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

Posted on 2009-12-18
Last Modified: 2012-05-08
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?).
Question by:reason4xistence
    LVL 38

    Accepted Solution

    You can get this using the Array.IndexOf method, e.g.

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

    Open in new window


    Author Closing Comment


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
    In this previous article (, we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now