PowerShell: Cannot find path Error

The attached script suddenly not working.  I am getting an error indicating that 'Cannot find path'.  The script was working great prior to this error.  I can open the .csv file using Notepad. I check the permissions on the folder and the file.  Full access has been granted.

Can someone advise as to what may be the issue and what troubleshooting I should consider?

review the following error:
PS C:\WinUpVer> C:\Fix\GetWmiObj08AutoWinUpV4.ps1
Get-Content : Cannot find path 'C:\WinUpVer\Updates.csv' because it does not exist.
At C:\Fix\GetWmiObj08AutoWinUpV4.ps1:1 char:13
+ $servers = (Get-Content .\Updates.csv)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\WinUpVer\Updates.csv:String) [Get-Conte
   nt], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand



PS C:\WinUpVer>
$servers = (Get-Content .\Updates.csv)
$servers | ForEach-Object {
  $Server = $_
  "Processing $Server ... " | Write-Host -NoNewline -ForegroundColor White
  Try {
    $QFEGroups = Get-WmiObject -Class "Win32_QuickFixEngineering" -ComputerName $Server -ErrorAction Stop |
      Select-Object -Property `
        @{Name="InstalledOn"; Expression={([DateTime]($_.InstalledOn)).ToLocalTime()}} |
      Group-Object -Property Description
    $LastHotfix = ($QFEGroups | ? {$_.Name -eq "Hotfix"}).Group | Sort-Object -Property InstalledOn | Select-Object -Last 1
    $LastUpdate = ($QFEGroups | ? {$_.Name -eq "Update"}).Group | Sort-Object -Property InstalledOn | Select-Object -Last 1
    $LastSecurityUpdate = ($QFEGroups | ? {$_.Name -eq "Security Update"}).Group | Sort-Object -Property InstalledOn | Select-Object -Last 1
    "" | Select-Object -Property `
      @{Name="ComputerName"; Expression={$Server}},
      @{Name="Hotfix"; Expression={$LastHotfix.HotfixID}},
      @{Name="HF_InstalledOn"; Expression={$LastHotfix.InstalledOn}},
      @{Name="Update"; Expression={$LastUpdate.HotfixID}},
      @{Name="UP_InstalledOn"; Expression={$LastUpdate.InstalledOn}},
      @{Name="Security Update"; Expression={$LastSecurityUpdate.HotfixID}},
      @{Name="SU_InstalledOn"; Expression={$LastSecurityUpdate.InstalledOn}},
    "OK." | Write-Host -ForegroundColor Green
  } Catch {
    $_.Exception.Message | Select-Object -Property `
      @{Name="ComputerName"; Expression={$Server}},
      "Security Update",
      @{Name="Error"; Expression={$_}}
    $_.Exception.Message | Write-Host -ForegroundColor Red
} | Export-Csv -NoTypeInformation -Path "C:\WinUpVer\WinUpdateVerify.csv"

Open in new window

lipotechSys EngAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
If you can access the CSV with the full path as reported in the error message, 'C:\WinUpVer\Updates.csv', then it is indeed very strange.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lipotechSys EngAuthor Commented:

Issue resolved. I determined it was a credentials issue.  What is odd is that I used the same credentials multiple times to execute this script and it ran successfully. Suddenly it failed to execute with the original credentials.

Question: How did you move the attached script into a code block? Not sure how I would accomplish that task.

Thank you for your response.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.