first time stackoverflower.
I have a need to remove 'ghost' entries from the PackageRegistrations of my software deployment GPOs.
What I mean by that is that there are more entries in the ADSI object than there are MSI/MST files associated to the GPO. i.e. what this blogger also seems to be experiencing http://justanotheritblog.co.uk/2016/11/15/list-msi-paths-from-software-installation-policies/ (I just found this when looking into my issue).
When nosing around the properites in ADSI, I stubmbled across 'msiScriptName', which seems to have a value of either 'A' or 'R'.
What I cannot seem to find, is any information as to what these values may represent.
Any ideas on what the 'A' and 'R' mean and/or how to correctily identify and/or remove the 'ghost' entries greatly recieved.
The reason for this is that I have a whole bunch of software deployment GPOs that need the file path updating, and rather than manually editing each one I wanted to use PowerShell to bulk update them - we are moving to DFS from fixed file server, so I need to update the msiFileList properties. This I can do, but do not want to waste processing overhead on irrelevant objects.
The following is rough code suggesting how I am doing this
$MSIFiles = @()
# Get all the SoftwareDeployment GPOs, indicated by a displayname continaing 'Install' and create an object for each MSI/MST associated to it.
$Packages = Get-GPO -All | Where-Object { $_.DisplayName -like "*Install*" } | Get-ADObjectGPOPackages -Domain 'skyriver.internal'
foreach ($p in $Packages)
{
$msiCount = ($p.msiFileList | Measure-Object).Count
$msiFileListNew = @()
for ($i = 0; $i -lt $msiCount; $i ++)
{
$msiFile = $p.msiFileList[$i] -replace 'hoth(01|01.skyriver.internal|02.skyriver.internal)','skyriver.internal\data'
$msiFileListNew += $msiFile
}
$Properties = [ordered]@{
'gpoDisplayName' = $p.gpoDisplayName
'PackageNumber' = $p.PackageNumber
'DisplayName' = $p.DisplayName
'CN' = $p.CN
'DistinguishedName' = $p.DistinguishedName
'Identity' = $p.Identity
'msiFileList' = $msiFileListNew
}
$obj = New-Object -TypeName psobject -Property $Properties
$MSIFiles += $obj
}
# Now make the replacements.
foreach ($m in $MSIFiles)
{
Set-ADObject -Identity $m.Identity -Server dagobah.skyriver.internal -Replace @{msiFileList = $m.msiFileList}
}
So far as I can tell, A is Advertised (ie available for install), and R is Remove. The Ghost packages probably have an R as they are no longer valid and are therefore to be uninstalled (I'm not sure if this only applies if the "uninstall when it falls out of scope" option is enabled before deleting?).