PowerShell 报错信息:
PS D:\Download> PowerShell -ExecutionPolicy Bypass -File .\install-safe-rm.ps1
所在位置 D:\Download\install-safe-rm.ps1:166 字符: 56
- ... if (Select-String -Path $IflowAgents -Pattern "trash" -Quiet) {
-
表达式或语句中包含意外的标记“trash" -Quiet) {
Write-Host "iflow”。
所在位置 D:\Download\install-safe-rm.ps1:197 字符: 21
- Write-Host " trash - Move file to Recycle Bin"
-
“<”运算符是为将来使用而保留的。
所在位置 D:\Download\install-safe-rm.ps1:198 字符: 18
- Write-Host " rm - Alias -> trash"
-
“<”运算符是为将来使用而保留的。
所在位置 D:\Download\install-safe-rm.ps1:199 字符: 23
- Write-Host " real-rm - Permanently delete"
-
“<”运算符是为将来使用而保留的。
所在位置 D:\Download\install-safe-rm.ps1:204 字符: 63
- Write-Host " - Keep important files under Git version control"
-
字符串缺少终止符: "。
所在位置 D:\Download\install-safe-rm.ps1:163 字符: 50
- if (Test-Path (Split-Path $IflowAgents -Parent)) {
-
语句块或类型定义中缺少右“}”。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
导致出问题的行如下:
Write-Host " trash - Move file to Recycle Bin"
Write-Host " rm - Alias -> trash"
Write-Host " real-rm - Permanently delete"
原因:
引号 / 字符串被截断、不闭合
直接在 Write-Host 里用 < > 符号,PowerShell 会当成运算符报错
缺少闭合的 } 导致脚本结构损坏
修改后实测通过,修改如下:
Write-Host " trash FILE - Move file to Recycle Bin"
Write-Host " rm FILE - Alias to trash"
Write-Host " real-rm FILE - Permanently delete"
测试结果:

PowerShell 报错信息:
PS D:\Download> PowerShell -ExecutionPolicy Bypass -File .\install-safe-rm.ps1
所在位置 D:\Download\install-safe-rm.ps1:166 字符: 56
表达式或语句中包含意外的标记“trash" -Quiet) {
Write-Host "iflow”。
所在位置 D:\Download\install-safe-rm.ps1:197 字符: 21
“<”运算符是为将来使用而保留的。
所在位置 D:\Download\install-safe-rm.ps1:198 字符: 18
“<”运算符是为将来使用而保留的。
所在位置 D:\Download\install-safe-rm.ps1:199 字符: 23
“<”运算符是为将来使用而保留的。
所在位置 D:\Download\install-safe-rm.ps1:204 字符: 63
字符串缺少终止符: "。
所在位置 D:\Download\install-safe-rm.ps1:163 字符: 50
语句块或类型定义中缺少右“}”。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
导致出问题的行如下:
Write-Host " trash - Move file to Recycle Bin"
Write-Host " rm - Alias -> trash"
Write-Host " real-rm - Permanently delete"
原因:
引号 / 字符串被截断、不闭合
直接在 Write-Host 里用 < > 符号,PowerShell 会当成运算符报错
缺少闭合的 } 导致脚本结构损坏
修改后实测通过,修改如下:
Write-Host " trash FILE - Move file to Recycle Bin"
Write-Host " rm FILE - Alias to trash"
Write-Host " real-rm FILE - Permanently delete"
测试结果:
