Powershell PVS运行状况检查脚本

Powershell PVS运行状况检查脚本,powershell,powershell-3.0,citrix,Powershell,Powershell 3.0,Citrix,我运行此脚本时出错。我试图调试它,但我不确定为什么会出现错误 $currentDir = Split-Path $MyInvocation.MyCommand.Path $logfile = Join-Path $currentDir ("PVSHealthCheck.log") $resultsHTM = Join-Path $currentDir ("PVSCheckResults.htm") $errorsHTM = Join-Path $currentDir ("PVSHealthChe

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

$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
分割路径:无法将参数绑定到参数“Path”,因为它为null。第1行字符:26
+$currentDir=拆分路径$MyInvocation.MyCommand.Path
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:InvalidData:(:)[Split Path],ParameterBindingValidationException
+FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SplitPathCommand
PS C:\Users\raw.admin>

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

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

你说我不能在ISE中运行它,我需要用Powershell CMD运行它?他说如果你想使用它,需要先将它保存为脚本。不用担心。木材树。这是常有的事。