I am currently reading the contents of a file and returning a pattern which gets one line. I am able to get the correct line by itself now. How do I do a substring function on the $RunTimeLine result to return the first four characters?
[string] $RunTimeLine = Select-String -Path $IDCSwiftFlowXMLFile -pattern "<time>" | ForEach-Object {$_.Line}
OUTPUT of $RunTimeLine >>>>>>> 30 5 * * 2-6 2
I have attempted doing the following but it isn’t returning anything
$StartTime = $RunTimeLine.substring(0,4)
Any help is greatly appreciated. Thanks.
The String.Substring method should work IF you have a string. If you execute:
it doesn’t return anything because the result is assigned to $StartTime. What does this output:
If nothing then try
$StartTime -eq $null. Is it possible the first four chars are whitespace so that it appears there is no output. You could check that with$StartTime.Length.