PowerShell version on remote computers must be installed
with the latest version if possible. It would make life easier.
New version comes with of course, new features and more fun. And if all servers or PCs has the same PowerShell version, then you need to create one version of PowerShell that works for all computers or servers.
But how to get PS version on remote computers?
To get the version locally, it’s quite straight forward:
Method 1:
($Psversiontable).PSVersion
Method 2:
(get-host).Version
To get version on remote computers, just add a few lines from the command above.
#--------- save as Get_PS_Version.ps1 or any file name
$xversion = (get-host).Version
$xversion_output = "PowerShell
Version: " + $xversion
$pc_name = $env:computername
$pc_output = "Computer Name: " + $pc_name
$xversion_output + "`n" >> c:\scripts\output\$pc_name.txt
$pc_output >> c:\scripts\output\$pc_name.txt
#--------------------------------
Assuming the file is on c:\scripts and has a sub folder
called output.
Change the location and sub folder name as necessary.
Change the location and sub folder name as necessary.
Run this code to get PS version on remote PCs:
Invoke-Command -FilePath c:\script\Get_Ps_Version.ps1 -ComputerName server1, server2, server3, server4,
server5
You can run the above command right at your workstation, of
course, you need to open PowerShell ISE or PowerShell command line with the right
credentials.
Or if you maintain a list of your servers which is not a bad idea, then you can use this method:
Invoke-command -computer (get-content c:\script\server_list\servers_list.txt) -filepath c:\script\Get_Ps_Version.ps1
If need to get one server or computer try this:
Invoke-Command -ComputerName Server01 -Credential Domain01\User01 -ScriptBlock { (get-host).Version }
Cheers..till next time. :)
================================
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
Heaven's Dew Fall Prayer app for Android :
Catholic Rosary Guide for Android:
Comments
Post a Comment