How to query host with powershell

Hi guys,
I want to query my hosts of hyper-v cluster on what type of network adapter they have.
In local host i do this powershell command

Get-NetAdapter -Physical | ft

Open in new window


How can I do a script that query a list of hosts?

Thanks
LVL 1
chipruleAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

n2fcCommented:
Run a Remote Script
To run a script on one or many remote computers, use the FilePath parameter of the Invoke-Command cmdlet. The script must be on or accessible to your local computer. The results are returned to your local computer.

For example, the following command runs the DiskCollect.ps1 script on the Server01 and Server02 remote computers.

Invoke-Command -ComputerName Server01, Server02 -FilePath c:\Scripts\DiskCollect.ps1

Open in new window


For more information about the Invoke-Command cmdlet see:
  https://technet.microsoft.com/en-us/library/dd347578.aspx.
0
chipruleAuthor Commented:
Thanks,
but if I want to directly launch script that's returns me the result without the invoke command, how can I do?

In few words a script with embedded list of host.

Thanks
0
oBdACommented:
Try this:
$DCOM = New-CimSessionOption -Protocol DCOM
$(ForEach ($Server In (Get-Content -Path C:\Temp\servers.txt)) {
	"Processing $($Server) ..." | Write-Host -ForegroundColor White -NoNewline
	Try {
		$CimSession = New-CimSession -SessionOption $DCOM -ComputerName $Server
		Get-NetAdapter -Physical -CimSession $CimSession
		' OK' | Write-Host -ForegroundColor Green
	} Catch {
		" ERROR: $($_.Exception.Message)" | Write-Host -ForegroundColor Red
	} Finally {
		Remove-CimSession -CimSession $CimSession -ErrorAction SilentlyContinue
	}
}) | Format-Table -AutoSize

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.