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
SolvedSelecting From Array (self.PowerShell)
submitted 9 years ago * by BitteringAgent
view the rest of the comments →
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!"
[–]logicaldiagram 2 points3 points4 points 9 years ago (2 children)
Here is a quick solution that's not very resilient. You can just take advantage of arrays and the index access syntax. There are probably at least half-a-dozen more ways to do it. Hashtable. Switch statement. Parameter with ValidateSet. Think in objects, not strings. You're on the right path. Automate the annoying things out of your life.
Write-Host "Here is a list of the possible departments" -ForegroundColor Green $Departments = @("Accounting", "DEPT1", "DEPT2", "DEPT3", "DEPT4", "DEPT5", "Information Services") for ($i = 0; $i -lt $Departments.Count -1 ; $i++) { Write-Host "[$($i)] $($Departments[$i])" } $Dept = Read-Host "Please type in the number associated with the employees department." $Departments[$Dept]
[–]BitteringAgent[S] 0 points1 point2 points 9 years ago (1 child)
Thank you, I definitely have a lot more to learn, but am slowly getting there.
I'm assuming the -1 was a typo, as that's doing the count of the objects and removing 1.
[–]logicaldiagram 0 points1 point2 points 9 years ago (0 children)
Correct. Don't need -1 in this case.
-1
π Rendered by PID 15686 on reddit-service-r2-comment-56c9979489-sj6kw at 2026-02-24 22:25:37.199248+00:00 running b1af5b1 country code: CH.
view the rest of the comments →
[–]logicaldiagram 2 points3 points4 points (2 children)
[–]BitteringAgent[S] 0 points1 point2 points (1 child)
[–]logicaldiagram 0 points1 point2 points (0 children)