title: Cannot find path because it doesn't exist
body: <p>I have written the below PowerShell script to do a remote Office uninstall.</p>
  
  <pre><code>$computers = @("WGBCZC4253TQY")
  
  foreach ($computer in $computers) {
      Copy-Item -Force -Recurse -Verbose -Path \\sgblon340012\O365\Remove-PreviousOfficeInstalls -Destination \\$computer\C$\temp200718\
  
      Invoke-Command -ComputerName $computer -ScriptBlock {
          &amp; { 
              Set-ExecutionPolicy -ExecutionPolicy Bypass -Force -Verbose
              cd C:\temp200718\Remove-PreviousOfficeInstalls -Verbose
              . .\Remove-PreviousOfficeInstalls.ps1
              Remove-PreviousOfficeInstalls
              Set-ExecutionPolicy -ExecutionPolicy Bypass -Force -Verbose
          }
      }
  
      Remove-Item -Force -Recurse \\$computer\C$\temp200718 -Verbose
  }
  </code></pre>
  
  <p>but it generates the below errors about the path not existing even though you can clearly see that it does exist as the files have just been copied!</p>
  
  <pre>
  VERBOSE: Performing the operation "Copy Directory" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls Destination: \\WGBCZC4253TQY\C$\temp200718\".
  VERBOSE: Performing the operation "Create Directory" on target "Destination: \\WGBCZC4253TQY\C$\temp200718\".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\OffScrub03.vbs Destination: \\WGBCZC4253TQY\C$\temp200718\OffScrub03.vbs".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\OffScrub07.vbs Destination: \\WGBCZC4253TQY\C$\temp200718\OffScrub07.vbs".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\OffScrub10.vbs Destination: \\WGBCZC4253TQY\C$\temp200718\OffScrub10.vbs".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\OffScrubc2r.vbs Destination: \\WGBCZC4253TQY\C$\temp200718\OffScrubc2r.vbs".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\OffScrub_O15msi.vbs Destination: \\WGBCZC4253TQY\C$\temp200718\OffScrub_O15msi.vbs". VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\OffScrub_O16msi.vbs Destination: \\WGBCZC4253TQY\C$\temp200718\ OffScrub_O16msi.vbs".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\README.md Destination: \\WGBCZC4253TQY\C$\temp200718\README.md".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\README_Remove-PreviousOfficeInstalls.md Destination: \\WGBCZC4253TQY\C$\temp200718\README_Remove-PreviousOfficeInstalls.md".
  VERBOSE: Performing the operation "Copy File" on target "Item: \\sgblon340012\O365\Remove-PreviousOfficeInstalls\Remove-PreviousOfficeInstalls.ps1 Destination: \\WGBCZC4253TQY\C$\temp200718\Remove-PreviousOfficeInstalls.ps1".
  VERBOSE: Performing operation "Set-ExecutionPolicy" on Target "Bypass". Cannot find path 'C:\temp200718\Remove-PreviousOfficeInstalls' because it does not exist.
      + CategoryInfo          : ObjectNotFound: (C:\temp200718\R...sOfficeInstalls:String) [Set-Location], ItemNotFoundException
      + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
      + PSComputerName        : WGBCZC4253TQY   The term '.\Remove-PreviousOfficeInstalls.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or  if a path was included, verify that the path is correct and try again.
      + CategoryInfo          : ObjectNotFound: (.\Remove-PreviousOfficeInstalls.ps1:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
      + PSComputerName        : WGBCZC4253TQY   The term 'Remove-PreviousOfficeInstalls' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a  path was included, verify that the path is correct and try again.
      + CategoryInfo          : ObjectNotFound: (Remove-PreviousOfficeInstalls:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
      + PSComputerName        : WGBCZC4253TQY   VERBOSE: Performing operation "Set-ExecutionPolicy" on Target "Bypass".
  VERBOSE: Performing the operation "Remove Directory" on target "\\WGBCZC4253TQY\C$\temp200718".
  VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\OffScrub03.vbs".
  VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\OffScrub07.vbs".
  VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\OffScrub10.vbs". VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\OffScrubc2r.vbs".
  VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\OffScrub_O15msi.vbs".
  VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\OffScrub_O16msi.vbs".
  VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\README.md". VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\README_Remove-PreviousOfficeInstalls.md".
  VERBOSE: Performing the operation "Remove File" on target "\\WGBCZC4253TQY\C$\temp200718\Remove-PreviousOfficeInstalls.ps1".
  </pre>