PowerShell

Check Version of PowerShell (localhost and remote hosts)

In this blog post I show how to find out the Version of PowerShell on the localhost and on remote computers.

The release number of the PowerShell version can be found in many ways: Registry, Skripts … and of course in PowerShell itself.

Checking version of PowerShell (localhost)

Open Windows PowerShell with administrative privileges. Run Get-Host with Select-Object.

Get-Host | Select-Object Version

Unbenannt.PNG

Simplified:


(Get-Host).Version

Unbenannt.PNG

More simplified:


$host.version

Unbenannt.PNG


$PSVersionTable.PSVersion

Unbenannt.PNG

User-friendly:


$host.version | Out-GridView

Unbenannt.PNG

User-friendly 2:


Write-Host (get-host).Version.Major (Get-Host).Version.Minor -Separator .

Unbenannt.PNG

Choose your favourite!

How to get PowerShell Version on Remote Hosts (Domain Environment)

Single Computer


Invoke-Command -Computername client001 -Scriptblock {$PSVersionTable.psversion}

Unbenannt.PNG

Client001 is running 5.1.

Multiple Computers

First, get a list of computer names by running Get-ADComputer. Then use that list to get the powershell version of all computers.


$adcomputer=(Get-ADComputer -Filter *).Name

Invoke-Command -ComputerName $adcomputer -Scriptblock {$PSVersionTable.psversion} -ErrorAction SilentlyContinue

Unbenannt.PNG

Cool. That looks good. All computers are up-to-date.

Non-Domain Computers

If the computers do not share the same domain, then you have to configure them as Trusted Hosts. For more information see my article PowerShell Remoting: How to connect to Remote Hosts in a Domain- and in a Non-Domain Environment (Trusted Hosts).

 

6 replies »

  1. Getting the following error.

    Get-ADComputer : The term ‘Get-ADComputer’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try

    Can I pipe it to get a csv file or a text file?

    Like

  2. I don’t want to see the version of all domain computers, but only selective computers. How can I provide the list of target remote computers…

    Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.