This shows you the differences between two versions of the page.
userspace:msi_to_opsi [2013/07/30 06:53] qx23 created |
userspace:msi_to_opsi [2021/08/23 08:37] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== MSI to OPSI ====== | ||
- | Tested on: Win7 64-bit | ||
- | Requieres: Powershell 2.0, MSI Module for Powershell | ||
- | |||
- | Download MSI Module for Powershell: http:// | ||
- | |||
- | |||
- | Dieses Powershellscript extrahiert informationen aus MSI Paketen und erstellt automatisiert anhand eines Templates fertige Opsiskripte inkl. control-Datei und der passenden Verzeichnisstruktur um die fertigen Daten auf den Opsiserver kopieren zu können. | ||
- | |||
- | '' | ||
- | < | ||
- | # Version: 0.1 | ||
- | # Date: 30.7.2013 | ||
- | # Author: Chris | ||
- | # Description: | ||
- | # How to use: MSI Files in poolfoldername will be processed by msi powershell module. Place MSI files in folder pool, run script, retrieve ready to use Opsi scripts from folder OUTPUT | ||
- | |||
- | $testmodulemsi = Get-Module -ListAvailable | Where-Object { $_.name -eq " | ||
- | if (($testmodulemsi)) | ||
- | { | ||
- | Import-Module -Name MSI -ErrorAction SilentlyContinue | ||
- | Write-Host " | ||
- | } | ||
- | else { | ||
- | Write-Host `n" | ||
- | Write-Host "THIS IS A FATAL ERROR. EXITING NOW." | ||
- | exit | ||
- | } | ||
- | |||
- | $DateTime = (Get-Date -Format s) -Replace " | ||
- | |||
- | ## Specify some global settings | ||
- | |||
- | $BaseFolder = " | ||
- | |||
- | # Poolfoldername is the location with the basefolder where the installers and theire procducte images are located. | ||
- | $PoolFolderName = " | ||
- | $InputFolder = $BaseFolder + " | ||
- | |||
- | # OPSI Package Parameter | ||
- | $DefaultValueMinimumspace = "1000 MB" | ||
- | $priority = " | ||
- | $packageversion = " | ||
- | |||
- | # Set Log Folder | ||
- | $LogFolder = " | ||
- | If(!(Test-Path " | ||
- | $log = $LogFolder + " | ||
- | |||
- | # MSI Parameter | ||
- | $installparameter = "/gb-! REBOOT=REALLYSUPPRES" | ||
- | $uninstallparameter = "/gb-! REBOOT=REALLYSUPPRES" | ||
- | |||
- | |||
- | # Move finishe packages to Opsi server. Not implementet (yet) | ||
- | $CopyToOpsiServer = $false | ||
- | $OpsiServerName = " | ||
- | $OpsiUserName = " | ||
- | $OpsiPasswordName = " | ||
- | $CreatedLinuxShellScript = $false | ||
- | |||
- | foreach ($msifile in Get-ChildItem .\Pool -Filter *.msi -name) { | ||
- | |||
- | $fullmsifile = $InputFolder + $msifile | ||
- | $productName = get-msitable $fullmsifile -table Property | where-object { $_.Property -eq " | ||
- | $productNameFlat = ($productName) -Replace " ", " | ||
- | $description = " | ||
- | |||
- | $progamversion = get-msitable $fullmsifile -table Property | where-object { $_.Property -eq " | ||
- | $msiid = get-msitable $fullmsifile -table Property | where-object { $_.Property -eq " | ||
- | |||
- | $uninstallprogramm = $msifile | ||
- | $uninstallprogramm = $msifile | ||
- | $installexec = $msifile | ||
- | |||
- | write-host " | ||
- | |||
- | $packagename = $productName.ToLower() | ||
- | $OutputPackageFolder = $BaseFolder + " | ||
- | $InstallerExecutable = $fullmsifile | ||
- | $OutputPackageFolderClientData = $OutputPackageFolder + ' | ||
- | |||
- | # Create packagefolder structur | ||
- | " | ||
- | |||
- | If(!(Test-Path " | ||
- | { | ||
- | New-Item -ItemType Directory -Path " | ||
- | " | ||
- | } | ||
- | Else | ||
- | { | ||
- | " | ||
- | } | ||
- | If(!(Test-Path " | ||
- | { | ||
- | New-Item -ItemType Directory -Path " | ||
- | " | ||
- | } | ||
- | Else | ||
- | { | ||
- | " | ||
- | } | ||
- | |||
- | If(!(Test-Path " | ||
- | { | ||
- | New-Item -ItemType Directory -Path " | ||
- | " | ||
- | } | ||
- | Else | ||
- | { | ||
- | " | ||
- | } | ||
- | |||
- | |||
- | $minimumspace = $DefaultValueMinimumspace | ||
- | |||
- | # Create setup.ins | ||
- | $original_file_setup_ins = $BaseFolder + ' | ||
- | $destination_file_setup_ins = $OutputPackageFolder + ' | ||
- | |||
- | (Get-Content $original_file_setup_ins) | Foreach-Object { | ||
- | $_ -replace ' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | Set-Content $destination_file_setup_ins | ||
- | |||
- | # Create uninstall.ins | ||
- | |||
- | $original_file_uninstall_ins = $BaseFolder + ' | ||
- | $destination_file_uninstall_ins = $OutputPackageFolder + ' | ||
- | |||
- | (Get-Content $original_file_uninstall_ins) | Foreach-Object { | ||
- | $_ -replace ' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | Set-Content $destination_file_uninstall_ins | ||
- | |||
- | # Create delsub.ins | ||
- | |||
- | $original_file_delsub_ins = $BaseFolder + ' | ||
- | $destination_file_delsub_ins = $OutputPackageFolder + ' | ||
- | |||
- | (Get-Content $original_file_delsub_ins) | Foreach-Object { | ||
- | $_ -replace ' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | Set-Content $destination_file_delsub_ins | ||
- | |||
- | |||
- | # Create OPSI Controlfile | ||
- | $original_file_opsi_control = $BaseFolder + " | ||
- | $destination_file_opsi_control = $OutputPackageFolder + " | ||
- | |||
- | (Get-Content $original_file_opsi_control) | Foreach-Object { | ||
- | $_ -replace " | ||
- | -replace ' | ||
- | -replace ' | ||
- | -replace ' | ||
- | -replace ' | ||
- | -replace ' | ||
- | } | Set-Content $destination_file_opsi_control | ||
- | |||
- | # Copy executable files und producticons | ||
- | |||
- | If(!(Test-Path $InstallerExecutable)) | ||
- | { | ||
- | Write-Host " | ||
- | " | ||
- | } | ||
- | Else | ||
- | { | ||
- | Copy-Item -Path $InstallerExecutable -Destination $OutputPackageFolderClientData | ||
- | } | ||
- | |||
- | } | ||
- | |||
- | </ |