[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 646
  • Last Modified:

How do I determine the location of an item in my powershell array?

How do I determine the location of an item in my powershell array? If I use -contains, it will give me True or False. If I use -eq, it will give me the value of the item. But I need to know the location (which number in the array (how far down the array sequence) is that item located?).
0
reason4xistence
Asked:
reason4xistence
1 Solution
 
Shift-3Commented:
You can get this using the Array.IndexOf method, e.g.


[array]::IndexOf($arrayname, "value to find")

Open in new window

0
 
reason4xistenceAuthor Commented:
Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now