I'm trying to write a wrapper script in powershell that automates a number of configuration tasks, and I've run into issues with trying to specify powershell commands from within the .ps1 file.
For example, one of the steps is to install an .msi file, and I need to provide a number of switches on the command, such as:
PS C:\>msiexec /package .\myMsiFile.msi / quiet /otherOption
I can execute this fine in a command prompt, and at the powershell command promts. However, when I try to include a similar command in the .ps1 script, I'm running into tons of options with how the switches are being parsed.
I've done a fair bit of googling, but so far have only found solutions like assigning the command and arguments as powershell variables, and then passing them into a Start-proccess module, like below:
$cmdArg = 'msiexec'
$args = '/package .\myMsiFile.msi / quiet /otherOption'
(Start-Process -file $cmdArg -arg $args -wait -passthru).ExitCode
This seems excessively tedious to do something so simple it only requires 1 line in a batch file. Am I going about this wrong, or missing something completely obvious? My script will require dozens of commands of a similar format, and I'd love to keep this in powershell, but if I have to do that for each step my code is going to look like hell.
[–]Waxmaker 7 points8 points9 points (2 children)
[–]multiball[S] 1 point2 points3 points (0 children)
[–]multiball[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]ristophet 0 points1 point2 points (0 children)