Public/Renderer/Set-ASRResolution.ps1
function Set-ASRResolution { Param( [Parameter(Mandatory=$false)][String]$Shell, [Parameter(Mandatory=$true, Position=1)][string]$x, [Parameter(Mandatory=$false, Position=2)][string]$y ) # first, get Shell we want to talk to $shellLocal = Get-ASDefaultShell if($PSBoundParameters['Shell']) { $shellLocal = $Shell } if([System.String]::IsNullOrEmpty($shellLocal)) { Write-Host 'Target shell is not set. Please specify target shell with -Shell parameter or by Set-ASDefaultShell snippet.' return } if([System.String]::IsNullOrEmpty($x)) { Write-Host "You must provide both x and y for resolution. You can do so by specifying both -x and -y parameters, or pass size in 000x000 format."; return; } $_x = 0; $_y = 0; $hasY = $PSBoundParameters.ContainsKey("y"); $isSet = $false; if($x.ToLower() -eq "4k") { $_x = 3840; $_y = 2160; $isSet = $true; } if($x.ToLower() -eq "2.5k") { $_x = 2560; $_y = 1440; $isSet = $true; } if($x.ToLower() -eq "fullhd") { $_x = 1920; $_y = 1080; $isSet = $true; } if($x.ToLower() -eq "hdready") { $_x = 1280; $_y = 720; $isSet = $true; } if( $isSet -eq $false ) { if($x.Contains("x")) { $split = $x.Split('x'); $_x = [System.Single]::Parse($split[0]); $_y = [System.Single]::Parse($split[1]); } else { if( $hasY ) { $_x = [System.Single]::Parse($x); $_y = [System.Single]::Parse($y); } else{ Write-Host "You must provide both x and y for resolution. You can do so by specifying both -x and -y parameters, or pass size in 000x000 format."; return; } } } Write-Host "Setting resolution to $($_x) x $($_y)" $uri = "http://$($shellLocal):4444/api/renderer/setresolution?width=$($_x)&height=$($_y)" $result = Invoke-RestMethod -Uri $uri -Method POST Write-Host $result } |