script library adding msi install ref script

This commit is contained in:
silversword411 2021-04-27 13:07:14 -04:00
parent e9e5bf31a7
commit 16fb4d331b
No known key found for this signature in database
GPG Key ID: 6F4BD176F56B50CA
2 changed files with 38 additions and 1 deletions

View File

@ -607,7 +607,17 @@
"name": "EXAMPLE File Copying using powershell", "name": "EXAMPLE File Copying using powershell",
"description": "Reference Script: Will need manual tweaking, for copying files/folders from paths/websites to local", "description": "Reference Script: Will need manual tweaking, for copying files/folders from paths/websites to local",
"shell": "powershell", "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" "default_timeout": "1"
} }
] ]

View File

@ -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
}
}