Monday, April 28, 2014

How to use Powershell to pad output using write-host

$objs = Get-WMIObject -namespace root\cimv2 -class Win32_Battery

foreach($obj in $objs)
{
    foreach($prop in $obj.Properties)
    {
         write-host $prop.Name.PadRight(30, " ") = $prop.Value
    }
}

No comments:

Post a Comment