{"id":242,"date":"2018-10-16T19:25:35","date_gmt":"2018-10-16T19:25:35","guid":{"rendered":"http:\/\/michaelschultz.net\/tech\/?p=242"},"modified":"2018-10-16T19:40:16","modified_gmt":"2018-10-16T19:40:16","slug":"configmgr-systems-pending-reboot-collections-and-queries","status":"publish","type":"post","link":"https:\/\/michaelschultz.net\/tech\/configmgr-systems-pending-reboot-collections-and-queries\/","title":{"rendered":"ConfigMgr Systems Pending Reboot Collections and Queries"},"content":{"rendered":"<p>A couple builds ago, Microsoft added a cool new column to the ConfigMgr console.\u00a0 It is really cool but I wanted to more with it.\u00a0 I wanted pending reboot collections and reports.\u00a0 Now I want to share what I found and did.<!--more--><\/p>\n<p>The Pending Reboot information can be found in the ConfigMgr DB as part of the v_CombinedDeviceResources view.\u00a0 This view has a lot of cool info, but we are interested in ClientState.\u00a0 ClientState is\u00a0 what lets us know if there is a reboot pending.<\/p>\n<p>There are\u00a0five main states:<br \/>\n0 = No reboot Pending<br \/>\n1 = Configuration Manager<br \/>\n2 = File Rename<br \/>\n4 = Windows Update<br \/>\n8 = Add or Remove Feature<\/p>\n<p>Now, if you look at that view, you will notice that there are more than those five listed.\u00a0 Two of my biggest ClientState values are 12 and 13.\u00a0 That is because the five are bit flags and your system may have multiple reasons for needing a reboot.<\/p>\n<p>By looking at the message in the console and comparing it to the ClientState value, I determined these additional ClientState values are the various main states added together.<\/p>\n<p>1 &#8211; Configuration Manager<br \/>\n2 &#8211; File Rename<br \/>\n3 &#8211; Configuration Manager, File Rename<br \/>\n4 &#8211; Windows Update<br \/>\n5 &#8211; Configuration Manager, Windows Update<br \/>\n6 &#8211; File Rename, Windows Update<br \/>\n7 &#8211; Configuration Manager, File Rename, Windows Update<br \/>\n8 &#8211; Add or Remove Feature<br \/>\n9 &#8211; Configuration Manager, Add or Remove Feature<br \/>\n10 &#8211; File Rename, Add or Remove Feature<br \/>\n11 &#8211; Configuration Manager, File Rename, Add or Remove Feature<br \/>\n12 &#8211; Windows Update, Add or Remove Feature<br \/>\n13 &#8211; Configuration Manager, Windows Update, Add or Remove Feature<br \/>\n14 &#8211; File Rename, Windows Update, Add or Remove Feature<br \/>\n15 &#8211; Configuration Manager, File Rename, Windows Update, Add or Remove Feature<\/p>\n<p>I can now work on my collection and SQL queries.<\/p>\n<p>This is collection query is for all systems pending reboot.<\/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> SMS_R_SYSTEM<span class=\"sy0\">.<\/span>ResourceID<span class=\"sy0\">,<\/span>SMS_R_SYSTEM<span class=\"sy0\">.<\/span>ResourceType<span class=\"sy0\">,<\/span>SMS_R_SYSTEM<span class=\"sy0\">.<\/span>Name<span class=\"sy0\">,<\/span>SMS_R_SYSTEM<span class=\"sy0\">.<\/span>SMSUniqueIdentifier<span class=\"sy0\">,<\/span>SMS_R_SYSTEM<span class=\"sy0\">.<\/span>ResourceDomainORWorkgroup<span class=\"sy0\">,<\/span>SMS_R_SYSTEM<span class=\"sy0\">.<\/span>Client <span class=\"kw1\">FROM<\/span> SMS_R_System <span class=\"kw1\">JOIN<\/span> sms_combineddeviceresources comb <span class=\"kw1\">ON<\/span> comb<span class=\"sy0\">.<\/span>resourceid <span class=\"sy0\">=<\/span> sms_r_system<span class=\"sy0\">.<\/span>resourceid <span class=\"kw1\">WHERE<\/span> comb<span class=\"sy0\">.<\/span>clientstate &amp;lt;&amp;gt; <span class=\"nu0\">0<\/span><\/div><\/div>\n<p>And this SQL query will return all systems pending reboot and the reason<\/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> <span class=\"br0\">&#91;<\/span>Name<span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n<span class=\"br0\">&#91;<\/span>ClientState<span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n<span class=\"st0\">&quot;Pending Reboot&quot;<\/span><span class=\"sy0\">=<\/span><br \/>\n<span class=\"kw1\">CASE<\/span> <span class=\"br0\">&#91;<\/span>ClientState<span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'1'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'2'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'File Rename'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'3'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager, File Rename'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'4'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Windows Update'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'5'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager, Windows Update'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'6'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'File Rename, Windows Update'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'7'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager, File Rename, Windows Update'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'8'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'9'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager, Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'10'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'File Rename, Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'11'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager, File Rename, Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'12'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Windows Update, Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'13'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager, Windows Update, Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'14'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'File Rename, Windows Update, Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">WHEN<\/span> <span class=\"st0\">'15'<\/span> <span class=\"kw1\">THEN<\/span> <span class=\"st0\">'Configuration Manager, File Rename, Windows Update, Add or Remove Feature'<\/span><br \/>\n<span class=\"kw1\">ELSE<\/span> <span class=\"st0\">'Unknown'<\/span><br \/>\n<span class=\"kw1\">END<\/span><br \/>\n<span class=\"kw1\">FROM<\/span> <span class=\"br0\">&#91;<\/span>v_CombinedDeviceResources<span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"kw1\">WHERE<\/span> ClientState &amp;lt;&amp;gt; <span class=\"st0\">'0'<\/span><br \/>\n<span class=\"kw1\">ORDER<\/span> <span class=\"kw1\">BY<\/span> Name<\/div><\/div>\n<p>I have uploaded the SQL query and one for counts to <a href=\"https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/SQL\/configmgr_systems_pending_reboot.sql\">https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/SQL\/configmgr_systems_pending_reboot.sql<\/a><br \/>\nI have also uploaded a PS script that will create collections based off ClientState to https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/ConfigMgr-Scripts\/configmgr_CB_pendingrebootcolletions.ps1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple builds ago, Microsoft added a cool new column to the ConfigMgr console.\u00a0 It is really cool but I wanted to more with it.\u00a0 I wanted pending reboot collections and reports.\u00a0 Now I want to share what I found and did.<\/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_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},"jetpack_post_was_ever_published":false},"categories":[31,4,26,17],"tags":[7,28,18],"class_list":["post-242","post","type-post","status-publish","format-standard","hentry","category-collections","category-configmgr","category-queries","category-sql","tag-configmgr","tag-sccm","tag-sql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p98a2r-3U","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/242","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=242"}],"version-history":[{"count":2,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/242\/revisions"}],"predecessor-version":[{"id":244,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/242\/revisions\/244"}],"wp:attachment":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/media?parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/categories?post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/tags?post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}