New to the forums and new to powershell remoting.
I have a script that traverses a local folder and filters for a specific filename pattern and deletes the files.
Get-ChildItem -Path c:\users -Filter "*.auc" -Recurse -ErrorAction SilentlyContinue -Force | Remove-Item -Force
Everything works like a charm, when running on a local machine.
I want to run this script across several machines, but what takes 2-5 seconds when running local, takes 1-2 minutes when running it remote.
I can guess that the Get-ChildItem is returning all the objects back over the network and into the calling console and that is what makes an impact on the performance.
I understand that I could start some background jobs and have them running in parallel and just check when they are done.
But what I really would like to know and understand, is whether there is a way to just execute a script on a remote machine? An old school fire and forget, but with the local execution performance. I could easily push the same script onto the servers, in the same location and then execute it.
Is it possible to execute a local stored script via powershell remoting, but make sure that the execution is actually done local? Should I start a powershell.exe with parameters to achieve the results expected?
Any other ideas to achieve what I’m looking would be of incredible help!