0

I have tried to create a script for extracting but the output is not quite I desired.

$Servers = Get-ADDomainController -Filter * | Select-Object Name foreach($server in $servers) { $compsystem = gwmi -q "Select * from win32_computersystem" | Select Model write-output $Server is $compsystem" } 

The output is something like :

@{Name=ServerName} is @{Model=Proliant DL360 G6}

The servername is different but the Model is the same so i think it's in a continous loop after the first servers.

Any ideeas ?

Thank you,

1 Answer 1

0

You are never using the variable $server, so all your output is from the local machine you are running the script on. To run the command on the actual servers you can use Invoke-Command:

$servers |Foreach-Object { $compsystem = Invoke-Command -ComputerName $_.name -ScriptBlock { gwmi -q "Select * from win32_computersystem" } Write-Host ("{0} is {1}" -f $_.Name,$compsystem.Model) } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.