Powershell将用户输入提供给下一步

时间:2017-02-24 08:03:51

标签: powershell-v3.0

Ibjust开始与Powershell合作并发现它非常有趣。在我的第一个代码,我真的很困惑: - )

$answer = read-host "Please Make a Selection"  
 if ($answer -eq 1){$result = Read-Host 'Enter Name for RestorePoint'}
 Checkpoint-Computer -Description $result 

错误:

Checkpoint-Computer : Cannot validate argument on parameter 'Description'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At D:\Scripts\RestorePoint.ps1:25 char:34
+  Checkpoint-Computer -Description <<<<  $result  
    + CategoryInfo          : InvalidData: (:) [Checkpoint-Computer], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.CheckpointComputerCommand

Restore-Computer : Cannot validate argument on parameter 'RestorePoint'. The argument is null. Supply a non-null argument and try the command again.
At D:\Scripts\RestorePoint.ps1:27 char:32
+  Restore-Computer -RestorePoint <<<<  $RPoint  
    + CategoryInfo          : InvalidData: (:) [Restore-Computer], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.RestoreComputerCommand

在输出上我遇到了一些错误。

0 个答案:

没有答案