Feb 8, 2013

Psexec examples

 What

Psexec usage examples

 Problem

I wanted to install/administrating multiple software/workstations deployments through a simple way

 Solution

PsExec from Sysinternals, this as a great tool that every network administrator should know! It's very handy and you can do a little of usefull stuff on many computers with running one command!

Download psexec here: http://download.sysinternals.com/files/PSTools.zip


We can run a command prompt on a remote system and interact with it, use following command:
psexec \\<ip or hostname> -u "user" -p "passwd" cmd

We can play a sound on a remote system using sndrec32:
psexec \\<ip or hostname> sndrec32 /play /close c:\windows\media\chimes.wav

We can open a webpage on every pc listed in an text file:
psexec @mylabPCs.txt -i -d iexplore http://brumnix.blogspot.com

We can make a screenshot from a pc:
psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" -i -c nircmd.exe savescreenshot "c:\shot.png"
psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" -i -c nircmd.exe loop 20 60000 savescreenshot "scr~$currdate.MM_dd_yyyy$-~$currtime.HH_mm_ss$.png"

We can install an .msi packet silently to multiple computers:
psexec @mylabPCs.txt -u "DOMAIN\administrator" -p "password" cmd /c "msiexec.exe /i "\\server\shared\setup.msi" /quiet /norestart"

We can run a command on multiple computers also with the following syntax:
for /f %%a in (c:\list.txt) do (
psexec \\%%a ipconfig /renew
)

We can change the windows firewall and allow UltraVNC protocol:
psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" cmd
netsh advfirewall firewall add rule name="UltraVNC" protocol=TCP localport=5900 action=allow dir=IN
netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes

We can change the computername if powershell has been installed:
psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" cmd
powershell
PS: $sysInfo = Get-WmiObject -Class Win32_ComputerSystem
PS: $sysInfo.Rename("NEWCOMPUTERNAME")
PS: restart-computer

No comments:

Post a Comment