script library adding msi install ref script
This commit is contained in:
parent
e9e5bf31a7
commit
16fb4d331b
|
@ -607,7 +607,17 @@
|
|||
"name": "EXAMPLE File Copying using powershell",
|
||||
"description": "Reference Script: Will need manual tweaking, for copying files/folders from paths/websites to local",
|
||||
"shell": "powershell",
|
||||
"category": "TRMM (Win):Misc",
|
||||
"category": "TRMM (Win):Misc>Reference",
|
||||
"default_timeout": "1"
|
||||
},
|
||||
{
|
||||
"guid": "168037d8-78e6-4a6a-a9a9-8ec2c1dbe949",
|
||||
"filename": "Win_MSI_Install.ps1",
|
||||
"submittedBy": "https://github.com/silversword411",
|
||||
"name": "EXAMPLE Function for running MSI install via powershell",
|
||||
"description": "Reference Script: Will need manual tweaking, for running MSI from powershell",
|
||||
"shell": "powershell",
|
||||
"category": "TRMM (Win):Misc>Reference",
|
||||
"default_timeout": "1"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
Function Install-MSI {
|
||||
Param (
|
||||
[Parameter(Mandatory, ValueFromPipeline = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.IO.FileInfo]$File,
|
||||
[String[]]$AdditionalParams,
|
||||
[Switch]$OutputLog
|
||||
)
|
||||
$DataStamp = get-date -Format yyyyMMddTHHmmss
|
||||
$logFile = "$($env:programdata)\CentraStage\MilesRMM\{0}-{1}.log" -f $file.fullname, $DataStamp
|
||||
$MSIArguments = @(
|
||||
"/i",
|
||||
('"{0}"' -f $file.fullname),
|
||||
"/qn",
|
||||
"/norestart",
|
||||
"/L*v",
|
||||
$logFile
|
||||
)
|
||||
if ($additionalParams) {
|
||||
$MSIArguments += $additionalParams
|
||||
}
|
||||
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
|
||||
if ($OutputLog.IsPresent) {
|
||||
$logContents = get-content $logFile
|
||||
Write-Output $logContents
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue