今天早上,我将一个目录从本地网络驱动器复制到临时文件夹进行测试。出现了这个错误。
Get-Content : Cannot find path 'C:\users\xxxxx\desktop\cgc\Automatic_Post-Call_Survey_-_BC,_CC.txt' because it does no
t exist.
At C:\users\xxxxx\desktop\cgc\testcountexcl1.ps1:55 char:12
+ Get-Content <<<< $txtfile | Get-WordCount -Exclude (Get-Content c:\temp\exclude.txt) | select -First 15
+ CategoryInfo : ObjectNotFound: (C:\users\xxxxx...ey_-_BC,_CC.txt:String) [Get-Content], ItemNotFoundEx
ception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
这将是预期的移动...PS 找不到引用的路径...但我在运行脚本之前进行了以下更改(旧的注释在新的上面):
$input = Get-Content c:\temp\wordCount.txt
<# $inpath = "C:\users\xxxxx\desktop\cgc\tx" #>
$inpath = "C:\temp\tx"
$srcfiles = Get-ChildItem $inpath -filter "*.txt"
$notPermittedWords = Get-Content c:\temp\exclude.txt
我的第一个暗示是有某种缓存保存我的
$inpath
我上次运行的变量......但无法确定这是否是预期的 PowerShell 行为。我是否误解了错误或解决方案?如何刷新缓存或任何可能存储在内存中的变量?
最佳答案
我不喜欢每次需要清除缓存时都必须关闭并重新打开的想法。
这适用于 PowerShellRemove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host
关于caching - Powershell 是否有需要清除的缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14502611/