简体   繁体   中英

How to convert "PT5H" to ticks using powershell?

I'm trying to convert "PT5H" to ticks format using powershell. But facing below error:

System.Management.Automation.ParameterBindingArgumentTransformationException: Cannot process argument transformation on parameter 'SuppressionDuration'. Cannot convert value "PT5H" to type "System.TimeSpan". Error: "String was not recognized as a valid TimeSpan."

Can anyone help me out in converting "PT5H"(String) to ticks?

You can use the XmlConvert.ToTimeSpan() method to parse ISO8601 duration strings:

$duration = [System.Xml.XmlConvert]::ToTimeSpan('PT5H')
Command-Name -SuppressionDuration $duration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM