I have 2 scripts that work in my testing environment just fine but do not work in production. Script 1 reads a csv file to create AD accounts, then uses Invoke-Command with Script 2 to create user folders on the file server. All servers are 2008 and running PS v.3.
Script 2 runs New-Psdrive to connect back to Server 1, Test-Path to check for a csv file, then Copy-Item to copy the csv on to Server 2, then Remove-Psdrive.
Problem: I get “PermissionDenied” “UnauthorizedAccessException” on the Test-Path and Copy_Item commands only when using Invoke-Command on Server 1. I can run script 2 locally on server 2 and the commands succeed. Likewise, I can run both commands from server 1 using a PSsession and they execute as expected. I don’t get an error with the New-Psdrive, and other commands seem to run on Server 2 like log creation and email.
I use the same user in all cases and shares/permissions are set to full for the user.