AGMPowerCLISetFunctions.ps1
function Set-AGMImage([string]$imagename,[string]$imageid,[string]$label) { <# .SYNOPSIS Labels a nominated image .EXAMPLE Set-AGMImage You will be prompted for image Name .EXAMPLE Set-AGMImage -imagename Image_2133445 -label "testimage" Labels Image_2133445 with the label "testimage" .DESCRIPTION A function to label images #> if ((!($imagename)) -and (!($imageid))) { $imagename = Read-Host "ImageName" } if ($imageid) { $id = $imageid } if ($imagename) { $imagegrab = Get-AGMImage -filtervalue backupname=$imagename if ($imagegrab.id) { $id = $imagegrab.id } else { Get-AGMErrorMessage -messagetoprint "Failed to find $imagename" return } } if (!($label)) { $label = Read-Host "Label" } $body = @{label=$label} $json = $body | ConvertTo-Json Put-AGMAPIData -endpoint /backup/$id -body $json } Function Set-AGMSLA ([string]$id,[string]$slaid,[string]$appid,[string]$dedupasync,[string]$expiration,[string]$logexpiration,[string]$scheduler) { <# .SYNOPSIS Enables or disables an SLA Note that if both an SLA ID and an App ID are supplied, the App ID will be ignored. .EXAMPLE Set-AGMSLA -slaid 1234 -dedupasync disable Disables dedupasync for SLA ID 1234. .EXAMPLE Set-AGMSLA -slaid 1234 -expiration disable Disables expiration for SLA ID 1234. .EXAMPLE Set-AGMSLA -appid 5678 -expiration disable Disables expiration for App ID 5678. .EXAMPLE Set-AGMSLA -appid 5678 -logexpiration disable Disables log expiration for App ID 5678. .EXAMPLE Set-AGMSLA -slaid 1234 -scheduler enable Enables the scheduler for SLA ID 1234. .EXAMPLE Set-AGMSLA -slaid 1234 -scheduler disable Disables the scheduler for SLA ID 1234. .DESCRIPTION A function to modify an SLA #> if ( (!($AGMSESSIONID)) -or (!($AGMIP)) ) { Get-AGMErrorMessage -messagetoprint "Not logged in or session expired. Please login using Connect-AGM" return } if ($id) { $slaid = $id } if (($appid) -and (!($slaid))) { $slaid = (Get-AGMSLA -filtervalue appid=$appid).id } if (!($slaid)) { Get-AGMErrorMessage -messagetoprint "No SLA ID or App ID was supplied" return } $body = New-Object -TypeName psobject if ($dedupasync.ToLower() -eq "enable"){ $body | Add-Member -MemberType NoteProperty -Name dedupasyncoff -Value "false" } if ($dedupasync.ToLower() -eq "disable"){ $body | Add-Member -MemberType NoteProperty -Name dedupasyncoff -Value "true" } if ($expiration.ToLower() -eq "enable"){ $body | Add-Member -MemberType NoteProperty -Name expirationoff -Value "false" } if ($expiration.ToLower() -eq "disable"){ $body | Add-Member -MemberType NoteProperty -Name expirationoff -Value "true" } if ($logexpiration.ToLower() -eq "enable"){ $body | Add-Member -MemberType NoteProperty -Name logexpirationoff -Value "false" } if ($logexpiration.ToLower() -eq "disable"){ $body | Add-Member -MemberType NoteProperty -Name logexpirationoff -Value "true" } if ($scheduler.ToLower() -eq "enable"){ $body | Add-Member -MemberType NoteProperty -Name scheduleoff -Value "false" } if ($scheduler.ToLower() -eq "disable"){ $body | Add-Member -MemberType NoteProperty -Name scheduleoff -Value "true" } $jsonbody = $body | ConvertTo-Json Put-AGMAPIData -endpoint /sla/$slaid -body $jsonbody } |