在此PowerShell脚本中,每键入一个字符都会返回错误,而不是消息“仅输入数字”。
PS C:\ Users \ User \ Desktop>。\ Test.ps145454输入KB编号:asfs无法将值“ asfs”转换为类型“ System.Int32”。错误:“输入字符串的格式不正确。”在C:\ Users \ User \ Desktop \ Test.ps1:5 char:1+ [int] $ name =读主机输入知识库文章编号+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidArgument:(:) [],RuntimeException + FullyQualifiedErrorId:InvalidCastFromStringToInteger
这将卸载Windows更新KB0
[int] $ name =读取主机输入KB号如果($ name -is [int]){wusa / uninstall / kb:$ name写主机“这将卸载Windows更新KB $ name”}否则{写主机“仅输入数字”}在这里...