46 lines
1.5 KiB
Markdown
46 lines
1.5 KiB
Markdown
```powershell
|
|
#Download and Run MSI package for Automated install
|
|
## VZ
|
|
#$uri = "https://eu.ninjarmm.com/agent/installer/22ea45a7-e951-4229-b305-ef9178339f0c/verbraucherzentralebayernmnchenmo9-7.0.2317-windows-installer.msi"
|
|
## SBX link for tests
|
|
$uri = "https://eu.ninjarmm.com/agent/installer/f816281d-6f56-4f13-abd6-5d4abf4dc67a/softboxhauptsitz-7.0.2317-windows-installer.msi"
|
|
$out = "c:\Temp\NinjaOneInstaller.msi"
|
|
|
|
if ( !( Test-Path "C:\Temp" ) )
|
|
{
|
|
New-Item -ItemType Directory -Path "C:\Temp"
|
|
}
|
|
|
|
|
|
Function Download_MSI_NinjaOne_Installer{
|
|
Invoke-WebRequest -uri $uri -OutFile $out -UserAgent ([Microsoft.PowerShell.Commands.PSUserAgent]::FireFox)
|
|
$msifile = Get-ChildItem -Path $out -File -Filter '*.ms*'
|
|
write-host "NinjaOne MSI $msifile "
|
|
}
|
|
|
|
$msifile = Get-ChildItem -Path $out -File -Filter '*.ms*'
|
|
Function Install_NinjaOne{
|
|
write-host "NinjaOne MSI $msifile "
|
|
$FileExists = Test-Path $msifile -IsValid
|
|
$DataStamp = get-date -Format yyyyMMddTHHmmss
|
|
$logFile = '{0}-{1}.log' -f $msifile.fullname,$DataStamp
|
|
$MSIArguments = @(
|
|
"/i"
|
|
('"{0}"' -f $msifile.fullname)
|
|
"/qn"
|
|
"/norestart"
|
|
"/L*v"
|
|
$logFile
|
|
)
|
|
If ($FileExists -eq $True)
|
|
{
|
|
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -passthru | wait-process
|
|
write-host "Finished msi "$msifile
|
|
}
|
|
|
|
Else {Write-Host "File doesn't exists"}
|
|
}
|
|
Download_MSI_NinjaOne_Installer
|
|
$msifile = Get-ChildItem -Path $out -File -Filter '*.ms*'
|
|
Install_NinjaOne
|
|
``` |