Ying Li at myITforum.com

PowerShell & System Center

PowerShell script to get Computers Chassis Types

Here is a PowerShell script to get Computers Chassis Types:

$erroractionpreference = "SilentlyContinue"
$a = get-content "C:\temp\PClist.txt"
foreach ($i in $a)
{$b = get-wmiobject win32_SystemEnclosure -computername $i
foreach ($j in $b)
{write-host "$i Chassistype is:" $j.chassistypes}
}

Posted: Dec 19 2006, 12:05 PM by yli628 | with 1 comment(s) |
Filed under:

Comments

jsnover said:

Did you realize that you could do this as a one-liner?

Get-WmiObject Win32_systemEnclosure -ErrorAction SilentlyContinue -computerName (get-Content c:\temp\pclist.txt) | foreach {Write-Host "$i Chassistype is:" $_.Chassistypes}

Jeffrey Snover [MSFT]

Windows PowerShell/MMC Architect

Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell

Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

# December 19, 2006 10:45 PM