Tim Ballin
asked on
Format Powershell Script as a Table
How can I alter this script so that the output will be in table format?
$arServer = Get-Content -Path "C:\ServerList.txt"
foreach ($strServer in $arServer){
$colltems =Get-WmiObject -class Win32_OperatingSystem -computername $strServer
foreach($sProperty in $colltems)
{
Write-Host "Computer name; " $strServer
Write-Host $sProperty.Description
Write-Host $sProperty.Caption
Write-Host $sProperty.OSArchitecture
Write-Host $sProperty.ServicePackMajorVersion
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Seems like you're on the right track, but here's what I get when I try to run that:
Get-WmiObject : Invalid parameter
At line:10 char:4
+ Get-WmiObject -class Win32_OperatingSystem -computername $sProperty| format-t ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Get-WmiObject : Invalid parameter
At line:10 char:4
+ Get-WmiObject -class Win32_OperatingSystem -computername $sProperty| format-t ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Get-WmiObject : Invalid parameter
At line:10 char:4
+ Get-WmiObject -class Win32_OperatingSystem -computername $sProperty| format-t ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
ASKER
Worked perfect!
Open in new window