Reputation: 25
I need to create custom columns to the output of my script in powershell.
dc55 (UTC-04:00) Santiago 4/26/2017 11:34:42 AM
DC10 (UTC-04:00) Santiago 4/26/2017 11:34:43 AM
DC11 (UTC-04:00) Santiago 4/26/2017 11:34:44 AM
DHCP10 (UTC-04:00) Santiago 4/26/2017 11:34:44 AM
DHCP11 (UTC-04:00) Santiago 4/26/2017 11:34:45 AM
so for example i need to format the output in this way
Server TimeZone Date and Time
----- -------- --------------
dc55 (UTC-04:00) Santiago 4/26/2017 11:34:42 AM
DC10 (UTC-04:00) Santiago 4/26/2017 11:34:43 AM
DC11 (UTC-04:00) Santiago 4/26/2017 11:34:44 AM
DHCP10 (UTC-04:00) Santiago 4/26/2017 11:34:44 AM
DHCP11 (UTC-04:00) Santiago 4/26/2017 11:34:45 AM
this is the line of output in my script:
Write-Host "$Server $TimeZone $date_time"
Upvotes: 0
Views: 2573
Reputation: 25
Thanks guys i followed your advice and i was able to give format to my output
+10 for you guys!
Upvotes: 1
Reputation: 17472
or like this :
[pscustomobject]@{Server= $Server;Timezone= $TimeZone;DateTime= $DateTime}
Upvotes: 2
Reputation: 1208
I usually do something like this:
New-Object -TypeName PSCustomObject -Property @{
Server= $Server
Timezone= $TimeZone
DateTime= $DateTime}
You can then show that on screen or export to CSV or whatever works for you.
Upvotes: 2