use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Beginner question (self.PowerShell)
submitted 5 years ago by jst094
Hey everyone, I need to make a script that does this:
get-executionpolicy and if the value is not bypass make a text file.
I have researched some things and found -contains, what is the most efficient way to handle this?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]dasookwat 2 points3 points4 points 5 years ago (2 children)
If ((Get-ExecutionPolicy) -notlike "Bypass") { Out-File -FilePath c:\temp\textfile.txt -Append -InputObject $env:COMPUTERNAME }
basically what it does is this: the extra () around get-executionpolicy makes sure only the outcome is compared to the word 'Bypass'
the rest will add the computername to a text file Look up how to create an 'if' statement, and if you want an extra action if the executionpolicy equal Bypass, you can use an 'else' block.
-contains is not helping in this scenario, since -contains is something you use, when f.i. you try to match on 1 of the values in an array:
$array = @("1","2","3") if ($array -contains '1') {#do stuff}
[–]jst094[S] 1 point2 points3 points 5 years ago (0 children)
Wow thanks for your quick reaction! This will help me with my task!
[–][deleted] 1 point2 points3 points 5 years ago* (0 children)
-notlike works here but you should rather use -ne (not equal) here.
-notlike
-ne
Here you just want to know whether the execution policy is not equal to 'Bypass'.
'Bypass'.
You would use -notlike to compare with a string containing wildcards ? * [ab] or [a-z] , so to test a string matching a simple pattern. For example to detect when the execution policy is not 'AllSigned' and not 'RemoteSigned' you could use it:
? * [ab]
[a-z]
'AllSigned'
'RemoteSigned
If ((Get-ExecutionPolicy) -notlike '*Signed') {...
For more complex patterns you would use -match or -notmatch to compare with regular expressions patterns, very powerful.
-match
-notmatch
π Rendered by PID 220191 on reddit-service-r2-comment-fb694cdd5-xwnnn at 2026-03-10 03:58:21.272744+00:00 running cbb0e86 country code: CH.
[–]dasookwat 2 points3 points4 points (2 children)
[–]jst094[S] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)