Selecting from text with select-string

YaroC 311 Reputation points
2022-05-10T10:03:11.043+00:00

I'm trying to find all occurrences of following pattern [int]$license in a script located on multiple machines. When I run $test | select-string -pattern '/[int/]' where $test holds the content of the file, this works as long as I won't add the dollar sign afterwards. I tried '/[int/]/$license' and '/[int/]`$license' but neither works which proves my regex is useless :) Can someone help with this?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
0 comments No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. Michael Taylor 48,046 Reputation points
    2022-05-10T15:07:07.573+00:00

    Try this $test | select-string -pattern '\[int\]\$license'

    0 comments No comments

  2. YaroC 311 Reputation points
    2022-05-16T09:48:31.957+00:00

    Indeed. Silly as it is it was the wrong character I was trying to use.

    0 comments No comments