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
Simplified:
(Get-Host).Version
More simplified:
$host.version
$PSVersionTable.PSVersion
User-friendly:
$host.version | Out-GridView
User-friendly 2:
Write-Host (get-host).Version.Major (Get-Host).Version.Minor -Separator .
Choose your favourite!
How to get PowerShell Version on Remote Hosts (Domain Environment)
Single Computer
Invoke-Command -Computername client001 -Scriptblock {$PSVersionTable.psversion}
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
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).
Categories: PowerShell, Windows 10, Windows Server
Hi, depends on the remote connection.
LikeLike
Will the commands above list ALL Versions of Powershell and not just the latest version installed?
LikeLike
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?
LikeLike
The error says no cmdlet found. What have you tried so far?
LikeLike
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…
LikeLike
You can use Invoke-Command to run commands remotely
LikeLike