【发布时间】:2017-06-11 22:42:23
【问题描述】:
我有这个脚本
#Change hostname
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
Write-Host "Change hostname " -NoNewLine
$ComputerName = [Microsoft.VisualBasic.Interaction]::InputBox('Insert the desired computername:', 'Change hostname')
Write-Host "- DONE" -ForegroundColor DarkGreen -BackgroundColor green -NoNewline
Write-Host " hostname = $ComputerName "
Rename-Computer -NewName $ComputerName
当计算机名有空格时,它会失败导致主机名不能有空格。 我可以阻止表单有任何空格还是有人知道在创建错误以重试时如何返回输入框
【问题讨论】:
标签: loops powershell try-catch finally