PVS健康检查脚本

时间:2015-09-08 18:55:16

标签: powershell powershell-v3.0 citrix

运行此脚本时出现错误。我正在尝试调试它,但我不确定为什么我会收到错误。

$currentDir = Split-Path $MyInvocation.MyCommand.Path
$logfile = Join-Path $currentDir ("PVSHealthCheck.log")
$resultsHTM = Join-Path $currentDir ("PVSCheckResults.htm")
$errorsHTM = Join-Path $currentDir ("PVSHealthCheckErrors.htm")

这是错误,

PS C:\Users\raw.admin> $currentDir = Split-Path $MyInvocation.MyCommand.Path
Split-Path : Cannot bind argument to parameter 'Path' because it is null. At line:1 char:26
+ $currentDir = Split-Path $MyInvocation.MyCommand.Path
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Split-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SplitPathCommand

PS C:\Users\raw.admin> 

我是否需要先创建$currentDir变量并设置路径?

1 个答案:

答案 0 :(得分:2)

$MyInvocation.MyCommand.Path未在控制台中填充,因为您没有运行脚本,因此没有该脚本的路径。