diff --git a/api/tacticalrmm/scripts/community_scripts.json b/api/tacticalrmm/scripts/community_scripts.json index 65997501..97b2a661 100644 --- a/api/tacticalrmm/scripts/community_scripts.json +++ b/api/tacticalrmm/scripts/community_scripts.json @@ -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" } ] \ No newline at end of file diff --git a/scripts/Win_MSI_Install.ps1 b/scripts/Win_MSI_Install.ps1 new file mode 100644 index 00000000..c19dca16 --- /dev/null +++ b/scripts/Win_MSI_Install.ps1 @@ -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 + } +} \ No newline at end of file