to enable psremoting on network computers

hi friends,

am looking for a ps script to enable psremoting on network computers using pstools .

below is my script

but this didn’t work as this enable only the first computer starts with hostname “pndt0001”

$computers=Get-ADComputer -filter ‘name -like “pndt000*”’|select -ExpandProperty name
foreach ($computer in $computers)
{C:\PSTools\PsExec.exe \$computer -s powershell Enable-PSRemoting -force}

am looking for script which first should test the connections to listed computers and then pass tested connection machines to execute the command by filtering not connected machines.

thanks

Hi Srikanth,

Going to ask a bit of an obvious question here.

Why not use Group Policy to enable PSRemoting?
Chances are this day and age if you hear to word ‘Psexec’ its probably not the best way to do it.

I agree with Flynn, GPO is the way to go.

hi Flynn,

i was aware of this option doing via GPO but we have very limit scope on AD given to us (i hope that you got my point now) .

we have around 300 machines in our organisation after researching for days i found this option of doing via Psexec and can able to do it for single machine at one time .

i need a script for enabling psremoting for multiple machine at one time .