caching - Powershell 是否有需要清除的缓存?

标签 caching powershell

今天早上,我将一个目录从本地网络驱动器复制到临时文件夹进行测试。出现了这个错误。

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 行为。我是否误解了错误或解决方案?如何刷新缓存或任何可能存储在内存中的变量?

最佳答案

我不喜欢每次需要清除缓存时都必须关闭并重新打开的想法。

这适用于 PowerShell
Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host

关于caching - Powershell 是否有需要清除的缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14502611/

相关文章:

http - 如果我为 http 过期设置了遥远的 future 日期,我该如何推送意外更改?

ruby-on-rails - 什么会导致 Rails 页面缓存停止工作?

cocoa-touch - 是否可以防止 NSURLRequest 在请求后缓存数据或删除缓存的数据?

azure - 删除 X 天前的 Azure 快照

windows - 如何在PowerShell中查询Windows 10设备的经纬度?

powershell - 我如何在执行命令之前获取第一个输出-Powershell

asp.net - HttpContext.Cache物理内存使用情况

matlab - 将 Matlab 函数结果缓存到文件

powershell - 如何修剪字符串直到第一个大写字母

xml - 使用 Powershell 进行外科 XML 编辑