本文是用 az network bastion rdp --name 生成rdp文件后的修改,因为rdp文件中默认时多屏打开VM,本人只想用一个屏幕显示,测试多种方法无法直接获取到命令的结果,修改替换之后在保持成x.rdp文件,如果有知道怎么修改的朋友,请不惜赐教,谢谢!
$basePath = "C:\Users\seare\AppData\Local\Temp"
$fileName = Read-Host "please input file name "
$fullPath = Join-Path $basePath $fileName
try {
$content = Get-Content -Path $fullPath
$newLineIndex = 1
$replaceLine = "use multimon:i:0"
$newLine = "smart sizing:i:1"
$linesToInsert = $content[0..$newLineIndex]
$linesToInsert += $replaceLine
$linesToInsert += $newLine
$linesToInsert += $content[($newLineIndex + 2)..($content.Count - 1)]
$linesToInsert | Set-Content -Path $fileName
}
catch {
Write-Error "not read $fileName"
}
替换前的内容:
full address:s:ironmanjboxsit:3389
alternate full address:s:ironmanjboxsit:3389
use multimon:i:1
gatewaycredentialssource:i:5
gatewayusagemethod:i:1
gatewayprofileusagemethod:i:1
gatewayhostname:s:bst-3f6cac8e-d1cf-46b0-9595-9eef
gatewayaccesstoken:s:eyJhbGciOiJSUzI1NiIsInR5cCI6I
signscope:s:Full Address,Alternate Full Address,Ga
signature:s:AQABAAEAAAChCwAAMIAGCSqGSIb3DQEHAqCAMI
替换后的内容:
use multimon:i:1 --1-->0
smart sizing:i:1 --add line
full address:s:ironmanjboxsit:3389
alternate full address:s:ironmanjboxsit:3389
use multimon:i:0
smart sizing:i:1
gatewaycredentialssource:i:5
gatewayusagemethod:i:1
gatewayprofileusagemethod:i:1
gatewayhostname:s:bst-3f6cac8e-d1cf-46b0-9595-9eef
gatewayaccesstoken:s:eyJhbGciOiJSUzI1NiIsInR5cCI6I
signscope:s:Full Address,Alternate Full Address,Ga
signature:s:AQABAAEAAAChCwAAMIAGCSqGSIb3DQEHAqCAMI