如何解决Powershell脚本随处运行
我编写此代码来更改字符串,但是我只能从包含该代码的文件夹中运行它。文件,但我想从任何地方运行它。错误在哪里
$filePath = Get-ChildItem -Path "C:\myfolder\config" -Filter *.config |Select -First 1
$tempFilePath = "$env:TEMP\$($filePath | Split-Path -Leaf)"
$find = 'test1'
$replace = 'test2'
(Get-Content -Path $filePath) -replace $find,$replace | Add-Content -Path $tempFilePath
Remove-Item -Path $filePath
Move-Item -Path $tempFilePath -Destination $filePath
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。