How to extract text from field?

Welcome Forums General PowerShell Q&A How to extract text from field?

Viewing 1 reply thread
  • Author
    Posts
    • #243953
      Participant
      Topics: 1
      Replies: 0
      Points: -9
      Rank: Member

      I need to extract the resource group name (in blue) from this field to use in a variable. What is the easiest way to do this? The subscription number might change but will always be the same length.

      Id : /subscriptions/f63f7a9e-2700-4c86-af00-67e86abb0000/resourcegroups/RG-025-311-WVD/providers/Microsoft.DesktopVirtualization/hostpools/025-113-Pool-P

    • #243959
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      If it’s always going to be that path, you could do it in a couple of ways. First, you can split at the slash and grab the appropriate element.

      Output:

      Perhaps an easier to modify approach would be using regex. If the path changes just modify it.

      Output:

      I hope this helps.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.