powershell - Powershell 错误 - 意外的令牌错误
问题描述
执行以下操作时出现错误。以下将 $env:userprofile 与路径连接的方法是否正确?
$env:userprofile\Documents\DNS\GetDnsRecord.ps1 | ConvertTo-Csv -NoTypeInformation | Select-Object -Skip 1 | Out-File -Append $env:userprofile\Documents\DNS\DnsRecord.csv
错误:
+ $env:userprofile\Documents\DNS\GetDnsRecord.ps1 | ConvertTo-Csv -NoTy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '\Documents\DNS\GetDnsRecord.ps1' in expression or statement.
谢谢您的帮助
约翰
解决方案
您可能想了解一下加入路径:https ://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/join-path?view=powershell-7
Join-Path $env:userprofile '\Documents\DNS\GetDnsRecord.ps1'
推荐阅读
- javascript - 如何使用cordova-plugin-filepath?
- python - 使用未按预期工作的关键参数按频率排序
- arrays - 如何替换字符串中的匹配字符?(红宝石)
- android - 如何最好地部署 Android 应用程序并允许更新
- javascript - 如何记录来自 fetch api 的响应
- java - 如何检查字符是否来自特定的字符集
- scala - 使用 H2 数据库时 Quill 中插入或更新操作的编译错误
- javascript - 检查字符串是否仅包含表情符号 - Javascript
- mysql - innodb 梭子鱼文件格式与希捷的关系
- javascript - 如何将 vue 数据绑定添加到动态创建的元素