Thursday, February 28, 2013

PsExec Automated Installs

My first tech related post is going to be about the Sysinternals utility, PsExec. This is a pretty common utility that most Windows techies know about. PsExec has been around for some time, but I still feel it hasn't gotten the recognition it deserves. 

For those of you not familliar with the Windows Sysinternals I implore you to visit their site before reading further, you'll thank me. If you are familiar, keep reading. 

My Reasons

I have used automation programs that cost a pretty penny. The ones I have experience with:

Symantec Ghost (a distant memory, lol)

Altiris Deployment Solution 6.9 with Inventory Solution (afterward we purchased 7.1)

Altiris Client Management Suite
7.1 (currently in use)

Sure, these are great utilities are for client, server, and image management and deployment, and I don't have any problem with that. I've had my fair share of times when I was in a pinch and they saved my skin. But a flaw with them and any such program is that they are all dependent on an installed service, open port(s), a certain .NET framework or other package, user permissions, or a combination of these. All PsExec needs is an enabled administrative share, e.g. \\computername\C$ and a network connection.

How I Use PsExec


In a nutshell PsExec is a utility that takes control of remote machines' command line. In fact, one of the most prized attributes of the program is that it can do so and run the process under the all-powerful SYSTEM account. If you still are doubtful of it's power then consider this, the SYSTEM account in Windows has the same privileges as root in Linux. In the release of Windows 7 Microsoft limited the local Administrator accounts' privileges even further. With PsExec you can take control of your command-line and you can do it remotely.

Here is a PsExec list script (syntax and examples) to query for logged-on users before restarting their machines in a thawed state with Faronics Deep Freeze

@echo off
psexec @Query.txt -s -high cmd /c query user /server
echo ****If PSExec worked you will see the currently logged on users****
echo ****If PSExec could not find the computer it is not powered on****
pause > nul
Set /P Restart=Would you like to restart? Y or N
 if /I "%Restart%"=="Y" goto restart
Yes, I know it's messy. I normally don't have much time to create my scripts so feel free to edit it and post it back in the comments

I made this in response to the Altiris Client Management 7.1s' poor agent update time. So, the Altiris agent reported that no one was logged-on when there were logged-on users. That led to restarting computers to update them and the users losing their work (whoops!). Although the agent check-in time is configurable, I decided not to use unnecessary amounts of network and server resources (our LAN is very limited) and created a script instead

I have dozens of other PsExec scripts to perform a variety of tasks: silent application installation, OS customization, application and computer serial inventory, even remote imaging with a PE installation and imagex.exe! Although management software is designed to do all of these things it can be unreliable and can hog both client and server resources, not to mention the cost.

Thanks for reading, I'll be posting a few more scripts I have made with PsExec  before moving to my next topic.