{"id":3400,"date":"2015-12-22T14:04:34","date_gmt":"2015-12-22T20:04:34","guid":{"rendered":"http:\/\/www.jasemccarty.com\/blog\/?p=3400"},"modified":"2015-12-22T21:56:38","modified_gmt":"2015-12-23T03:56:38","slug":"vsan-spbm-compliance-powercli","status":"publish","type":"post","link":"https:\/\/www.jasemccarty.com\/blog\/vsan-spbm-compliance-powercli\/","title":{"rendered":"VSAN, SPBM Compliance, &#038; PowerCLI"},"content":{"rendered":"<p>I very often tear down\/distress my &#8220;lab&#8221; environment while working on docs\/testing code\/trying to replicate issues\/etc. I was trying to recreate an issue the other day and decided to replace my vCenter Appliance. I deleted the VCSA, but left some of the other VMs, as they had some services I needed like DNS.<\/p>\n<p>After deploying the a new VCSA, I noticed an error in the Cluster&#8217;s Monitor tab, under Virtual SAN, specific to my VSAN objects. \u00a0The Compliance status for all my old VM&#8217;s was &#8220;Out of Date.&#8221;<\/p>\n<p>I clicked on a single VM, picked my VM storage policy, and selected the VM home and clicked OK. I could have just as easily selected Apply to all. Not hard, but potentially time consuming in the case of a lot of objects.<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/noncompliant.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3402\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/noncompliant-1024x553.png\" alt=\"noncompliant\" width=\"500\" height=\"270\" srcset=\"https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/noncompliant-1024x553.png 1024w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/noncompliant-300x162.png 300w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/noncompliant-768x415.png 768w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/noncompliant.png 1115w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p><!--more-->I thought for a second. I&#8217;d rather not do this for each of these objects\u2026 Plus, I&#8217;ll likely tear down the VCSA again\u2026 So why not script it?<\/p>\n<p>I looked at 2 PowerCLI cmdlets to handle this. <strong><a href=\"https:\/\/www.vmware.com\/support\/developer\/PowerCLI\/PowerCLI58R1\/html\/Get-SpbmEntityConfiguration.html\" target=\"_blank\">Get-SpbmEntityConfiguration<\/a><\/strong> shows the currently assigned SPBM policy, along with whether it is compliant or not, and the last time it was checked. <strong><a href=\"https:\/\/www.vmware.com\/support\/developer\/PowerCLI\/PowerCLI58R1\/html\/Set-SpbmEntityConfiguration.html\" target=\"_blank\">Set-SpbmEntityConfiguration<\/a><\/strong> sets SPBM configuration data for VMs, HardDisks, and cluster objects.<\/p>\n<p>My PowerShell\/PowerCLI is a little rusty, but I was able to crank out a one liner for the\u00a0task.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">Set-SpbmEntityConfiguration -Configuration (Get-SpbmEntityConfiguration | \r\nWhere-Object {$_.ComplianceStatus -eq 'outOfDate'}) -StoragePolicy $_.StoragePolicy<\/pre>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/compliant.png\" rel=\"attachment wp-att-3410\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3410\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/compliant.png\" alt=\"compliant\" width=\"500\" height=\"260\" srcset=\"https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/compliant.png 1112w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/compliant-300x156.png 300w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/compliant-768x399.png 768w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/compliant-1024x532.png 1024w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>I didn&#8217;t really sort those objects, but adding &#8220;Sort -Property Id&#8221; to the Get-SpbmEntityConfiguration call would clean it up. Hard disks would then be listed under their VM&#8217;s home entity.<\/p>\n<p>Refreshing the Web Client, all of the objects show as Compliant.<\/p>\n<p>Also, in the script, I&#8217;m only reapplying policies to objects that are out of compliance.<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/showcompliance.png\" rel=\"attachment wp-att-3416\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3416\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/showcompliance.png\" alt=\"showcompliance\" width=\"500\" height=\"206\" srcset=\"https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/showcompliance.png 826w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/showcompliance-300x123.png 300w, https:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2015\/12\/showcompliance-768x316.png 768w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>A quick check using &#8220;Get-SpbmEntityConfiguration&#8221; shows that all my VM&#8217;s are compliant with their assigned Storage Policy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I very often tear down\/distress my &#8220;lab&#8221; environment while working on docs\/testing code\/trying to replicate issues\/etc. I was trying to recreate an issue the other &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[135,10],"tags":[65,167,151,152],"class_list":["post-3400","post","type-post","status-publish","format-standard","hentry","category-software-defined","category-storage-2","tag-powercli","tag-spbm","tag-virtual-san","tag-vsan"],"_links":{"self":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/3400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/comments?post=3400"}],"version-history":[{"count":22,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/3400\/revisions"}],"predecessor-version":[{"id":3427,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/3400\/revisions\/3427"}],"wp:attachment":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/media?parent=3400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/categories?post=3400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/tags?post=3400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}