Hi,
With much help, I create this script to add sourcelist’s path to MSI. I hope it might help.
<code>Function AddSourceList { <# .SYNOPSIS Ajoute un chemin au sourcelist d'un MSI .DESCRIPTION Ajoute un chemin au sourcelist d'un MSI .Parameter Str_MSIPathAndFile Donner un chemin complet d'un MSI incluant le nom du fichier. Le MSI doit se trouver dans le répertoire. .EXAMPLE AddSourcelist MSI #> [CmdletBinding()] param( [Parameter(Mandatory=$true)] [string]$Str_MSIPathAndFile ) Begin { ## Get the name of this function and write header [string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header } Process { Try { $MSIPath=split-path $Str_MSIPathAndFile $ProductCode= Get-MsiTableProperty -Path $Str_MSIPathAndFile #$productcode='{09AAAB09-6DBA-4DD9-9865-54597D3FBCA8}' #$MSIPath='E:\Temp\Logiciels\Antidote 8\msi\druide' $Com_WI = New-Object -ComObject WindowsInstaller.Installer $codeInvokeMethod = { $type = $this.gettype(); $index = $args.count - 1; $methodargs = $args[1..$index] $type.invokeMember($args[0], [System.Reflection.BindingFlags]::InvokeMethod, $null, $this, $methodargs) } $Com_WI = $Com_WI | Add-Member -MemberType ScriptMethod -Value $codeInvokeMethod -Name InvokeMethod -PassThru Try { Write-log "Ajout du Sourcelist $($MSIPath) au MSI $($Str_MSIPathAndFile) Product code $($productcode.productcode)" $Com_WI.InvokeMethod('AddSource', "$($productcode.productcode)", '', "$($MSIPath)") } Catch { Write-Log -Message "Failed to resolve registry path [$regKey]. </code>
n$(Resolve-Error)" -Severity 3 -Source ${CmdletName}
Continue
}
}
catch {
Write-Log -Message “Failed to resolve registry path [$regKey]. `n$(Resolve-Error)” -Severity 3 -Source ${CmdletName}
Continue
}
}
End {
Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
}
}`