Posted in
Windows Powershell,
Windows Server |
1 Comment | 3,594 views | 18/06/2013 13:39
This is an example to show you how to get hardware information of AD clients via PowerShell.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| $Servers = Get-ADComputer -Filter {Name -like "C*"}
Foreach ($Server in $Servers)
{
$Hostname = $Server.Name
$ServerInfo = (Get-WmiObject -Computername $Hostname Win32_ComputerSystem)
$Manufacturer = $ServerInfo.Manufacturer
$Model = $ServerInfo.Model
Write-Host "Name: $Hostname"
Write-Host "Manufacturer: $Manufacturer"
Write-Host "Model: $Model"
Write-Host " "
$Content = "$Hostname;$Manufacturer;$Model"
Add-Content -Value $Content -Path "C:\ServerInfo.txt"
} |
$Servers = Get-ADComputer -Filter {Name -like "C*"}
Foreach ($Server in $Servers)
{
$Hostname = $Server.Name
$ServerInfo = (Get-WmiObject -Computername $Hostname Win32_ComputerSystem)
$Manufacturer = $ServerInfo.Manufacturer
$Model = $ServerInfo.Model
Write-Host "Name: $Hostname"
Write-Host "Manufacturer: $Manufacturer"
Write-Host "Model: $Model"
Write-Host " "
$Content = "$Hostname;$Manufacturer;$Model"
Add-Content -Value $Content -Path "C:\ServerInfo.txt"
}
I’ve used filter to get specific computers.