Answered by:
Script to extract details from Windows Remote Computer

Question
-
Hello Team,
Looking for help ... Need a powershell script to perform the below tasks on remote Windows computers:
1> Check and provide the list of the systems which are enabled with Hyper-V
2> Servers in which Hyper-V enabled extract the list of VM's hosted on them.
Thanks,
Samojit
Monday, February 24, 2020 3:21 PM
Answers
-
Try this:
$Servers = @( 'Server1', 'Server2' ) $Hosts = Invoke-Command -ComputerName $Servers -ScriptBlock { $HyperV = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online If ($HyperV.State -eq 'Enabled') { return $env:COMPUTERNAME } } $Hosts.foreach{Get-VM -ComputerName $_}
MicaH
itmicah.wordpress.com- Edited by MicaH_Z Tuesday, February 25, 2020 7:32 AM
- Marked as answer by Samojit Das Tuesday, February 25, 2020 8:02 AM
Monday, February 24, 2020 4:04 PM
All replies
-
Try this:
$Servers = @( 'Server1', 'Server2' ) $Hosts = Invoke-Command -ComputerName $Servers -ScriptBlock { $HyperV = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online If ($HyperV.State -eq 'Enabled') { return $env:COMPUTERNAME } } $Hosts.foreach{Get-VM -ComputerName $_}
MicaH
itmicah.wordpress.com- Edited by MicaH_Z Tuesday, February 25, 2020 7:32 AM
- Marked as answer by Samojit Das Tuesday, February 25, 2020 8:02 AM
Monday, February 24, 2020 4:04 PM -
Try this:
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Monday, February 24, 2020 6:22 PM -
Tuesday, February 25, 2020 7:35 AM
-
... and quite often you don't even get a reply or a "thank you" or a confirmation that it works from this kind of asker. :-/
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Tuesday, February 25, 2020 7:42 AM -
Dude why dont you concentrate on your own business rather than poking your nose in other people stuff ... its will be helpful for you to learn some manners or etiquettesTuesday, February 25, 2020 8:05 AM
-
Thanks MicaH_Z for your great help !!Tuesday, February 25, 2020 8:05 AM
-
Dude why dont you concentrate on your own business rather than poking your nose in other people stuff ... its will be helpful for you to learn some manners or etiquettes
Funny that you mention " manners or etiquettes". ;-)Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Tuesday, February 25, 2020 9:07 AM -
hope you will start following or at least learn it ;-)Tuesday, February 25, 2020 10:53 AM
-
Please carefully review the following links to set your expectation for posting in technical forums.
- This Forum is for Scripting Questions Rather than script requests
- How to ask questions in a technical forum
- How to post code in Technet Forums
\_(ツ)_/
Tuesday, February 25, 2020 10:56 AM