find an exe in a folder

Posted on 2012-09-13
Last Modified: 2012-09-13

How find an exe file into a directory to run in order not to have his name in a script :
Exmaple: I want to detect SQLServer2008R2SP2-KB2630458-x64-ENU.exe
$command = "$patchdir\SQLServer2008R2SP2-KB2630458-x64-ENU.exe /q /Action=Patch /InstanceName=`"$I`" /IAcceptSQLServerLicenseTerms"


Question by:bibi92
    LVL 67

    Accepted Solution

    If you are certain there is only a single EXE file in the location of the $pathdir:
    $exe = (gci $patchDir\SQLServer*.exe).FullName
    $command = "$exe /q /Action=Patch /InstanceName=`"$I`" /IAcceptSQLServerLicenseTerms"

    Open in new window


    Author Closing Comment

    Thanks bibi

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Why Use PowerShell? Recently, I was asked to come up with a quick way to find out what versions all of our SQL servers were currently running. Well, we have several thousand so taking a manual approach simply wasn't an option. We also didn't have t…
    A commonly asked question on the site recently has been regarding how do I share the GAL between different forests? I want a list of Contacts representing all the users in a remote domain, How do i get them? It's a problem I was posed with a litt…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now