提问人:Steini 提问时间:11/14/2023 最后编辑:Steini 更新时间:11/15/2023 访问量:27
Powershell 在使用 rightclick->open with 时在“copy-item”期间死机,但在 powershell 中打开路径手册时没问题
Powershell dies during "copy-item" when using rightclick->open with but is fine when opening the path manual in powershell
问:
我有一个powershell脚本,它从带有一些过滤器的路径中复制了很多文件。
非常奇怪的行为: 当我使用以下命令打开 powershell 脚本时: 右键单击>使用 powershell(或双击)run
脚本在复制命令时死亡。
当我打开一个空白的 powershell 时, 使用“cd”转到脚本所在的路径 然后使用 \run.ps1 运行 Shellscript
然后它工作正常。
在这两种情况下,回声“$($pwd)”的回声是相同的。
是否有已知的错误,或者我可以做任何事情来使用右键单击方法使其工作?
我的脚本的相关行。当我注释掉“Copy-Item”路径时,脚本正常工作。
if($null -eq $env:DEVROOT) {
echo "Error: Please configure Windows environment-variable DEVROOT
to the root-folder of your projects."
pause
return
}
$devRootPath = "$env:DEVROOT"
$copyExcludes = ".git",".svn",".idea",".vscode"
$destinationPath = "code-temp-store\"
Get-ChildItem "$($devRootPath)\lma\" | Where-Object{$_.Name -notin $copyExcludes} |
Copy-Item -Destination $destinationPath -Recurse -Force
答: 暂无答案
评论
Copy-Item
Copy-
Item
$_.Name -notin $copyExcludes
$devRootPath