Search This Blog

Saturday, November 23, 2013

Setting up a sheduled job to monitor software changes

Requirement:  To monitor software adds and deletes of software

Solution: Use a Powershell script to collect the installed software of both 32bit and 64bit applications, then take that script and schedule it to run weekly


1st the scripts to collect the software

32 bit

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-Object DisplayName, DisplayVersion, Publisher, InstallDate

64 bit

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate


Now take those scripts and create a scheduled job

32bit looks like

        $trigger = New-JobTrigger -DaysOfWeek Friday -Weekly -At 7PM

        $options = New-ScheduledJobOption -RunElevated

        $Filename32 = "32bitSoftware"

        Register-ScheduledJob -Name 32bitSoftware -ScriptBlock {
      
        Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | 
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
        Export-Csv ("c:\Jobs\"+ $Filename32 +"_"+ $((Get-Date).ToString('ddMMMyy')) +".csv") -NoTypeInformation} -Trigger $trigger -ScheduledJobOption $options

Note: for the 64 bit  replace the script block with the 64bit code, change the time, and change the filename variable

No comments:

Post a Comment