Script to List Installed Programs and Windows Updates


Author
Message
RayG
RayG
Advanced Member
Advanced Member (450 reputation)Advanced Member (450 reputation)Advanced Member (450 reputation)Advanced Member (450 reputation)Advanced Member (450 reputation)Advanced Member (450 reputation)Advanced Member (450 reputation)Advanced Member (450 reputation)Advanced Member (450 reputation)
Group: Forum Members
Posts: 222, Visits: 960
The file is uploaded as a .TXT file so it cannot be executed acidentally before anyone who wishes to use it has had a chance to view the file to see it does not do anything untoward.

I have also included some example output files. The ones that have a name of *.csv.txt should be renamed to *.csv if you want to load them into a spreadsheet which is probably the default for *.csv files if you have one on your system.

The GetInstallProgramsList.txt file should be renamed to GetInstallProgramsList.ps1 in a (new?) directory where you are happy for the output to be created. It can be run as a non administrator to see the Windows Updates but everything else unfortunatly requires Administrator privileges, the script will produce a UAC prompt (If you are not already an administrator) and elevate itself to produce the output.

You will also need to "unblock" the file, right click on the file, select properties and at the bottom check the "unblock" checkbox. This is a security precaution introduced by windows to stop inadvertent execution of files downloaded from the internet.

This next action may be required to enable scripts to run. If you see the following output:
PS C:\> <path>\GetInstalledProgramList.ps1
<path>\GetInstalledProgramList.ps1 : File
<path>\GetInstalledProgramList.ps1 cannot be loaded because running scripts is disabled on
this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ <path>\GetInstalledProgramList.ps1 -Windo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo    : SecurityError: (:) [], PSSecurityException
  + FullyQualifiedErrorId : UnauthorizedAccess

You will need to look at the execution policy settings on your system open a powershell window and type Get-ExecutionPolicy -list:
PS C:\> Get-ExecutionPolicy -list

   Scope ExecutionPolicy
   ----- ---------------
MachinePolicy   Undefined
   UserPolicy   Undefined
      Process   Undefined
   CurrentUser  Undefined
 LocalMachine   Undefined

If it looks like the above output, I recommend that if you are an administrator you do not do the next step UNLESS you know what you are doing, but create a new user WITHOUT administrator privileges then type the following command:
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
PS C:\> Get-ExecutionPolicy -List

       Scope ExecutionPolicy
       ----- ---------------
 MachinePolicy      Undefined
    UserPolicy      Undefined
       Process      Undefined
   CurrentUser   RemoteSigned
  LocalMachine      Undefined
PS C:\>


After making the above change the script (and any other script) will be able to run.

The simplest of command lines is:
<path>\GetInstalledProgramList.ps1

The script will prompt for every option I suggest just taking the Windows Updates option with no TXT or CSV output, results will be to the console

The most output will be obtained with the following command line:
<path>\GetInstalledProgramList.ps1 -RunAsAdmin -InstalledPrograms -Installe
dStorePrograms -WindowsUpdates -Console -Csv -Txt

Leave out the options you don't want or require there must be at least one output option for the script to run either:
-Console, -Csv or -Txt

If none are given the script will prompt:
<path>\GetInstalledProgramList.ps1 -WindowsUpdates
Do you want a .txt file created? [Y/N]: n
Do you want a .csv file created? [Y/N]: n

The replies of "n" (as above) will result in output to the console.

Edit: 18th Dec 2017.
I have changed the script quite a bit, it still does the same job but the output file names have changed to enable some extra facilties.
1). There is now an HTML output
2). It creates dated files so you can keep as many as you want - there is a "tidy" option to remove files older than 'n' days
3). It will track the differences between runs so you can see what has changed.

I use this as the scheduled options to powershell run as administrator:
-executionpolicy bypass -noprofile "<path>\GetInstalledProgramList.ps1" -WindowsUpdates -InstalledPrograms -InstalledStorePrograms -Html -Txt -Difference -Tidy 30 -Log




Regards
RayG
Windows10 X64 V1709 B16299.192 MR v7.1.2833

Attachments
Edited 18 December 2017 2:32 PM by RayG
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search