new to powershell - create install script

Welcome Forums General PowerShell Q&A new to powershell - create install script

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 7 months ago.

  • Author
  • #54266

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    Hey Guys,

    I don't use powershell much and i am trying to get more familiar with it. I am currently working on a script that needs to install a an agent that communicates to an internal URL. I am trying to make it a silent install and only want the user to see the start and end of the installation. I've tried the below variations and they don't seem to work. Anyone have any simple script they use to do installs or tell me what i am doing wrong on the below syntax?

    start-Process "\testpath\msipath\program.msi" /i /qn http://testserver

    Error message – Start-Process : A positional parameter cannot be found that accepts argument '/qn'.
    At line:1 char:1
    + Start-Process "path\ ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

    2nd script –

    Process process = new Process();
    process.StartInfo.FileName = "msiexec.exe";
    process.StartInfo.Arguments = string.Format("/qn /i \"{0}\" ALLUSERS=1","\testpath\msipath\program.msi"-InternalURL http://testserver);
    Error message

    At line:1 char:8
    + Process process = new Process();
    + ~
    Missing statement block after 'process'.
    At line:1 char:16
    + Process process = new Process();
    + ~
    Missing statement block after 'process'.
    At line:1 char:9
    + Process process = new Process();
    + ~~~~~~~
    Script command clause 'process' has already been defined.
    At line:1 char:17
    + Process process = new Process();
    + ~
    Unexpected token '=' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingNamedStatementBlock

  • #54267

    Topics: 8
    Replies: 1190
    Points: 639
    Helping Hand
    Rank: Major Contributor

    Before you even get to the Powershell, have you tried a standard command-line installation?

    msiexec /i "C:\testpath\msipath\program.msi" /qb http://testserver

    Some basic thing that didn't look right:

    • The full path the MSI wasn't used. If it's going to be dynamic and you want to reference the installation directory, you can do that, but you should provide a full path to the msi
    • You say that you want the user to see the installation. The /qn switch is a silent installation, no interface. The /qb should be a basic installation interface.
    • The URL you are passing is a MSI parameter? There is typically a format like URL="http://testserver". The MSI parameters are typically named. That's why I was curious if you actually tested a straight command line before attempting to move to Powershell

    With that said, you need to call MSIEXEC, not the MSI. The arguments can be formatted as an array like so and passed. The += is an example of building the array, so you have the option to do if ($something -eq 'blah) {$arguments += "AnotherParam=1"} or something like that. Here is a basic example:

    $arguments = @()
    $arguments += "/i"
    $arguments += "C:\testpath\msipath\program.msi"
    $arguments += "/qb"
    $arguments += "http://testserver"
    (Start-Process -FilePath "msiexec.exe" -ArgumentList $arguments -Wait -PassThru).ExitCode

The topic ‘new to powershell - create install script’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort