remote PCs using get-msiproductinfo

Aug 10, 2007 at 2:57 AM
Hi,

I'm curious, are you planning on adding the ability to grade the MSI info from remote boxes?

regards,
Feb 11, 2008 at 8:46 AM
Windows Installer APIs do not support remote calls, however remoting is planned for PowerShell v2.0 (see http://connect.microsoft.com to sign up for pre-releases) and you could use WMI currently to query the Win32_Product class like so,

get-wmiobject -class Win32_Product -computername {remote computer name}
Jul 25, 2013 at 10:37 AM
Be aware of the following if you do use win32_product:
http://gregramsey.net/2012/02/20/win32_product-is-evil/
http://support.microsoft.com/kb/974524?siteID=rGMTN56tf_w-zqifLU196uOvhooe6pv4JA
Jul 25, 2013 at 11:46 AM
Here's an example of running it remotely, you copy the folder to the temp directory on the remote machine, invoke the command remotely, then delete the remote folder, this has to be done as a separate job as the Windows Installers will have been loaded in the app domain. I do this as a job as I don't need to wait for it to complete.
[cmdletbinding()]
param
(
    [parameter(Mandatory=$true,ValueFromPipeLine=$true,ValueFromPipelineByPropertyName=$true)]
    [string]
    $computerName
)

begin
{
    write-verbose "Starting: $($MyInvocation.MyCommand)"

    $scriptFolder   = Split-Path -Parent $MyInvocation.MyCommand.Path
    $moduleName     = "MSI"
    $modulePath     = Join-Path -Path $scriptFolder -ChildPath $moduleName  

    $remoteScript   = {
        param($targetPath)
        
        Import-Module $targetPath
        Get-MSIProductInfo
    }

    $delayedDelete  = {
        param($path)
        Remove-Item -Path $path -Force -Recurse
    }
}
process
{
    $remotePath = "\\$computerName\c$\temp\$moduleName"
    
    write-verbose "Copying module to $remotePath"
    Copy-Item -Path $modulePath -Destination $remotePath -Recurse -Container -Force

    write-verbose "Getting installed products"
    $products = Invoke-Command -ComputerName $computerName -ScriptBlock $remoteScript -ArgumentList "c:\temp\$moduleName"
    write-verbose "$($products.length) Products found"
    
    write-verbose "Starting job to delete $remotePath"
    Start-Job -ScriptBlock $delayedDelete -ArgumentList $remotePath | Out-Null
}

end
{
    write-verbose "Complete: $($MyInvocation.MyCommand)"
}
Marked as answer by heaths on 10/3/2013 at 2:17 PM