Public/console-endpoint.ps1
|
function New-CSConsoleEndpoint { <# .SYNOPSIS Creates a console endpoint for a virtual machine. .DESCRIPTION Wraps createConsoleEndpoint, returning the console URL and websocket connection details used to open a VM's console. An optional -Token can be supplied when the deployment requires one. .PARAMETER VirtualMachineId The VM to open a console for .PARAMETER Token An optional console access token, when the deployment requires one .EXAMPLE New-CSConsoleEndpoint -VirtualMachineId 'vm-uuid' Returns the console URL and websocket connection details for the VM. .EXAMPLE Get-CSVM -Name 'web-01' | ForEach-Object { New-CSConsoleEndpoint -VirtualMachineId $_.id } Opens a console endpoint for a VM located by name. #> [CmdletBinding()] param( [Parameter(Mandatory=$true)][string]$VirtualMachineId, [string]$Token ) $apiParams = @{ virtualmachineid = $VirtualMachineId } if ($PSBoundParameters.ContainsKey('Token')) { $apiParams['token'] = $Token } Invoke-CSApiRequest -Command 'createConsoleEndpoint' -Parameters $apiParams } |