Posted by: Preetam | January 17, 2007

Computer Inventry with Powershell

I’m planning to put here series of code to get the computer inventory of machines. As you could remember last time I got the IP Address of the machine. This time I wanna know how many and what programs are installed on this machine.

$ALLPROGS=Get-ChildItem “hklm:\software\microsoft\windows\currentversion\uninstall” ForEach-Object {Get-ItemProperty $_.pspath}
if ($args -eq “sort” )

$ALLPROGS Select-Object displayname,publisher sort publisher



$ALLPROGS Select-Object displayname,publisher group publisher sort count


I’ve purposely left this code hanging whether you wish to have group programs or sort by name of the application publisher. Program is simple but fact that I would like to mentioned here, I tried the other way round, which I’ve pasted just for the sake of not to do do this.

USAGE: .\AllPrograms02.ps1 sort or .\AllPrograms02.ps1

$CHILDPROG=get-childitem $ALLPROG
$PROGNAME=$CHILDPROG select-object pschildname
for($i=0;$i -lt $PROGNAME.length; $i++) {
$PROGS get-itemproperty select-object displayname,publisher sort displayname

Even though I have mentioned sort by displayname it won’t work, sorting fails here because it has to be with POST here…, just though of keeping it in my mind. Please bear in mind this is not going to work on remote computer, But for me it doesn’t matter. Because I’m going to run this everytime I built the server or someone asks me or Best one is to do by using psexec..hahaha. But certainly in future there is would be simpler way to run this across enterprise.

Technorati tags: tags:

IceRocket tags:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: