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,
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 useInvoke-Command
: