public/Format-CTSDCard.ps1
#https://$($ip)/stw-cgi/system.cgi?msubmenu=storageinfo&action=control&Storage=1&Mode=Format Function Format-CTSDCard { [cmdletBinding( DefaultParameterSetName='All', SupportsShouldProcess = $true, ConfirmImpact='high' )] Param( [Parameter( Mandatory=$true, ParameterSetName='All' )] [String]$IP, [Parameter( Mandatory=$true, ParameterSetName='All' )] [pscredential]$Credential, [Parameter( Mandatory=$false, ParameterSetName='All' )] [int]$Storage=1 ) DynamicParam { $DynamicParameters = @{ CameraType = @{ Mandatory = $true Position = 1 ParameterSetName = "All" Enum = $Script:SupportedCameraModels } <#Storage = @{ Mandatory = $true Position = 2 ParameterSetName = "All" Enum = $Script:SupportedCameraModels } #> } $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary ForEach($entry in $DynamicParameters.Key) { $RuntimeParameterDictionary.Add($entry, $DynamicParameters[$entry]) } return $RuntimeParameterDictionary } Begin { Write-Debug "[Format-CTSDCard] Started" if($CameraType -eq 'Hanwha') { #Set basic Paramters for Invoke-HanwhaCommand $CamCmd = @{ Arguments = @{ IP = $IP Menu = 'system' SubMenu = 'storageinfo' Action = 'control' Parameters = @() } Credential = $Credential } #Add Action Parameters $CamCmd.Arguments.Parameters += "Storage=$Storage" $CamCmd.Arguments.Parameters += "Mode=Format" #Message Setup $SPDescription = "Storage Operation" $SPWarning = "This action will remove all data from the SD Card. Are you sure you want to do this?" $SPCaption = "Formatting SD Card" if($PSCmdlet.ShouldProcess($SPDescription,$SPWarning,$SPCaption)) { Invoke-HanwhaCommand @CamCmd } } } } |