List MSI paths from Software Installation Policies
Hey, We have 1000’s of MSI’s assigned through group policy and often need to work with the file paths in PowerShell, here’s a function that returns the file path of the MSI from the Software Installation GPO.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Function Get-MSIPath { [CmdletBinding()] Param ( [Parameter(Mandatory=$True,position=0)] $Policy, [Parameter(Mandatory=$False)] $Domain = (Get-ADDomainController).Name ) $DC = Get-ADDomainController -DomainName $Domain -Discover $DN = (Get-ADDomain -Server $DC).DistinguishedName $GP = Get-GPO -Name $Policy -Domain $Domain -Server $DC $ADobj = Get-ADObject -filter "Name -ne 'Packages'" -Server $DC -SearchBase "CN=Packages,CN=Class Store,CN=Machine,CN={$($GP.ID.Guid)},CN=Policies,CN=System,$DN" -ErrorAction Stop -SearchScope Subtree -Properties msiFileList,displayName Return $ADobj.MSIFileList } |
This function will return the MSI path and MST path. It will… Read more »