Difference between revisions of "Power Shell"
Jump to navigation
Jump to search
(→Formatting: Added ToString) |
(→Datetime: Re-ordered sections) |
||
Line 302: | Line 302: | ||
=== Datetime === | === Datetime === | ||
The object structure: http://msdn.microsoft.com/en-us/library/system.datetime.aspx | The object structure: http://msdn.microsoft.com/en-us/library/system.datetime.aspx | ||
==== Improper (US) Formatting ==== | |||
Be aware that if you live somewhere dates are normally formatted properly (eg not the USA), then Powershell (or the underlying DateTime object type) has a nasty habit of returning a string formatted with day and month swapped around when coming from a script. | |||
If you do a <code> Get-Date </code> it all looks fine, but then you output a DateTime object in a script to some text and its wrong. Add the <code> .ToString() </code> method to the end at it'll sort itself, though quite why when Powershell is converting the object into a string anyway, the object needs to be explicitly told to fix the issue, seems a bit superfluous. | |||
==== Formatting ==== | ==== Formatting ==== | ||
Line 336: | Line 341: | ||
|} | |} | ||
For the full list of formatting options see http://technet.microsoft.com/en-us/library/ee692801.aspx | For the full list of formatting options see http://technet.microsoft.com/en-us/library/ee692801.aspx | ||
==== Converters ==== | ==== Converters ==== |