简体   繁体   中英

Installing executables with Powershell DSC

I am trying to install Visual Studio 2013 using PowerShell DSC but I'm running into a few issues and hoping that you guys could clear it up for me. Is DSC capable for rebooting the node and then resuming an installation of VS? Does anyone know what this error means? "vs_ultimate.exe was installed, but the specified ProductId and/or Name does not match package details"

Does anyone have any more specific examples of trying to install .exe with this method?

How does someone find out the ProductID?

Does anyone know the exact syntax of the ReturnCode?

Any help would be great!

If you have a system where the software was already installed you can find the ProductID using:

Get-WmiObject -Class Win32_Product | fl Name,Version,InstallDate,InstallSource,PackageName,IdentifyingNumber

Example output:

Name              : Dell OpenManage Systems Management Software (64-Bit)
Version           : 7.3.0
InstallDate       : 20131009
InstallSource     : c:\Installs\OMSA\
PackageName       : SysMgmtx64.msi
IdentifyingNumber : {7CB08DC5-EA02-4076-BA7D-AD7736A3DE71}

Name              : Microsoft ASP.NET MVC 4 Runtime
Version           : 4.0.40804.0
InstallDate       : 20141111
InstallSource     : C:\windows\TEMP\IXP000.TMP\
PackageName       : AspNetMVC4.msi
IdentifyingNumber : {3FE312D5-B862-40CE-8E4E-A6D8ABF62736}

Where IdentifyingNumber is the GUID you should use in the package resource. Example for the above Dell software:

package OMSA
{
        Name = 'Dell OpenManage Systems Management Software (64-Bit)'
        ...
        ProductId = '7CB08DC5-EA02-4076-BA7D-AD7736A3DE71'
        Arguments = ...
}

Quoting Heath Stewart's comment :

the ProductId is the ProductCode of the MSI, which you can get by opening the MSI in Orca (part of the Windows SDK) or you can install my module from http://psmsi.codeplex.com and get it like so:

get-msitable <yourmsi.msi> -table Property | where { $_.Property -eq "ProductCode" }

The error means you have a mismatch in the Name or the ProductId of your Package resource against the msi content.

Easiest way in my experience to find both value is to use the Carbon powershell module.

Install-Module Carbon

Then simply run from powershell console:

msi "[path to your msi]"

Note: msi is an alias for Get-Msi

Example:

PS C:\Users\gigi\Downloads> msi .\node-v6.10.0-x64.msi

ProductName ProductVersion Manufacturer       ProductCode                         
----------- -------------- ------------       -----------                         
Node.js     6.10.0         Node.js Foundation 84f68739-3b44-4d36-abdb-2151a23c9c3d

Copy and paste ProductName and ProductCode to your DSC package configuration and you are done.

I wrote a PowerShell function to find the product information

Function Get-InstallerProductProperty
{
    # Define parameters
    Param($installerFilePath,
    $PropertyName)

    # Verify file exists
    if((Test-Path -Path $installerFilePath) -eq $true)
    {
        $path = $installerFilePath

        $comObjWI = New-Object -ComObject WindowsInstaller.Installer
        $MSIDatabase = $comObjWI.GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$comObjWI,@($Path,0))
        $Query = "SELECT Value FROM Property WHERE Property = '$PropertyName'"
        $results = $View = $MSIDatabase.GetType().InvokeMember("OpenView","InvokeMethod",$null,$MSIDatabase,($Query))
        $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null)
        $Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null)
        $Value = $Record.GetType().InvokeMember("StringData","GetProperty",$null,$Record,1)

        # Return the product id
        return $Value.Replace("{", "").Replace("}", "")
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM