I'm attempting to run a very simple script on a different server and am getting an ItemNotFoundException. Here's my script:
Invoke-Command -ComputerName myserver -FilePath C:\laurietest\testthis.ps1
Invoke-Command -ComputerName myserver -ScriptBlock {
Write-Output "Directory before copying:"
Get-ChildItem C:\laurietest\
Copy-Item -Path C:\laurietest\output.txt -Destination C:\laurietest\output2.txt
Write-Output "Directory after copying:"
Get-ChildItem C:\laurietest\
}
And here's the output I get when I run the command:
It lists the contents of the directory and the file testthis.ps1 is definitely there, but the Invoke-Command can't seem to find it. Any ideas?