write to server from remote client

I am calling a script on several clients from my application server. I am attempting to write everything to a log file on my file server. My master script on my application server calls a client script, also located on the application server, which kicks off a process on several clients. My master script updates the log file, but when I kick of the client script, the client script can only write to log files on the client machines, not the file server. I would like everything write to the log file my file server so I only have to go to one location to view the output.
I am running the master as admin, and I am using the Invoke-Command to run the client script on the client machines:
Invoke-Command -computername $DeviceName -FilePath $File -InDisconnectedSession -ErrorVariable e -ErrorAction SilentlyContinue
My client script attempts to write to the log file (“Starting Client Script” >> \server\path\file.txt) but fails. I can write to a local file on each client machine, such as “Starting Client Script” >> c:\temp\file.txt. I can also ping the file server from the client and write it to a log, such as ping server >> c:\temp\file.txt.
When I do a Test-Path \server or test-path ipaddress from the client script it comes back as false if it is called from the master script, otherwise it comes back as true.
Is there a way to have the client script write the output to the log file on the file server?

When you remote into a machine, you’re delegating your credentials to it, so it can perform tasks on your behalf. But it can’t delegate them any further by default, which means any non-local operations it tries to perform are done anonymously. This is often referred to as the “Second Hop Problem,” is described in “Secrets of PowerShell Remoting,” and is a pretty serious security discussion.

If you’re doing:

Invoke-Command -computername $DeviceName -FilePath $File -InDisconnectedSession -ErrorVariable e -ErrorAction SilentlyContinue

(Formatting code makes it a million times easier to help with), then I would make sure the script being run ($File) is doing the right thing and outputting objects to the pipeline. That way, you can capture those objects on your local machine and log them there. For example:

Invoke-Command -computername $DeviceName -FilePath $File -InDisconnectedSession -ErrorVariable e -ErrorAction SilentlyContinue |
Out-File \\MyFileServer\MyShare\output.txt

Or something. Remoting will bring the results back to you, and you can do something with them there, rather than asking the remote machine to do something with them. But that relies on $File being a well-designed PowerShell tool, outputting a uniform set of objects.

Alternately, have $File write everything to a local file on the remote machine, and then as its last step, Get-Content that file - which will send the contents back to your local computer, where you can put them wherever you want.

The Get-Contents process should work for me.

Thanks