I'm trying to determine which of my servers from a list (for example, servers.txt) have .NET 4.5 installed and what version of PowerShell. I have standalone commands which will tell me this on a single box -
**
**PS D:\tools> Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client'
Version       : 4.5.51641
CBS           : 1
TargetVersion : 4.0.0
Install       : 1
InstallPath   : C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
Servicing     : 0
Release       : 378675
PSPath        : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework
                Setup\NDP\v4\Client
PSParentPath  : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4
PSChildName   : Client
PSDrive       : HKLM
PSProvider    : Microsoft.PowerShell.Core\Registry**
** Which shows at the top (Version) that it is indeed 4.5. Is there a way to just display the Version field and the hostname (or computername) in a table format?
Also, the same for the below command which gives you your version of PowerShell -
PS D:\tools> get-host |select-object version
Version
-------
4.0
I actually did put the full path. Here is my screen after displaying the txt file and then running the command -
PS D:\tools> type h:\servers.txt
OPP-HOLD
zOPP-SQL12HAa
zOPP-SQLESMA
PS D:\tools> Get-content -path h:\servers.txt | where {$_-match "\S"} | foreach Get-ItemProperty -ComputerName $_ 'HKLM:
\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client' -name Version
foreach : Input name "Get-ItemProperty" cannot be resolved to a method.
At line:1 char:60
+ Get-content -path h:\servers.txt | where {$_-match "\S"} | foreach Get-ItemPrope ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (OPP-HOLD:PSObject) [ForEach-Object], PSArgumentException
    + FullyQualifiedErrorId : MethodNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand
foreach : Input name "Get-ItemProperty" cannot be resolved to a method.
At line:1 char:60
+ Get-content -path h:\servers.txt | where {$_-match "\S"} | foreach Get-ItemPrope ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (zOPP-SQL12HAa:PSObject) [ForEach-Object], PSArgumentException
    + FullyQualifiedErrorId : MethodNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand
foreach : Input name "Get-ItemProperty" cannot be resolved to a method.
At line:1 char:60
+ Get-content -path h:\servers.txt | where {$_-match "\S"} | foreach Get-ItemPrope ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (zOPP-SQLESMA:PSObject) [ForEach-Object], PSArgumentException
    + FullyQualifiedErrorId : MethodNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand