Skip to content

Instantly share code, notes, and snippets.

@wsmelton
Last active January 14, 2021 21:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsmelton/e2d9c6b2323d60d372d8192b24a24b0f to your computer and use it in GitHub Desktop.
Save wsmelton/e2d9c6b2323d60d372d8192b24a24b0f to your computer and use it in GitHub Desktop.
Listing of ProductID and Product Name for SSMS install with PowerShell DSC
<#
Listing of the required information to install SQL Server Management Studio via the Package resource with PowerShell DSC.
# Example config:
Configuration InstallSSMS {
Package InstallSsms {
Ensure = "Present"
ProductID = <GUID value>
Name = Full SSMS Name that displays in Program Features
Path = SSMS-Setup-ENU.exe
Arguments = "/install /passive /norestart"
}
}
The above can be used for any version but you have to know the ProductID and the full displayed name for SSMS. It was discovered recently that this chagnes with each version. So the below is pscustomobject for each one.
The code below will pull the needed information for the version of SSMS installed currently:
$x86Path = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedItemsX86 = Get-ItemProperty -Path $x86Path | Select-Object -Property DisplayName, PSChildName
$x64Path = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedItemsX64 = Get-ItemProperty -Path $x64Path | Select-Object -Property DisplayName, PSChildName
$installedItems = $installedItemsX86 + $installedItemsX64
$installedItems | Where-Object -FilterScript { $_.DisplayName -like "Microsoft SQL Server Management Studio*" } | Sort-Object -Property DisplayName | fl
#>
DisplayName : Microsoft SQL Server Management Studio - 17.9
PSChildName : {083356d9-896b-43ce-8013-f8e1e95c163d}
DisplayName : Microsoft SQL Server Management Studio - 18.0 Preview 5
PSChildName : {bbd634e9-1c99-4a6b-9135-023b09e41723}
@conran20
Copy link

Hello,

I am currently having issues getting the name/productID to match.

I've tried many different names/ids.

From what your commands got back, to what is in c:\program files(x86), to what the following commands have pulled back:

Get-WmiObject Win32_Product | Format-Table IdentifyingNumber, Name, Version

function Get-Guid {
Param(
[parameter(Mandatory=$true)]
[string]$Name
)
$path = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall*'
Get-ItemProperty -Path $path | Where-Object {$_.DisplayName -like "$name"} | select Displayname, ModifyPath
}

get-guid

I've gotten the same error on each iteration:

image

Am I missing something?

Here is my script:

`#################################################

Temporary relax execution policy

#################################################

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force

#################################################

Install necessary modules

#################################################

Check if the PSDscResources module is installed, if not install.

if((get-module -name PSDscResources) -eq $null) { install-module PSDscResources -Force -Verbose }

Check if the FileDownloadDSC module is installed, if not install.

if((get-module -name FileDownloadDSC) -eq $null) { install-module FileDownloadDSC -Force -Verbose}

Configuration InstallSSMS #Version 18.6, 15.0.18338.0
{
Import-Module –Name 'PSDesiredStateConfiguration'
Import-Module -Name 'FileDownloadDSC'
Import-DSCResource -Name 'FileDownload'

Node localhost
{
    FileDownload DownloadSSMS
    {
       FileName = "C:\dsc\downloads\SSMS-Setup-ENU.msi"
       Url = "https://go.microsoft.com/fwlink/?linkid=2135491"
       #-DependsOn = [string] 
       #-PsDscRunAsCredential = "Administrator"
	}

    Package InstallSSMS
    {
        Name = "SQL Server Management Studio"
        Path = "C:\dsc\downloads\SSMS-Setup-ENU.msi"
        ProductId = "67FD1BCA-F06F-48F5-86E9-AC4EA982A775"
        Arguments = "/install /passive /norestart"
        #[Credential = [PSCredential]]
        DependsOn = "[FileDownload]DownloadSSMS"
        Ensure = "present"
        #LogPath = "c:\logs\"
        #PsDscRunAsCredential = "Administrator"
        
    }
   
}

}

InstallSSMS
Start-DscConfiguration .\InstallSSMS -Verbose -Wait -Force
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment