Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 249166

Re: Check Host Profile Compliance At Host Level

$
0
0

Thanks for you additions. It is a usefull script now.

 

To prevent the Test-VMHostProfileCompliance cmdlet from outputting red warning messages for hosts that don't have a host profile you can add -ErrorAction:SilentlyContinue to that line. if ($var -ne $null) is the same as if ($var) and is a bit shorter.

 

foreach ($VMHostin (Get-VMHost))
{   $Compliance=Test-VMHostProfileCompliance-VMHost$VMHost-UseCache-ErrorAction:SilentlyContinue  $AttachedProfile=Get-VMHostProfile-entity$VMHost  if ($Compliance)   {    $ComplianceStatus=$Compliance.ExtensionData.ComplianceStatus   }  elseif ($AttachedProfile)   {    $ComplianceStatus="Compliant"  }   else  {     $ComplianceStatus="No Profile Attached!"  }   New-Object-TypeNamePSObject-Property @{     VMhost =$VMHost.name     ComplianceStatus =$ComplianceStatus  }
}

Viewing all articles
Browse latest Browse all 249166

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>