get-wmiobject -class win32_service -namespace "root\cimv2" | format-list * enter> 查看機(jī)器信息
在網(wǎng)絡(luò)管理環(huán)境中的多數(shù)情況下,我們可能要查看不同的計算機(jī)信息,因此,就需要使用計算機(jī)這一參數(shù),例如:
$name="."
$items = get-wmiObject -class win32_NetworkAdapterConfiguration '
-namespace "root\CIMV2" -ComputerName $name | where{$_.IPEnabled -eq “True”}
foreach($obj in $items) {
Write-Host "DHCP Enabled:" $obj.DHCPEnabled
Write-Host "IP Address:" $obj.IPAddress
Write-Host "Subnet Mask:" $obj.IPSubnet
Write-Host "Gateway:" $obj.DefaultIPGateway
Write-Host "MAC Address:" $ojb.MACAddress
}
$name=read-host "Enter Computer Name"
write-host "Computer:"$name
$items = get-wmiObject -class win32_NetworkAdapterConfiguration '
-namespace "root\CIMV2" -ComputerName $name | where{$_.IPEnabled -eq “True”}
foreach($obj in $items) {
Write-Host "DHCP Enabled:" $obj.DHCPEnabled
Write-Host "IP Address:" $obj.IPAddress
Write-Host "Subnet Mask:" $obj.IPSubnet
Write-Host "Gateway:" $obj.DefaultIPGateway
Write-Host "MAC Address:" $ojb.MACAddress
}