Gajus - Fotolia
SCVMM PowerShell commands for server health checks
Perform regular SCVMM health checks -- such as monitoring clustered shared volume utilization and host participation in SCVMM placement -- using simple PowerShell commands and scripts.
Although Microsoft offers System Center Operations Manager to help administrators monitor the components associated with System Center Virtual Machine Manager, small organizations might not be able to afford SCOM. Fortunately, there are some common health checks you can perform using SCVMM PowerShell commands.
One check you should perform on all of your Windows servers is for the host name, physical CPU count, cores per CPU and total memory. In addition to the aforementioned information, by executing the SCVMM PowerShell command below, you're also reporting on the SCVMM server, which includes the host cluster name of the server, the live migration settings and the VM host groups.
Get-VMHost | Select HostCluster, Name, PhysicalCPUCount, CoresPerCPU,ProcessorManufacturer, CPUSpeed,CPUModel,@{N="Memory(GB)";E={[math]::Round((($_.TotalMemory)/1GB),
3)}},OperatingSystem,
EnableLiveMigration,VMHostGroup
Check utilization of cluster shared volumes
You should check the utilization of cluster shared volumes in SCVMM clusters from time to time to make sure none of the volumes are running out of space. You can execute the SCVMM PowerShell script below against the server to generate a small report showing the free space on each volume.
$VMMClus = Get-scvmhostcluster -VMMServer
foreach ($ThisClus in $VMMClus) {
$ThisClus.SharedVolumes.GetEnumerator() | Select @{l='ClusterName';e={$vmmcluster.name}},
@{l='Freespace(GB)';e={"{0:N2}"-f ($_.freespace/1gb)}},
@{l='percentage(Available)';e={"{0:N2}" -f ($_.freespace / ($_.Capacity/100))}}
}
Monitor the SCVMM jobs window
Every task you perform in SCVMM is scheduled in the SCVMM job window. The SCVMM job window contains the name of the task that is currently being performed. If it has already been executed, the local task or remote task on a virtualization host or library server will be shown, along with the date and time when the task was performed.
If a task failed to execute successfully, the SCVMM job window will reflect that. Be sure to monitor the SCVMM job window and search for any failed tasks.
Make sure Run As accounts are enabled and active
SCVMM server uses Run As accounts to access information on virtualization hosts. In other words, the SCVMM agent installed on Hyper-V hosts can establish communication with the SCVMM server only by using a Run As account.
Run As accounts are also used for other tasks in SCVMM server. It's important to ensure all the required Run As accounts in your SCVMM server are active and that their credentials haven't expired.
To see if Run As accounts are active, execute the Get-SCRunAsAccount SCVMM PowerShell cmdlet, which lists all the Run As accounts and their status. To test the credentials of a Run As account, use the Test-SCDomainCredential SCVMM PowerShell cmdlet. For example, using $MyCreds = Get-Credential; Test-SCDomainCredential -Credential $MyCreds will test the credentials entered for a Run As account in the $MyCreds variable and show the result in the command window.
Check host participation in SCVMM placement
SCVMM provides an automatic placement feature that can be used to deploy a VM to a virtualization host that is capable of meeting all the deployment criteria for a VM. For example, before a VM gets deployed on a virtualization host, the SCVMM server calculates the host ratings for all the virtualization hosts participating in SCVMM placement and then deploys the VM.
Make sure managed virtualization hosts are enabled to participate in SCVMM placement. To do so, execute the Get-VMHost SCVMM PowerShell command and look for the placement settings.
Make sure library shares are active
Making sure library shares are active doesn't directly fall under an SCVMM health check, but it's important to include if you're the only one managing the SCVMM environment. Library shares store resources, such as hard disk files, drivers and ISO files, which SCVMM agents use during the deployment of VMs on target hosts.
A quick SCVMM PowerShell script can help you verify the status of all the library shares. Executing the PowerShell script below will list all the library shares managed by SCVMM.
$LibServersFile = "C:\Temp\LibServers.TXT"
ForEach ($ThisServer in GC $LibServersFile)
{
Find-SCLibraryShare -LibraryServer "$ThisServer"
}
Executing the SCVMM PowerShell script above will return the list of library shares used by the library servers mentioned in the C:\Temp\LibServers.txt file. A text file named LibServers.TXT hosts the names of the library servers per line, as shown in Figure A.
If you don't find a library share in the returned list, you can take action accordingly.