Jump to content
DarrenWhite99

Expose PowerShell Version as an installed software application

Recommended Posts

The following one liner can be put into a computer startup script, into a Remote Monitor, etc. to add PowerShell as if it was an installed application. The Version Number will be set as well. With this you can search for all systems with PowerShell Version >=X, it can be included in reports, etc. This is an alternative (or complement) to the PowerShell Roles that I published here https://www.labtechgeek.com/files/file/13-powershell-version-roles/.

The command line is: 

"%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe" -nologo -noprofile -Command "$Path='Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft PowerShell';$Null=New-Item -Path $Path -Force -EA 0;(@{v='InstallLocation';t='String';d='%WINDIR%\system32\WindowsPowerShell\v1.0\'},@{v='NoModify';t='DWord';d='1'},@{v='NoRepair';t='DWord';d='1'},@{v='SystemComponent';t='DWord';d='0'},@{v='NoRemove';t='DWord';d='1'},@{v='DisplayName';t='String';d='Microsoft Powershell'},@{v='Publisher';t='String';d='Microsoft PowerShell'},@{v='Comments';t='String';d='This application was added to identify the version of PowerShell installed on this computer.'},@{v='DisplayVersion';t='String';d=$(IF (($PSVersionTable)) {$PSVersionTable.PSVersion} else {'1.0'})})|foreach-object {$null=New-ItemProperty -Path $Path -Name $($_.v) -PropertyType $($_.t) -Value $($_.d) -Force -EA 0}"

I have this as a remote monitor on my "Service Plans" group, limited to a search for computers with PowerShell Installed. (The search is just for all agents with the "PowerShell Installed" role from the role pack mentioned above.) Once the monitor runs and agents refresh their software inventory, PowerShell will be reported like this.

Dataview-Software-PowerShellVersions.jpg

powershell show display report installed software application add/remove program programs version

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

We use the following to do something similar but for Chocolatey
 

"%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe" -nologo -noprofile -Command "$Path='Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Chocolatey'; $null=New-Item -Path $Path -Force -EA 0; (@{v='InstallLocation'; t='String'; d=$env:ChocolateyInstall},@{v='NoModify'; t='DWord'; d='1'},@{v='NoRepair'; t='DWord'; d='1'},@{v='SystemComponent'; t='DWord'; d='0'},@{v='NoRemove'; t='DWord'; d='1'},@{v='DisplayName'; t='String'; d='Chocolatey'},@{v='Publisher'; t='String'; d='Chocolatey'}, @{v='Comments'; t='String'; d='Like apt-get, but for Windows.'},@{v='DisplayVersion';t='String';d=choco --version}) | foreach-object {$null=New-ItemProperty -Path $Path -Name $($_.v) -PropertyType $($_.t) -Value $($_.d) -Force -EA 0}"

 

Edited by Thinkit-Wesley
* full credit to Darren of course :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...