This morning, I copied a directory from my local, networked drive to temp folder for testing. This error appeared.
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
This would be expected with the move...PS can't find the path referenced...but I made the following change prior to running the script (old commented out above the new):
$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
My first inkling is that there's some kind of cache holding my $inpath
variable from my last run...but have not been able to find out if that's expected PowerShell behavior. Am I misinterpreting the error or the solution? How do I flush the cache or whatever varables may be stored in memory?
Or use the PowerShell Cache Editor – to modify and update the existing cache, which can be found via the Ribbon->File->Home->Platform->Edit Cache icon.
In PowerShell, in order to clear the screen you can either type Clear-Host;, its aliases, cls; and clear; or its equivalent [System. Console]::Clear();.
Each PowerShell session has its own command history. To display the command history, use the Get-History cmdlet. By default, Clear-History deletes the entire command history from a PowerShell session. You can use parameters with Clear-History to delete selected commands.
I do not like the idea of having to close and re-open every time I need to clear the cache.
This works in PowerShell
Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With