0

I am building a script to automate computer build and configuration: The idea is that from WDS it comes as clean as possible, automatically runs this script which will check the serial number, query our Workday database of assets and configure the OS according to what the user assigned to that system needs.

Right now I am focusing on 3 big groups: Laptop, Desktop, and Lab. All 3 will have some SW that will be the same and some that will be specific for each. My issue is with msiexec: Initially, I hard-coded all the installations for each group. but this means that I will have to change the script each time something is updated (say a new app is rolled out as default). which is not ideal.

    function Install-Desktop {
    #Write-Output "Here will be the install Desktop computer script"
    $IPATH="<Path To root sw folder>"
    #Software List
    <#          SOFTWARE LIST           #>
    $office="$IPATH\script\o365"
    $webex="$IPATH\script\webex"
    $chrome="$IPATH\script\chrome"
    #install Ofice:
    Invoke-Expression "$office\setup.exe /configure $office\O365.xml"
    $params = '/i', "$webex\webexapp.msi",'/qb!','/norestart'
    Start-Process msiexec -ArgumentList "$params"  -Wait -PassThru
    $params = '/i', "$chrome\GoogleChromeStandaloneEnterprise64.msi",'/qb!','/norestart'
    Start-Process msiexec -ArgumentList $params  -Wait -PassThru
    }

This piece of code works well.

Now my idea was to import from a list the software to be installed (it is easier to maintain a list than to modify the script every time). something like:

function install-software {
    param (
        [String]$Type
    )
    $IPATH=<ROOT SW Folder>
    $SoftWares=Import-Csv -Path "$IPath\script\$Type`.csv" #there will be a Laptop.csv in that path
    foreach ($Software in $SoftWares) {
        #detect if it is msiexect or other:
        # (this has to do with how the csv is built, the first parameter is '/i' if it is an msi installer)
        if ($Software.param1 -eq "'/i'") {
            Start-Process msiexec -ArgumentList $Software  -Wait -PassThru
        }
        else {
            $Params=[string]::Join(" ",$Software.param1,$Software.param2,$Software.param3,$Software.param4)
            Invoke-Expression "$Params" 
        }
    }
}

This only works on the else part. However on the msiexec side of the if, the MSI opens as without arguments. I tried a lot of ways to pass the args, none worked. I am not a PowerShell guru in any way, so there is probably something that I am missing to see here.

2
  • Not terribly familiar with deploying MSI's through PS, but my guess is that since you're passing $params as an array, the MSI call is not seeing all of them. Is there any difference if you make $params a single string like $params = "/i $webex\webexapp.msi /qb! /norestart" ? Also, have you tried stepping through the code at the foreach` to look at the value of $Software and $Softwares? Commented Jun 21, 2019 at 19:29
  • Yes I have. -ArgumentList needs to be passed as array (I have tried passing them as a single string and fails) or a single string (but with just 1 argument), that would make it non silent. the array $software has the values it has to have (I tested it writing the variable, instead of doing anything) Commented Jun 21, 2019 at 19:57

1 Answer 1

1

Well, it looks like you have to pass the full path, it doesn't even let you use mounted net drive: so the answer was on the csv. instead of S:\<path to installer> it had to be \<Full path to installer> and i had to get rid of all the quotes and double quotes as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.