Create a Software Inventory Reports using PowerShell.

Note: Please Treat this script as education purpose, dont run it on your production environmnet. this script is using Win32_product WMI class and that calls MSI to get the list of the software and sometime MSI starting recofiguring softwares Please see this link http://support.microsoft.com/kb/974524

If you are it administrator , and supporting and helping users in your environment, and you dint have any software inventory tools because they are too costly and you want to know what software are installed on users machines that is  a big problem.

Sometime users installed alots of shitty softwares form internet and after installing those they are start complaining about my this my that stop working. i face this situation few times in a month to solve it i generated this script. this script reside on every users laptop {copied my login scripts} , and i asked user to run it and send em the output.

this script create a html file in executers c:\users\username folder.

You will get list of all software installed on users machine in to a nice HTML file , and this list are sorted my Install date of the software, so latest installed software will on the top.

Script:

#variables  
    $vUserName = (Get-Item env:\username).Value 
    $vComputerName = (Get-Item env:\Computername).Value 
    $filepath = (Get-ChildItem env:\userprofile).value 
    $name = (Get-Item env:\Computername).Value  
## Html Style 
    $a = "<!--mce:0-->" 
# removing old HTML Report if exists 
    if (test-Path $filepath\$name.html) { remove-Item $filepath\$name.html; 
    Write-Host -ForegroundColor white -BackgroundColor Red    "Old file removed" 
    } 
# Running Command  
    ConvertTo-Html -Title "Software Information for $name" -Body "<h1> Computer Name : $name </h1>" >  "$filepath\$name.html" 
    Get-WmiObject win32_Product -ComputerName $name | Select Name,Version,PackageName,Installdate,Vendor | Sort Installdate -Descending ` 
                                             | ConvertTo-html  -Head $a -Body "<H2> Software Installed</H2>" >> "$filepath\$name.html"                              
    $Report = "The Report is generated On  $(get-date) by $((Get-Item env:\username).Value) on computer $((Get-Item env:\Computername).Value)" 
    $Report  >> "$filepath\$name.html"  
## Opening file and the file  
    write-Host "file is saved in $filepath and the name of file is $name.html" -ForegroundColor Cyan 
    invoke-Expression "$filepath\$name.html"  
## END of the SCRIPT ## 

Be the first to comment

Leave a Reply

Your email address will not be published.


*