这太奇怪了。我可以复制它。但我不能解释为什么会这样。我的猜测是,在调用PowerShell运行脚本时,这在某种程度上是路径分析中的一个优化错误。你打电话来的时候也有同样的问题
里面
PowerShell,当这样调用它时,例如:
. "powershell.exe" -File C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_UsageStats.xlsx_ExcelRefresh.ps1
# or
Start-Process "powershell" -Arg "-File", "C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_UsageStats.xlsx_ExcelRefresh.ps1"
我可以给你一些建议,哪些替代方案应该有效:
最简单:删除或替换点!
powershell -File "C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_UsageStats_xlsx_ExcelRefresh.ps1"
或者,这些变化也应起作用:
# Pass a command which calls the script using the call operator (&)
# Note: The single quotes are necessary! Else you will have the same behavior
powershell -Command "& 'C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_UsageStats.xlsx_ExcelRefresh.ps1'"
# A workaround to avoid the issue that's probably causing this.
# The semicolon basically puts an empty command at the beginning.
# This supports my theory, that this is somehow an optimization bug.
powershell -Command ";& C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_UsageStats.xlsx_ExcelRefresh.ps1"
# Base64-encoded version of
# "& C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_UsageStats.xlsx_ExcelRefresh.ps1"
powershell -EncodedCommand "JgAgAEMAOgBcAFMAVgBOAFwAQgB1AHMAaQBuAGUAcwBzAEEAbgBhAGwAeQBzAHQAcwBcAEUAeABjAGUAbABUAG8AbwBsAHMAXABEAGEAdABhAGIAYQBzAGUAUwBTAEEAUwBfAFUAcwBhAGcAZQBTAHQAYQB0AHMALgB4AGwAcwB4AF8ARQB4AGMAZQBsAFIAZQBmAHIAZQBzAGgALgBwAHMAMQA="
我给微软写了一些关于这方面的反馈,但是我建议你进一步调查这一点,并可能给PowerShell团队写一个bug报告。