param( [string] $VISRV) ############################### # vCheck - Daily Error Report # ############################### # Thanks to all who have commented on my blog to help improve this project # Especially - Thanks to Raphaël SCHITZ (http://www.hypervisor.fr/) for his contributions and time # And also thanks to the many vExperts who have added suggestions for this report. # $Version = "5.0" # # Changes: # Version 5.0 - Changed the order and a few titles etc, tidy up ! # Version 4.9 - Added Inacessable VMs # Version 4.8 - Added HA VM restarts and resets # Version 4.7 - VMTools Issues # Version 4.6 - Added VCB Garbage # Version 4.5 - Added Host config issues # Version 4.4 - Added Disk Overcommit check # Version 4.3 - Added vSwitch free ports check # Version 4.2 - Added General Capacity Information based on CPU and MEM ussage per cluster # Version 4.1 - Added the ability to change the colours of the report. # Version 4.0 - HTML Tidy up, comments added for each item and the ability to enable/disable comments. # Version 3.9 - Adjusted log checking to include ESXi Logs # Version 3.8 - Added ESXi check for unsupported mode enabled # Version 3.7 - Added ESXi check for Lockdown Mode Enabled # Version 3.6 - Added VM Memory Swap and Ballooning # Version 3.5 - Added Host Overcommit check # Version 3.4 - Added Guest Disk check for space (MB) # Version 3.3 - Added Size of snapshots # Version 3.2 - Fixed Slot size information issue # Version 3.1 - Added VMs with High CPU Usage # Version 3.0 - Added VMs in mis-matched Folder names # Version 2.9 - Added counts to each titlebar and output to screen whilst running for interactive mode # Version 2.8 - Changed VC Services to show only unexpected status # Version 2.7 - Added VMs with outdated Hardware - vSphere Only # Version 2.6 - Added Slot size check - vSphere Only # version 2.5 - Added report on Hosts in a HA cluster where the swapfile location is set, check the hosts # Version 2.4 - Added VM/Host/Cluster Alerts # Version 2.3 - Added VMs with over x amount of vCPUs # Version 2.2 - Added Dead SCSILuns # Version 2.1 - Now checks for VMs stored on storage available to only one host rather than local storage # Version 2.0 - CPU Ready # Version 1.17 - vmkernel host log file check for warnings # Version 1.16 - NTP Server and service check # Version 1.15 - DRSMigrations & Local Stored VMs # Version 1.14 - Active/Inactive VMs # Version 1.13 - Bug Fixes # Version 1.12 - Added Hosts in Maintenance Mode and not responding + Bug Fixes # Version 1.11 - Simplified mail function. # Version 1.10 - Added How many days old the snapshots are # Version 1.9 - Added ability to change user account which makes the WMI calls # Version 1.8 - Added Real name resolution via AD and sorted disk space by PerfFree # Version 1.7 - Added Event Logs for VMware warnings and errors for past day # Version 1.6 - Add details to service state to see if it is expected or not # Version 1.5 - Check for objects to see if they exist before sending the email + add VMs with No VMTools # You can change the following defaults by altering the below settings: # # Set the SMTP Server address $SMTPSRV = "mysmtpserver.mydomain.local" # Set the Email address to recieve from $EmailFrom = "me@mydomain.local" # Set the Email address to send the email to $EmailTo = "me@mydomain.local" # Use the following item to define if the output should be displayed in the local browser once completed $DisplaytoScreen = $true # Use the following item to define if an email report should be sent once completed $SendEmail = $false # Use the following area to define the colours of the report $Colour1 = "CC0000" # Main Title - currently red $Colour2 = "7BA7C7" # Secondary Title - currently blue #### Detail Settings #### # Set the username of the account with permissions to access the VI Server # for event logs and service details - you will be asked for the same username and password # only the first time this runs after setting the below username. # If it is left blank it will use the credentials of the user who runs the script $SetUsername = "" # Set the location to store the credentials in a secure manner $CredFile = ".\mycred.crd" # Set if you would like to see the helpfull comments about areas of the checks $Comments = $true # Set the warning threshold for Datastore % Free Space $DatastoreSpace = "5" # Set the warning threshold for snapshots in days old $SnapshotAge = 14 # Set the number of days to show VMs created & removed for $VMsNewRemovedAge = 5 # Set the number of days of VC Events to check for errors $VCEventAge = 1 # Set the number of days of VC Event Logs to check for warnings and errors $VCEvntlgAge = 1 # Set the number of days of DRS Migrations to report and count on $DRSMigrateAge = 1 # Local Stored VMs, do not report on any VMs who are defined below $LVMDoNotInclude = "Template_*|VDI*" # VMs with CD/Floppy drives not to report on $CDFloppyConnectedOK = "APP*" # The NTP server to check $ntpserver = "pool.ntp.org" # vmkernel log file checks - set the number of days to check before today $vmkernelchk = 1 # CPU ready on VMs - To learn more read here: http://communities.vmware.com/docs/DOC-7390 $PercCPUReady = 10.0 # Change the next line to the maximum amount of vCPUs your VMs are allowed $vCpu = 2 # Number of slots available in a cluster $numslots = 10 # VM Cpu above x for the last x days $CPUValue = 75 $CPUDays = 2 # VM Disk space left, set the amount you would like to report on $MBFree = 10 # Max number of VMs per Datastore $NumVMsPerDatastore = 5 # HA VM reset day(s) number $HAVMresetold = 1 # HA VM restart day(s) number $HAVMrestartold = 1 # VMHost/VMFS quota $VMHostVMFSQuota = 28 # Datastore OverAllocation % $OverAllocation = 100 # vSwitch Port Left $vSwitchLeft = 5 # This section can be used to turn off certain areas of the report which may not be relevent to your installation # Set them to $False if you do not want them in your output. # General Summary Info $ShowGenSum = $true # Snapshot Information $ShowSnap = $true # Datastore Information $Showdata = $true # Hosts in Maintenance mode $ShowMaint = $true # Hosts not responding or Disconnected $ShowResDis = $true # Dead LunPath $ShowLunPath = $true # VMs Created or cloned $ShowCreated = $true # VMs vCPU $Showvcpu = $true # VMs Removed $ShowRemoved = $true # Host Swapfile datastores $ShowSwapFile = $true # DRS Migrations $ShowDRSMig = $true # Cluster Slot Sizes $ShowSlot = $true # VM Hardware Version $ShowHWVer = $true # VI Events $ShowVIevents = $true # VMs in inconsistent folders $ShowFolders = $true # VM Tools $Showtools = $true # Connected CDRoms $ShowCDRom = $true # ConnectedFloppy Drives $ShowFloppy = $true # NTP Issues $ShowNTP = $true # Single storage VMs $ShowSingle = $true # VM CPU Ready $ShowCPURDY = $true # Host Alarms $ShowHostAlarm = $true # VM Alarms $ShowVMAlarm = $true # Cluster Alarms $ShowCLUAlarm = $true # VC Service Details $ShowVCDetails = $true # VC Event Log Errors $ShowVCError = $true # VC Event Log Warnings $ShowVCWarn = $true # VMKernel Warning entries $ShowVMKernel = $true # Show VM CPU Usage $ShowVMCPU = $true # Show ESXi Tech Support mode $ShowTech = $true # Show ESXi Hosts which do not have lockdown mode enabled $Lockdown = $true # Show VMs disk space check $ShowGuestDisk = $true # Show Number of VMs per Datastore $ShowNumVMperDS = $true # Show Overcommit $ShowOvercommit = $true # Show Ballooning and Swapping for VMs $ShowSwapBal = $true # HA VM reset log $HAVMreset = $true # HA VM restart log $HAVMrestart = $true # Host ConfigIssue $ShowHostCIAlarm = $true # Map Disk Region Events (http://kb.vmware.com/kb/1007331) $ShowMapDiskRegionEvents = $true # Capacity Info $ShowCapacityInfo = $true # VMHost/VMFS Quota $VMHostVMFS = $true # Check inaccessible or invalid VM $ShowBlindedVM = $true # Check VMTools Issues $ShowtoolsIssues = $true # Check vSwitch Port Left $vSwitchCheck = $true ####################################### # Start of script # Turn off Errors $ErrorActionPreference = "silentlycontinue" if ($VISRV -eq ""){ Write-Host Write-Host "Please specify a VI Server name eg...." Write-Host " powershell.exe vCheck.ps1 MyvCenter" Write-Host Write-Host exit } function Write-CustomOut ($Details){ $LogDate = Get-Date -Format T Write-Host "$($LogDate) $Details" } function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) { $mailer = new-object Net.Mail.SMTPclient($smtpserver) $msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body) $msg.IsBodyHTML = $true $mailer.send($msg) } Function Get-CustomHTML ($Header){ $Report = @"
$Heading | $($Detail) |
---|