This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
2
Simplify script flow
Post Body
Hi r/powershell,
I would like to know if there is a more elegant way to do this:
$group_valid
contains one ore more strings$Identity.Groups
contains one or more strings- the script should only run if one or more strings from $Identity.Groups are valid
Like this:
$group_valid = Get-Content -path "$PSScriptRoot\group_valid.txt"
$access = $false
foreach ($group in $group_valid) {
if ($Identity.Groups -contains $group) {
$access = $true
break
}
}
if(-not $access) {
exit
}
# Do stuff
If $group_valid would only contain a sinlge string, this would work:
$group_valid = Get-Content -path "$PSScriptRoot\group_valid.txt"
if ($Identity.Groups -notcontains $group_valid) {
exit
}
# Do stuff
Which is so much less 'overhead' and slick. Which options do I have?
Author
Account Strength
90%
Account Age
15 years
Verified Email
Yes
Verified Flair
No
Total Karma
4,545
Link Karma
3,347
Comment Karma
1,198
Profile updated: 2 days ago
Posts updated: 10 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 7 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...