2

I have a script that returns the registry key, however the result doesn't show the computer that is returning the key.

How could I modify this code so it will list the computer and key.

$key={(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release).Release}
$computers = @(Get-Content computers.txt)
foreach ($computer in $computers){ 
Invoke-Command -computer $computer -scriptblock $key >> version.csv}
2
  • stackoverflow.com/questions/23664595/… ?? Commented Jul 24, 2015 at 22:07
  • @ErikE The solution you linked says that it requires PS v3 I am running v2. Commented Jul 24, 2015 at 22:14

1 Answer 1

2

Below should do what you need:

$key={(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release).Release}
$computers = @(Get-Content computer.txt)

foreach ($computer in $computers){    
    $result = Invoke-Command -computer $computer -scriptblock $key
    $FinalStr = "$($Computer) : $($result)"
   $FinalStr >> version.csv    
}
Sign up to request clarification or add additional context in comments.

1 Comment

That was the ticket. Thank you very much @Arcass.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.