Guid Regex powershell script

ZM 211 Reputation points
2022-04-12T13:03:49.617+00:00

Hi i need some help on a script, I want to create a single powershell file that, does a guid check then add it to one of the task groups in my pipeline

the Guid Regex I want to use:

^[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}$

how will the script end up, using functions param etc

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2022-04-12T15:22:33.473+00:00

    Hi @SakeriyeMohamud-4520 ,

    maybe this helps to get started:

    $guid = [guid]::NewGuid()
    if ($guid -match("^[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}$")) {
      Write-Output "Guid is valid .... do something"
    }
    else {
      Write-Output "Guid is not valid! .... do something else"
    }
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.
    0 comments No comments

  2. Michael Taylor 60,161 Reputation points
    2022-04-12T15:32:36.37+00:00

    You already posted this question here. Please don't create new questions if you already have an existing one unless you are changing the question and/or consider linking to the original so others don't waste time recommending things that have already been recommended.

    1 person found this answer helpful.
    0 comments No comments

  3. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2022-04-12T17:17:40.267+00:00

    Hi @Michael Taylor ,

    sorry, I didn't noticed the same question was posted with a different tag before.
    I will close this thread than.

    Her we go to the earlier question: https://learn.microsoft.com/en-us/answers/questions/805910/validate-regex-pattern-as-the-pipeline-starts.html

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.