PowerShell: matching strings

PSRegex01

# Get the content of a file and return the content if a searched string is found, else return null.
# So if what is wanted is the boolean, just for null, else it was found.
# (This is terribly inefficient, as it grabs the content of the whole file, rather than exiting early
# if the string is found)
$result = Get-Content .\PAndP.txt | Select-String -Pattern "this will not appear" -SimpleMatch
$result -eq $null


 

PSRegex05

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s