{"id":47,"date":"2017-09-01T18:06:14","date_gmt":"2017-09-01T18:06:14","guid":{"rendered":"http:\/\/michaelschultz.net\/tech\/?p=47"},"modified":"2018-06-28T21:47:31","modified_gmt":"2018-06-28T21:47:31","slug":"using-sccm-compliance-settings-and-a-boundary-group-to-apply-bits-settings","status":"publish","type":"post","link":"https:\/\/michaelschultz.net\/tech\/using-sccm-compliance-settings-and-a-boundary-group-to-apply-bits-settings\/","title":{"rendered":"Using ConfigMgr Compliance Settings and a Boundary Group to Apply BITS Settings"},"content":{"rendered":"<p>The solution here makes use of a boundary group to determine if a SCCM client should use BITS to control content transfers and compliance settings set the BITS settings.\u00a0 With SCCM build 1610, the boundary group IDs a client is associated with are store in WMI.\u00a0 Using PowerShell, we are able to look at the boundary group ID and use it to help set BITS settings.\u00a0 Fair warning with this solution.\u00a0 While the boundary group ID is currently stored in WMI, I have been informed by Microsoft that this information isn\u2019t meant to be customer facing and may go away in future SCCM builds, but it is something that is current available.<!--more--><\/p>\n<p>I am going to just cover the compliance item\u2019s discovery script, compliance script, and compliance rule.\u00a0 If you need help with how to create the configuration item, configuration baseline, and deploying the baseline, I suggest starting with the System Center Configuration Manager Documentation site at https:\/\/docs.microsoft.com\/en-us\/sccm\/<\/p>\n<p>The first step is to create a boundary group for applying BITS settings.\u00a0 For me, I named it SCCM &#8211; BITS Enabled Boundaries.\u00a0 I then add all the boundaries that need to have the SCCM clients utilitze BITS.<\/p>\n<p>Once I have the boundary group created, I need to get the GroupID as it is needed as part of the compliance settings scripts.\u00a0 I do this using SQL to query the SCCM database for the GroupID.<\/p>\n<div class=\"codecolorer-container sql default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"sql codecolorer\"><span class=\"kw1\">SELECT<\/span> GroupID <span class=\"sy0\">,<\/span>Name<br \/>\n<span class=\"kw1\">FROM<\/span> vSMS_BoundaryGroup<br \/>\n<span class=\"kw1\">WHERE<\/span> Name <span class=\"sy0\">=<\/span> <span class=\"st0\">'SCCM - BITS Enabled Boundaries'<\/span><\/div><\/div>\n<p>Let&#8217;s say the results from SQL shows the GroupID as 12345678 for my environment.<\/p>\n<p>Now that I have the GroupID, I can work on the PowerShell scripts.\u00a0 The first is the discovery script.<\/p>\n<p>I set the GroupID as a variable<\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"re0\">$ThrottledID<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;12345678&quot;<\/span><\/div><\/div>\n<p>Next, I query WMI get the boundary group IDs for the client and set it as a variable.<\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"re0\">$BoundaryGroups<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">Get-WmiObject<\/span> <span class=\"kw5\">-Namespace<\/span> ROOT\\ccm\\LocationServices <span class=\"kw5\">-class<\/span> BoundaryGroupCache <span class=\"sy0\">|<\/span> <span class=\"kw2\">select<\/span> <span class=\"kw5\">-ExpandProperty<\/span> BoundaryGroupIDs<\/div><\/div>\n<p>I then query the registry to determine if BITS is or is not enabled and set that as a variable.<\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"re0\">$bitsenable<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">Get-ItemProperty<\/span> <span class=\"st0\">&quot;HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS&quot;<\/span> <span class=\"kw5\">-Name<\/span> EnableBitsMaxBandwidth <span class=\"sy0\">|<\/span> <span class=\"kw2\">select<\/span> <span class=\"kw5\">-ExpandProperty<\/span> EnableBitsMaxBandwidth<\/div><\/div>\n<p>Finally, I determine if the client is in the BITS boundary group and set a compliance variable.<\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"kw3\">If<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$boundarygroups<\/span> <span class=\"kw4\">-contains<\/span> <span class=\"re0\">$ThrottledID<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw4\">-and<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$bitsenable<\/span> <span class=\"kw4\">-eq<\/span> <span class=\"st0\">&quot;0&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re0\">$compliance<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;false&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"kw3\">ElseIf<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$boundarygroups<\/span> <span class=\"kw4\">-notcontains<\/span> <span class=\"re0\">$ThrottledID<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw4\">-and<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$bitsenable<\/span> <span class=\"kw4\">-eq<\/span> <span class=\"st0\">&quot;1&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re0\">$compliance<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;false&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"kw3\">Else<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re0\">$compliance<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;true&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n$compliance<\/div><\/div>\n<p>When setting the compliance rule for the compliance setting, it is set to The value returned by the specified script: Equals true.<\/p>\n<p>Now it is time to do the remediation script.<\/p>\n<p>I set variables for the GroupID, boundary groups IDs of the client, and whether BITS is currently enabled or disabled.<\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"re0\">$ThrottledID<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;12345678&quot;<\/span><br \/>\n<br \/>\n<span class=\"re0\">$BoundaryGroups<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">Get-WmiObject<\/span> <span class=\"kw5\">-Namespace<\/span> ROOT\\ccm\\LocationServices <span class=\"kw5\">-class<\/span> BoundaryGroupCache <span class=\"sy0\">|<\/span> <span class=\"kw2\">select<\/span> <span class=\"kw5\">-ExpandProperty<\/span> BoundaryGroupIDs<br \/>\n<br \/>\n<span class=\"re0\">$bitsenable<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">Get-ItemProperty<\/span> <span class=\"st0\">&quot;HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS&quot;<\/span> <span class=\"kw5\">-Name<\/span> EnableBitsMaxBandwidth <span class=\"sy0\">|<\/span> <span class=\"kw2\">select<\/span> <span class=\"kw5\">-ExpandProperty<\/span> EnableBitsMaxBandwidth<\/div><\/div>\n<p>Once the variables are set, I configure the client\u2019s BITS settings.\u00a0 I enable or disable BITS based of the boundary group membership as well as set specific registry settings for BITS settings when BITS is needed.\u00a0 These settings are based off needs in my environment. More information on the BITS registry settings can be found at https:\/\/technet.microsoft.com\/en-us\/library\/bb457145.aspx<\/p>\n<p>I also stop and start the BITS service.<\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"kw3\">If<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$boundarygroups<\/span> <span class=\"kw4\">-contains<\/span> <span class=\"re0\">$ThrottledID<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw4\">-and<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$bitsenable<\/span> <span class=\"kw4\">-eq<\/span> <span class=\"st0\">&quot;0&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> EnableBITSMaxBandwidth <span class=\"kw5\">-value<\/span> <span class=\"nu0\">1<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> MaxBandwidthValidFrom <span class=\"kw5\">-value<\/span> <span class=\"nu0\">6<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> MaxBandwidthValidTo <span class=\"kw5\">-value<\/span> <span class=\"nu0\">18<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> MaxTransferRateOffSchedule <span class=\"kw5\">-value<\/span> <span class=\"nu0\">80<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> MaxTransferRateOnSchedule <span class=\"kw5\">-value<\/span> <span class=\"nu0\">40<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<br \/>\n<span class=\"kw1\">Stop-Service<\/span> BITS<br \/>\n<span class=\"kw1\">Start-Service<\/span> BITS<br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"kw3\">ElseIf<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$boundarygroups<\/span> <span class=\"kw4\">-notcontains<\/span> <span class=\"re0\">$ThrottledID<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw4\">-and<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$bitsenable<\/span> <span class=\"kw4\">-eq<\/span> <span class=\"st0\">&quot;1&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> EnableBITSMaxBandwidth <span class=\"kw5\">-value<\/span> <span class=\"nu0\">0<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> MaxTransferRateOffSchedule <span class=\"kw5\">-value<\/span> <span class=\"nu0\">9999<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<span class=\"kw1\">Set-ItemProperty<\/span> <span class=\"kw5\">-path<\/span> <span class=\"st0\">'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\BITS'<\/span> <span class=\"kw5\">-name<\/span> MaxTransferRateOnSchedule <span class=\"kw5\">-value<\/span> <span class=\"nu0\">9999<\/span> <span class=\"kw5\">-Force<\/span><br \/>\n<br \/>\n<span class=\"kw1\">Stop-Service<\/span> BITS<br \/>\n<span class=\"kw1\">Start-Service<\/span> BITS<br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"kw3\">Else<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The solution here makes use of a boundary group to determine if a SCCM client should use BITS to control content transfers and compliance settings set the BITS settings.\u00a0 With SCCM build 1610, the boundary group IDs a client is associated with are store in WMI.\u00a0 Using PowerShell, we are able to look at the &hellip; <a href=\"https:\/\/michaelschultz.net\/tech\/using-sccm-compliance-settings-and-a-boundary-group-to-apply-bits-settings\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using ConfigMgr Compliance Settings and a Boundary Group to Apply BITS Settings&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,4],"tags":[10,9,7,8,11],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-dcm","category-configmgr","tag-boundaries","tag-compliance-settings","tag-configmgr","tag-dcm","tag-powershell"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p98a2r-L","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":8,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/47\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}