PowerShell to extract text from a string


I needed a quick and easy way to extract the GUID number from an event log description for a System Center Orchestrator RunBook I was creating for a customer. 

$EventID = 'The following "GUID:1234-567-890" is causing problems.  Please fix'

$Text = $EventID -split ' '

$GUID = $Text -like '"GUID:*"' -replace '"',''

It's a quick and easy way to extract the text I needed from a string and pass it along.

*note: Those are single quotes around double quotes.


Comments (0)

Skip to main content