guidance on how to remotely run powershell function, please

I am working on automating WSUS updates.

I have a simple, basic script here that I can use: https://gist.github.com/jacobludriks/9ca9ce61de251a5476f1

It’s also a function, which is good :slight_smile:

My desire is to run the function remotely upon an array of servers, like so:

foreach in $servers array, e.g. foreach ($server in $servers) {

** properly connect to server

run the wsus update function

sleep/wait a few minutes

next server

Is this a good way to do this and what code do I need to ** properly connect to the server??

What is the proper code for server connection such that I can use $server and not the actual server name??

Thank you, Tom

Hi Tom,

Best thing i can recommend is to take a look at the free ebook Secrets of PowerShell remoting.

You can find it via Resources / Free E-Books on this site or directly via :

https://www.penflip.com/powershellorg/secrets-of-powershell-remoting

OIC – found and downloaded.

Seems what I must do now is write a test script and practice having it run remotely on the servers, then work on the WSUS stuff.

Thank you, Tom