external help file | Module Name | online version | schema |
---|---|---|---|
PSScriptTools-help.xml |
PSScriptTools |
2.0.0 |
Convert a lexical timespan into a PowerShell timespan.
ConvertFrom-LexicalTimespan [-String] <String> [-AsString] [<CommonParameters>]
When working with some XML data, such as that from scheduled tasks, timespans or durations are stored in a lexical format like P0DT0H0M47S. You can use this command to convert that value into a timespan object.
PS C:\> ConvertFrom-LexicalTimespan P0DT0H0M47S
Days : 0
Hours : 0
Minutes : 0
Seconds : 47
Milliseconds : 0
Ticks : 470000000
TotalDays : 0.000543981481481481
TotalHours : 0.0130555555555556
TotalMinutes : 0.783333333333333
TotalSeconds : 47
TotalMilliseconds : 47000
PS C:\> Get-ScheduledTask -TaskName DailyWatcher |
Select-Object Taskname,
@{Name="ExecutionLimit";Expression = `
{ ConvertFrom-LexicalTimespan $_.settings.ExecutionTimeLimit }}
Taskname ExecutionLimit
-------- --------------
DailyWatcher 3.00:00:00
Format the timespan as a string
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Enter a lexical time string like P23DT3H43M. This is case-sensitive.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/