This project has moved. For the latest updates, please go here.

Hide TS Advertisements

Topics: Support Requests
Jul 9, 2015 at 3:46 AM
Hi All,
Can anybody help me with the logic the 'Hide TS Advertisements' function uses? (Under Software Distribution -> Advertisements) i.e. is it where some value -eq false in the original WMI query (get-wmiobject -query "SELECT * FROM CCM_SoftwareDistribution" -namespace "root\ccm\policy\machine\actualconfig").

Hopefully an easy one and thank you in advance.
Coordinator
Jul 9, 2015 at 6:33 AM
Edited Jul 9, 2015 at 6:35 AM
The 'Hide TS Advertisements' just filters duplicate AdvertisementID's...
http://sccmclictr.codeplex.com/SourceControl/latest#SCCMCliCtrWPF/SCCMCliCtrWPF/Controls/AdvertisementGrid.xaml.cs
if (cb_TSAdv.IsChecked == true)
 {
   List<softwaredistribution.CCM_SoftwareDistribution> oList = oAgent.Client.SoftwareDistribution.Advertisements_(true).OrderBy(o => o.PRG_ProgramID).ThenBy(o => o.PKG_Name).ToList();
   iAdvertisements = oList.GroupBy(t => t.ADV_AdvertisementID).Select(grp => grp.FirstOrDefault()).OrderBy(o => o.PKG_Name).ToList();
  }
  else
  {
   List<softwaredistribution.CCM_SoftwareDistribution> oList = oAgent.Client.SoftwareDistribution.Advertisements_(true).OrderBy(o => o.PRG_ProgramID).ThenBy(o => o.PKG_Name).ToList();
   iAdvertisements = oList.OrderBy(o => o.PKG_Name).ToList();
  }
As this is done in the code behind, you will not see any difference in the PowerShell command...
Jul 10, 2015 at 10:48 AM
Edited Jul 10, 2015 at 10:50 AM
Many thanks rzander.

Just in case anybody else is trying to do something similar, my motivation for the above question was that I was trying to replicate the Hide TS Advertisements function directly in PowerShell, and with rzanders help, I came up with the below.

(Get-WmiObject -query "SELECT * FROM CCM_SoftwareDistribution" -namespace "root\ccm\policy\machine\actualconfig" | Group-Object ADV_AdvertisementID | ? {$_.Count -eq 1}).Group
Marked as answer by rzander on 7/10/2015 at 4:03 AM