Powershell – How to Format Output

Sometimes you don’t see the data completely.

Like this :

CLS

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

Get-SPTimerJob

image

Solutions :

Use some formatting commands.

CLS

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$list = Get-SPTimerJob 

foreach ($objItem in $list) {
#- or + is left or right alligned,
# the First Parameter 0-2 is the column index
# Second Parameter is column width
  "{0,-80} {1, 45} {2, 25}" -f `

 $objItem.name, $objItem.Schedule, $objItem.LastRunTime

}

image

Powershell has many more formatting options, have a look at the internet 😉

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: