Hi, Could you anyone help me out how to find PSremote enabled or not and .NET version on multiple computers using a single powershell script and export them into a csv.
Thanks in advance.
Hi, Could you anyone help me out how to find PSremote enabled or not and .NET version on multiple computers using a single powershell script and export them into a csv.
Thanks in advance.
Hi Jeevan,
Did you try anything? Please put down anything you have tried so far, then we can assist you further towards your requirements.
Thank you.
Hi Kiran,
Below is the one that i tried to get .NET version. I am finding it little difficult to get the other half of my requirement into my script.
Get-Content -Path “c:\temp\servers.csv” | ConvertFrom-Csv | ForEach-Object -Process { Invoke-Command -ComputerName $_.Name -ScriptBlock { Get-ChildItem ‘HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP’ }
}
Look into Test-WSMan
Hi Jeevan,
Try this one…
$ScriptBlock = [scriptblock]::Create({
$RegistryPath = 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
$Release = Get-ItemProperty -Path $RegistryPath -ErrorAction SilentlyContinue | ForEach-Object Release
[PSCustomObject]@{
DotNetVersion = $(
switch ($release) {
({ $_ -ge 528040 }) { '4.8'; break }
({ $_ -ge 461808 }) { '4.7.2'; break }
({ $_ -ge 461308 }) { '4.7.1'; break }
({ $_ -ge 460798 }) { '4.7'; break }
({ $_ -ge 394802 }) { '4.6.2'; break }
({ $_ -ge 394254 }) { '4.6.1'; break }
({ $_ -ge 393295 }) { '4.6'; break }
({ $_ -ge 379893 }) { '4.5.2'; break }
({ $_ -ge 378675 }) { '4.5.1'; break }
({ $_ -ge 378389 }) { '4.5'; break }
default { '.Net installed/updated' }
}
)
IsRemotingEnabled = -not [string]::IsNullOrEmpty((Test-WsMan))
}
})
$Servers = Get–Content –Path 'c:\temp\servers.csv' | ConvertFrom–Csv | ForEach-Object Name
Invoke-Command -ComputerName $Servers -ScriptBlock $ScriptBlock | Select-Object -Property DotNetVersion, IsRemotingEnabled, PSComputerName
Thank you.
Hi Kiran, I got the below error.
Get–Content : The term ‘Get–Content’ 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 again.
At line:24 char:12
$Servers = Get–Content –Path ‘c:\temp\servers.csv’ | ConvertFrom–Csv | ForEach-O …
CategoryInfo : ObjectNotFound: (Get–Content:String) , CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
Invoke-Command : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:25 char:30
Invoke-Command -ComputerName $Servers -ScriptBlock $ScriptBlock | Select-Object …
CategoryInfo : InvalidData: (
[Invoke-Command], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand
Microsoft.PowerShell.Management\Get-ContentThank you.
Thank you…! It works fine now.