PSGpfsApi/Public/GpfsSmbShare.ps1

53 lines
1.4 KiB
PowerShell

function Get-GpfsSmbShare {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 0)]
[string]$ShareName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "smb/shares/$ShareName"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint 'smb/shares'
}
}
function New-GpfsSmbShare {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess('SMB share', 'Create')) {
Invoke-GpfsApiRequest -Method POST -Endpoint 'smb/shares' -Body $Settings
}
}
function Set-GpfsSmbShare {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$ShareName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($ShareName, 'Update SMB share')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "smb/shares/$ShareName" -Body $Settings
}
}
function Remove-GpfsSmbShare {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$ShareName
)
if ($PSCmdlet.ShouldProcess($ShareName, 'Remove SMB share')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "smb/shares/$ShareName"
}
}