#Produce IDs so we can clean our pack.
$CleanDisplayName = $SolutionName.Replace('.','')
$MPID = "P2P.OMSAdministration.SolutionControl.$CleanDisplayName"
$FoundMP = $null
Try
{
#Before we go further, check for Installed Pack
$FoundMP = $MG.GetManagementPacks($MPID)
If ($FoundMP -ne $null)
{
$PackInstallDate = $FoundMP.TimeCreated.ToLocalTime().ToString()
Write-EventLog -LogName 'OMS Admin Extensions' -Source OMSAdminSetup -EntryType Information -EventId 5650 -Message "We found the pack $MPID for $SolutionName, it was installed on $PackInstallDate. This will be deleted as part of the Process." -Category 50
Remove-SCOMManagementPack -ManagementPack $FoundMP -ErrorAction SilentlyContinue
}
Else
{
Write-EventLog -LogName 'OMS Admin Extensions' -Source OMSAdminSetup -EntryType Information -EventId 5651 -Message "We did not find the Override pack $MPID for $SolutionName" -Category 50
}
}
Catch
{
Write-EventLog -LogName 'OMS Admin Extensions' -Source OMSAdminSetup -EntryType Information -EventId 5651 -Message "We did not find the Override pack $MPID for $SolutionName" -Category 50
}