Git Product home page Git Product logo

Comments (3)

DarrenWhite99 avatar DarrenWhite99 commented on August 29, 2024

It is building an argument list, but it is joining them all together immediately. ( -join ' ' ) .
But the password alone is not the argument, it is SERVERPASS=PASSWORD .. I don't know if you can get away with SERVERPASS= PASSWORD as two arguments.

from labtech-powershell-module.

dkattan avatar dkattan commented on August 29, 2024

Upon further inspection, the problem is more about escaping double quotes in MSI parameters, and not escaping them for the command line.

$ServerPassword = 'Hello"world'
"SERVERPASS=""$ServerPassword"""
SERVERPASS="Hello"world"

This makes msiexec unable to parse the command line, and if we were to be in an interactive session, pops up the help dialog.

I think the solution instead is a $ServerPassword = $ServerPassword.Replace('"','""') on the preceding line

As an aside, TIL I put entirely too much faith in Start-Process handling of -ArgumentList when it is an array.

https://github.com/PowerShell/PowerShell/blob/9f1f6762073e450d0940cfcbe8ee6dbb8710ea08/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs#L1876

I naively assumed it was scanning for spaces in each array item and wrapping it in double quotes if found.

This is not the case.

Start-Process -Wait msiexec -ArgumentList "/i","C:\Mimecast for Outlook 7.9.0.79 (x64).msi","/qn"

Fails in the same mode as above, however

Start-Process -Wait msiexec -ArgumentList "/i","`"C:\Mimecast for Outlook 7.9.0.79 (x64).msi`"","/qn"

Works as expected.

from labtech-powershell-module.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.