Public/DesktopImage.ps1
Function Remove-NmeDesktopImageScriptSchedule { <# .SYNOPSIS Delete scheduled script execution job for desktop image. .DESCRIPTION Delete scheduled script execution job for desktop image. This function calls the /api/v1/desktop-image/{subscriptionId}/{resourceGroup}/{name}/script/schedule endpoint of the NME REST API, using the delete method. .PARAMETER SubscriptionId The id (guid) of the subscription where this desktopimage resides .PARAMETER ResourceGroup The Azure resource group where the desktopimage resides .PARAMETER Name The name of the desktopimage #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$Name ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/$SubscriptionId/$ResourceGroup/$Name/script/schedule$Querystring" -Method delete -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob') $Result | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'resourceGroup' -NotePropertyValue $resourceGroup -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'name' -NotePropertyValue $name -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeDesktopImageScriptSchedule { <# .SYNOPSIS Get scheduled script execution job params for desktop image. .DESCRIPTION Get scheduled script execution job params for desktop image. This function calls the /api/v1/desktop-image/{subscriptionId}/{resourceGroup}/{name}/script/schedule endpoint of the NME REST API, using the get method. .PARAMETER SubscriptionId The id (guid) of the subscription where this desktopimage resides .PARAMETER ResourceGroup The Azure resource group where the desktopimage resides .PARAMETER Name The name of the desktopimage #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$Name ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/$SubscriptionId/$ResourceGroup/$Name/script/schedule$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeScheduleRunCustomScriptOnVmRestModel') $Result | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'resourceGroup' -NotePropertyValue $resourceGroup -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'name' -NotePropertyValue $name -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function New-NmeDesktopImageScriptSchedule { <# .SYNOPSIS Schedule script execution on desktop image VM. .DESCRIPTION Schedule script execution on desktop image VM. This function calls the /api/v1/desktop-image/{subscriptionId}/{resourceGroup}/{name}/script/schedule endpoint of the NME REST API, using the post method. .PARAMETER SubscriptionId The id (guid) of the subscription where this desktopimage resides .PARAMETER ResourceGroup The Azure resource group where the desktopimage resides .PARAMETER Name The name of the desktopimage .PARAMETER NmeScheduleRunCustomScriptOnVmRestModel Requires an NmeScheduleRunCustomScriptOnVmRestModel object, as generated by the New-NmeScheduleRunCustomScriptOnVmRestModel command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$Name, [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeScheduleRunCustomScriptOnVmRestModel"){$true} else{throw " is not a NmeScheduleRunCustomScriptOnVmRestModel object."}})]$NmeScheduleRunCustomScriptOnVmRestModel ) Set-NmeAuthHeaders Try { $json = $NmeScheduleRunCustomScriptOnVmRestModel | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/$SubscriptionId/$ResourceGroup/$Name/script/schedule$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob') $Result | ForEach-Object {$_ | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue'} $Result | ForEach-Object {$_ | Add-Member -NotePropertyName 'resourceGroup' -NotePropertyValue $resourceGroup -erroraction 'SilentlyContinue'} $Result | ForEach-Object {$_ | Add-Member -NotePropertyName 'name' -NotePropertyValue $name -erroraction 'SilentlyContinue'} $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeDesktopImageSetAsImageSchedule { <# .SYNOPSIS Get scheduled "Set as image" job params for desktop image. .DESCRIPTION Get scheduled "Set as image" job params for desktop image. This function calls the /api/v1/desktop-image/{subscriptionId}/{resourceGroup}/{name}/set-as-image/schedule endpoint of the NME REST API, using the get method. .PARAMETER SubscriptionId The id (guid) of the subscription where this desktopimage resides .PARAMETER ResourceGroup The Azure resource group where the desktopimage resides .PARAMETER Name The name of the desktopimage #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$Name ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/$SubscriptionId/$ResourceGroup/$Name/set-as-image/schedule$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeDesktopImageSetAsImageScheduleRest') $Result | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'resourceGroup' -NotePropertyValue $resourceGroup -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'name' -NotePropertyValue $name -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeDesktopImageScheduledTask { <# .SYNOPSIS Get scheduled tasks for desktop image. .DESCRIPTION Get scheduled tasks for desktop image. This function calls the /api/v1/desktop-image/{subscriptionId}/{resourceGroup}/{name}/schedule endpoint of the NME REST API, using the get method. .PARAMETER SubscriptionId The id (guid) of the subscription where this desktopimage resides .PARAMETER ResourceGroup The Azure resource group where the desktopimage resides .PARAMETER Name The name of the desktopimage #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$Name ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/$SubscriptionId/$ResourceGroup/$Name/schedule$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeDesktopImageScheduleRestModel') $Result | ForEach-Object {$_ | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue'} $Result | ForEach-Object {$_ | Add-Member -NotePropertyName 'resourceGroup' -NotePropertyValue $resourceGroup -erroraction 'SilentlyContinue'} $Result | ForEach-Object {$_ | Add-Member -NotePropertyName 'name' -NotePropertyValue $name -erroraction 'SilentlyContinue'} $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function New-NmeDesktopImageSetAsImageTask { <# .SYNOPSIS Power off and set as image. .DESCRIPTION Power off and set as image. This function calls the /api/v1/desktop-image/{subscriptionId}/{resourceGroup}/{name}/set-as-image endpoint of the NME REST API, using the post method. .PARAMETER SubscriptionId The id (guid) of the subscription where this desktopimage resides .PARAMETER ResourceGroup The Azure resource group where the desktopimage resides .PARAMETER Name The name of the desktopimage .PARAMETER NmeSetAsImageRequest Requires an NmeSetAsImageRequest object, as generated by the New-NmeSetAsImageRequest command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$Name, [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeSetAsImageRequest"){$true} else{throw " is not a NmeSetAsImageRequest object."}})]$NmeSetAsImageRequest ) Set-NmeAuthHeaders Try { $json = $NmeSetAsImageRequest | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/$SubscriptionId/$ResourceGroup/$Name/set-as-image$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob') $Result | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'resourceGroup' -NotePropertyValue $resourceGroup -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'name' -NotePropertyValue $name -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function New-NmeDesktopImageCreateFromLibraryTask { <# .SYNOPSIS Create desktop image from Azure library. .DESCRIPTION Create desktop image from Azure library. This function calls the /api/v1/desktop-image/create-from-library endpoint of the NME REST API, using the post method. .PARAMETER NmeCreateImageFromLibraryRequest Requires an NmeCreateImageFromLibraryRequest object, as generated by the New-NmeCreateImageFromLibraryRequest command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeCreateImageFromLibraryRequest"){$true} else{throw " is not a NmeCreateImageFromLibraryRequest object."}})]$NmeCreateImageFromLibraryRequest ) Set-NmeAuthHeaders Try { $json = $NmeCreateImageFromLibraryRequest | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/create-from-library$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob') $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Start-NmeDesktopImageScript { <# .SYNOPSIS Run script on desktop image VM. .DESCRIPTION Run script on desktop image VM. This function calls the /api/v1/desktop-image/{subscriptionId}/{resourceGroup}/{name}/script endpoint of the NME REST API, using the post method. .PARAMETER SubscriptionId The id (guid) of the subscription where this desktopimage resides .PARAMETER ResourceGroup The Azure resource group where the desktopimage resides .PARAMETER Name The name of the desktopimage .PARAMETER NmeRunCustomScriptOnVmRestModel Requires an NmeRunCustomScriptOnVmRestModel object, as generated by the New-NmeRunCustomScriptOnVmRestModel command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$Name, [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeRunCustomScriptOnVmRestModel"){$true} else{throw " is not a NmeRunCustomScriptOnVmRestModel object."}})]$NmeRunCustomScriptOnVmRestModel ) Set-NmeAuthHeaders Try { $json = $NmeRunCustomScriptOnVmRestModel | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/desktop-image/$SubscriptionId/$ResourceGroup/$Name/script$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob') $Result | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'resourceGroup' -NotePropertyValue $resourceGroup -erroraction 'SilentlyContinue' $Result | Add-Member -NotePropertyName 'name' -NotePropertyValue $name -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } |