Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parameters/ Arguments using powershell

Status
Not open for further replies.

GrimR

IS-IT--Management
Jun 17, 2007
1,149
0
0
ZA
How can I install the parameters/ Arguments using powershell

Start-Process 'server\software$\Agent-6.11.1-x64.msi' -ArgumentList "/i /qn" "Agent='GROUP' SERVER=cloud.work.com:443 KEY=4cehdahdihaifdiahfidhfaduhfdjhf" -Wait
I get the same error in this website, but when I try his solution it does not work, the box still appears




MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
found one that works

$cmdhash=@{}
$cmdhash['FilePath'] = 'C:\Windows\System32\msiexec.exe'
$cmdhash['Wait'] = $true
$cmdhash['NoNewWindow'] = $true
$cmdhash['ArgumentList']=@()
$cmdhash['ArgumentList'] += '/i \\esd189.org\dfs\wpkg\software\Google\GAPS\googleappspasswordsync64.msi'
$cmdhash['ArgumentList'] += '/l*vx C:\programdata\gaps_msi_log.txt'
$cmdhash['ArgumentList'] += '/quiet'
$cmdhash['ArgumentList'] += 'DOMAIN="example.org"'
$cmdhash['ArgumentList'] += 'ADMIN_EMAIL="googlesync@example.org"'
$cmdhash['ArgumentList'] += 'CREDENTIALS_FILE="\\ds-01\c$\Users\svc-googlesync\Documents\example.json"'
$cmdhash['ArgumentList'] += 'BASE_DN="DC=example,DC=org"'
$cmdhash['ArgumentList'] += 'MAIL_ATTRIBUTE="userPrincipalName"'
# using splatting, run the process
Start-Process @cmdhash

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
are you interested in if the MSI was successful or not?

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
it works on ssome msi files but I have others this does not work on

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
historically i resorted to:

$WshShell = New-Object -ComObject Wscript.Shell
$objTask.ReturnCode = $WshShell.Run($objTask.Command + " " + $strParameters, 2, $TRUE)
Write-Log ("------ Task(" + $objTask.Name + ").ReturnCode = " + $objTask.ReturnCode) -AsInfo

Pretty ugly, but it was the early days of powershell and i was struggling to get it to wait and give me the returncode.
The above is bomb proof, clunky as you like though :)

This is an alternative (but i still stick with the above as it has never caused me issues):

Function ExecuteProc ($filename, $parms, $parms2)
{
$proc = New-Object System.Diagnostics.ProcessStartInfo
$proc.FileName = $filename
$proc.RedirectStandardError = $true
$proc.RedirectStandardOutput = $true
$proc.UseShellExecute = $false
$proc.Arguments = $parms,$parms2
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $proc
$p.Start() | Out-Null
$p.WaitForExit()
return $p.ExitCode
}



I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top