Forum Discussion

dmarquesgn's avatar
dmarquesgn
Iron Contributor
Jul 25, 2022

Running remote script to write in file share

Hi,

I'm building a script for checking, downloading and installing updates on Windows Servers, using the PSWindowsUpdate module.

My goal is to go to one server a time, check for updates and write a log file in csv format to a fileshare, so after I can parse that CSV file to do some checks and then apply the updates later on.

The issue is that when running the script (from a server), I get the message:
"Access to the path '\path\filename.csv' is denied."


But if I go directly to the server itself and run the command, it works, as the server has permissions over that folder. 
So it's something while I'm running the script remotely that is not right.
I've tried several ways, like:

- Enter-PSSession
- Invoke-Command -ComputerName $server { command }

- Invoke-Command -Session $s -ScriptBlock { command }

So what I am missing here?

 

Thanks

11 Replies

Resources