From 175aedfcfedffc34ae734b9b1085152028af5ce3 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Mon, 29 Aug 2016 14:05:45 +1000 Subject: [PATCH 01/50] Add VM filter Add standard VM filter --- ...irtual machines with less hard disks than partitions.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 b/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 index ce845c40..f18d75f0 100644 --- a/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 +++ b/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 @@ -1,7 +1,9 @@ # Start of Settings +# Do not report on any VMs who are defined here (regex) +$VMTDoNotInclude = "VM1_*|VM2_*" # End of Settings -$Result = @($FullVM | +$Result = @($FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | Where-Object {$_.Config.ManagedBy.ExtensionKey -ne 'com.vmware.vcDr'} | Select-Object -Property Name,@{N="NrOfHardDisks";E={($_.Layout.Disk|measure).count}},@{N="NrOfGuestDisks";E={($_.Guest.Disk|measure).count}},@{N="GuestFamily";E={$_.Guest.GuestFamily}} | Where-Object {$_.GuestFamily -eq "windowsGuest" -and $_.NrOfHardDisks -lt $_.NrOfGuestDisks} @@ -13,5 +15,5 @@ $Header = "Virtual machines with less hard disks than partitions : $(@($Result). $Comments = "Virtual machines with less hard disks than partitions. Probably they have more than one partition on a hard disk." $Display = "Table" $Author = "Robert van den Nieuwendijk" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" From e80eaaef290d5ef1e7829c2a9030a526b5223f1b Mon Sep 17 00:00:00 2001 From: David Seibel Date: Sat, 3 Sep 2016 21:38:52 -0400 Subject: [PATCH 02/50] Added HTML-based GUI configuration tool --- Styles/CleanGreen/Style.ps1 | 25 +- Styles/VMware/Style.ps1 | 23 +- vCheck.ps1 | 521 ++++++++++++++++++++++++------------ vCheckUtils.ps1 | 127 ++++++++- 4 files changed, 499 insertions(+), 197 deletions(-) diff --git a/Styles/CleanGreen/Style.ps1 b/Styles/CleanGreen/Style.ps1 index a06706a1..9185ac8b 100644 --- a/Styles/CleanGreen/Style.ps1 +++ b/Styles/CleanGreen/Style.ps1 @@ -11,9 +11,18 @@ $ChartSize = "200x200" Add-ReportResource "Header-vCheck" ($StylePath + "\Header.jpg") -Used $true # Hash table of key/value replacements -$StyleReplace = @{"_HEADER_" = ("'$reportHeader'"); - "_CONTENT_" = "Get-ReportContentHTML"; - "_TOC_" = "Get-ReportTOC"} +if ($GUIConfig) { + $StyleReplace = @{"_HEADER_" = ("'$reportHeader'"); + "_SCRIPT_" = "Get-ConfigScripts"; + "_CONTENT_" = "Get-ReportContentHTML"; + "_CONFIGEXPORT_" = ("'
'") + "_TOC_" = ("''")} +} else { + $StyleReplace = @{"_HEADER_" = ("'$reportHeader'"); + "_CONTENT_" = "Get-ReportContentHTML"; + "_CONFIGEXPORT_" = ("''") + "_TOC_" = "Get-ReportTOC"} +} #region Function Defniitions <# @@ -49,7 +58,7 @@ function Get-ReportContentHTML { function Get-PluginHTML { param ($PluginResult) - $FinalHTML = $PluginHTML -replace "_TITLE_", $PluginResult.Title + $FinalHTML = $PluginHTML -replace "_TITLE_", $PluginResult.Header $FinalHTML = $FinalHTML -replace "_COMMENTS_", $PluginResult.Comments $FinalHTML = $FinalHTML -replace "_PLUGINCONTENT_", $PluginResult.Details $FinalHTML = $FinalHTML -replace "_PLUGINID_", $PluginResult.PluginID @@ -104,11 +113,18 @@ $ReportHTML = @" font-family: Tahoma, sans-serif; font-size: 8pt; } + input { + float:right; + clear:both; + } .pluginContent td { padding: 5px; } .warning { background: #FFFBAA !important } .critical { background: #FFDDDD !important } + @@ -123,6 +139,7 @@ $ReportHTML = @"
_HEADER_
_TOC_
_CONTENT_ + _CONFIGEXPORT_
 
vCheck v$($vCheckVersion) by Alan Renouf generated on $($ENV:Computername) on $($Date.ToLongDateString()) at $($Date.ToLongTimeString())
diff --git a/Styles/VMware/Style.ps1 b/Styles/VMware/Style.ps1 index be2b120b..4c14e0b8 100644 --- a/Styles/VMware/Style.ps1 +++ b/Styles/VMware/Style.ps1 @@ -17,9 +17,18 @@ Add-ReportResource "Header-vCheck" ($StylePath + "\Header.jpg") -Used $true Add-ReportResource "Header-VMware" ($StylePath + "\Header-vmware.png") -Used $true # Hash table of key/value replacements -$StyleReplace = @{"_HEADER_" = ("'$reportHeader'"); - "_CONTENT_" = "Get-ReportContentHTML"; - "_TOC_" = "Get-ReportTOC"} +if ($GUIConfig) { + $StyleReplace = @{"_HEADER_" = ("'$reportHeader'"); + "_SCRIPT_" = "Get-ConfigScripts"; + "_CONTENT_" = "Get-ReportContentHTML"; + "_CONFIGEXPORT_" = ("'
'") + "_TOC_" = ("''")} +} else { + $StyleReplace = @{"_HEADER_" = ("'$reportHeader'"); + "_CONTENT_" = "Get-ReportContentHTML"; + "_CONFIGEXPORT_" = ("''") + "_TOC_" = "Get-ReportTOC"} +} #region Function Defniitions <# @@ -111,10 +120,17 @@ $ReportHTML = @" font-family: Tahoma, sans-serif; font-size: 8pt; } + input { + float:right; + clear:both; + } .pluginContent td { padding: 5px; } .warning { background: #FFFBAA !important } .critical { background: #FFDDDD !important } +
@@ -132,6 +148,7 @@ $ReportHTML = @"
_HEADER_
_TOC_
_CONTENT_ + _CONFIGEXPORT_
 
vCheck v$($vCheckVersion) by Alan Renouf generated on $($ENV:Computername) on $($Date.ToLongDateString()) at $($Date.ToLongTimeString())
diff --git a/vCheck.ps1 b/vCheck.ps1 index 203faa52..d19a5850 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -58,6 +58,8 @@ param ( [Switch]$config, + [Switch]$GUIConfig, + [ValidateScript({ Test-Path $_ -PathType 'Container' })] [string]$Outputpath=$Env:TEMP, @@ -85,6 +87,9 @@ $lang = DATA { setupMsg09 = Please complete the following questions or hit Enter to accept the current setting setupMsg10 = After completing this wizard the vCheck report will be displayed on the screen. setupMsg11 = + configMsg01 = After you have exported the new settings from the configuration interface, + configMsg02 = import the settings CSV file using Import-vCheckSettings -csvfile C:\\path\\to\\vCheckSettings.csv + configMsg03 = NOTE: If vCheckSettings.csv is stored in the vCheck folder, simply run Import-vCheckSettings resFileWarn = Image File not found for {0}! pluginInvalid = Plugin does not exist: {0} pluginpathInvalid = Plugin path "{0}" is invalid, defaulting to {1} @@ -239,6 +244,79 @@ Function Invoke-Settings { } # end Function Invoke-Settings +Function Invoke-HTMLSettings { + + <# + .DESCRIPTION + Run through settings for specified file, expects question on one line, and variable/value on following line. + Outputs settings to HTML file, which accepts input, and can create a configuration file. + .NOTES + Updated: 20160830 + Updated By: David Seibel + Update Notes: + - Initial creation + #> + + [CmdletBinding(PositionalBinding = $true)] + param ( + [parameter(Position = 0)] + $Filename, + [parameter(Position = 1)] + $GB + ) + + PROCESS { + + $file = Get-Content $filename + $OriginalLine = ($file | Select-String -Pattern "# Start of Settings").LineNumber + $EndLine = ($file | Select-String -Pattern "# End of Settings").LineNumber + + if (!(($OriginalLine + 1) -eq $EndLine)) { + + $Line = $OriginalLine + $PluginInfo = Get-PluginID $Filename + $PluginName = $PluginInfo.Title + + $htmlOutput = "" + If ($PluginName.EndsWith(".ps1", 1)) { + $PluginName = ($PluginName.split("\")[-1]).split(".")[0] + } # end if + + $htmlOutput += "" + + do { + $Question = $file[$Line] + $QuestionWithoutHash = $Question.Replace("# ", "") + $Line++ + $Split = ($file[$Line]).Split("=") + $Var = $Split[0].Trim() + if ($Split.count -gt 1) { + $CurSet = $Split[1].Trim() + # Check if the current setting is in speech marks + $String = $false + if ($CurSet -match '"') { + $String = $true + $CurSet = $CurSet.Replace('"', '').Trim() + } # end if + + $htmlOutput += "`n" + } + } Until ($Line -ge ($EndLine - 1)) + + $htmlOutput += "
$QuestionWithoutHash
" + $PluginConfig += New-Object PSObject -Property @{ + "Details" = $htmlOutput; + "Header" = $PluginName; + "PluginID" = $PluginName; + } + + return $PluginConfig + } # end if + + } # end PROCESS block + +} # end Function Invoke-HTMLSettings + <# Replace HTML Entities in string. Used to stop
tags from being mangled in tables #> function Format-HTMLEntities { param ([string]$content) @@ -615,6 +693,58 @@ function Get-ReportResource { } } + +function Get-ConfigScripts { + return "function createCSV() { + var inputs = document.getElementsByTagName('input'); + + var strsplit = null + //var output = 'filename,question,var\n' + var output = '\n' + for (var i = 0; i < inputs.length; i += 1) { + strsplit = inputs[i].name.split('|') + output += '\t\n' + output += '\t\t' + output += strsplit[0] + output += '\n' + output += '\t\t' + output += strsplit[1] + output += '\n' + output += '\t\t' + output += strsplit[2] + output += '\n' + output += '\t\t""' + output += inputs[i].value + output += '""\n' + output += '\t\n' + } + output += '' + downloadFile('vCheckSettings.xml', output) + } + function downloadFile(filename, rows) { + var fileContent = ''; + for (var i = 0; i < rows.length; i++) { + fileContent += rows[i]; + } + + var blob = new Blob([fileContent], { type: 'text/xml;charset=utf-8;' }); + if (navigator.msSaveBlob) { // IE 10+ + navigator.msSaveBlob(blob, filename); + } else { + var link = document.createElement('a'); + if (link.download !== undefined) { // feature detection + // Browsers that support HTML5 download attribute + var url = URL.createObjectURL(blob); + link.setAttribute('href', url); + link.setAttribute('download', filename); + link.style.visibility = 'hidden'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } + } + }" +} #endregion functions #region initialization @@ -687,19 +817,6 @@ $Setup = ($file | Select-String -Pattern '# Set the following to true to enable $SetupLine = $Setup++ $SetupSetting = Invoke-Expression (($file[$SetupLine]).Split("="))[1] -if ($SetupSetting -or $config) { - - Clear-Host - - ($lang.GetEnumerator() | Where-Object { $_.Name -match "setupMsg[0-9]*" } | Sort-Object Name) | ForEach-Object { - Write-Warning -Message "$($_.value)" - } - - Invoke-Settings -Filename $GlobalVariables -GB $true - Foreach ($plugin in $vCheckPlugins) { - Invoke-Settings -Filename $plugin.Fullname - } -} ## Include GlobalVariables and validate settings (at the moment just check they exist) . $GlobalVariables @@ -727,186 +844,234 @@ if (!(Test-Path ($StylePath))) { # Import the Style . ("$($StylePath)\Style.ps1") -#endregion initialization -#region scriptlogic -################################################################################ -# Script logic # -################################################################################ -# Start generating the report -$PluginResult = @() - -Write-Warning -Message $lang.pluginBegin - -# Loop over all enabled plugins -$p = 0 -$vCheckPlugins | Foreach { - $TableFormat = $null - $PluginInfo = Get-PluginID $_.Fullname - $p++ - Write-CustomOut ($lang.pluginStart -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) - $pluginStatus = ($lang.pluginStatus -f $p, $vCheckPlugins.count, $_.Name) - Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $pluginStatus -PercentComplete (100 * $p/($vCheckPlugins.count)) - $TTR = [math]::round((Measure-Command { $Details = @(. $_.FullName)}).TotalSeconds, 2) - - Write-CustomOut ($lang.pluginEnd -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) - # Do a replacement for [count] for number of items returned in $header - $Header = $Header -replace "\[count\]", $Details.count - - $PluginResult += New-Object PSObject -Property @{ - "Title" = $Title; - "Author" = $PluginInfo["Author"]; - "Version" = $PluginInfo["Version"]; - "Details" = $Details; - "Display" = $Display; - "TableFormat" = $TableFormat; - "Header" = $Header; - "Comments" = $Comments; - "TimeToRun" = $TTR; - } +if ($SetupSetting -or $config -or $GUIConfig) { + #Clear-Host + + ($lang.GetEnumerator() | Where-Object { $_.Name -match "setupMsg[0-9]*" } | Sort-Object Name) | ForEach-Object { + Write-Warning -Message "$($_.value)" + } + + if ($GUIConfig) { + $PluginResult = @() + + # Set the output filename + if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } + $Filename = ("{0}\{1}_vCheck-Config_{2}.html" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) + + #$configHTML = "" + #$configHTML += Invoke-HTMLSettings -Filename $GlobalVariables + $PluginResult += Invoke-HTMLSettings -Filename $GlobalVariables + Foreach ($plugin in $vCheckPlugins) { + #$configHTML += Invoke-HTMLSettings -Filename $plugin.Fullname + $PluginResult += Invoke-HTMLSettings -Filename $plugin.Fullname + } + + # Run Style replacement + $MyConfig = Get-ReportHTML + # Always generate the report with embedded images + $embedConfig = $MyConfig + # Loop over all CIDs and replace them + Foreach ($cid in $global:ReportResources.Keys) { + $embedConfig = $embedConfig -replace ("cid:{0}" -f $cid), (Get-ReportResource $cid -ReturnType "embed") + } + + $embedConfig | Out-File $Filename + Invoke-Item $Filename + ($lang.GetEnumerator() | Where-Object { $_.Name -match "configMsg[0-9]*" } | Sort-Object Name) | ForEach-Object { + Write-Warning -Message "$($_.value)" + } + + } elseif ($config) { + Invoke-Settings -Filename $GlobalVariables -GB $true + Foreach ($plugin in $vCheckPlugins) { + Invoke-Settings -Filename $plugin.Fullname + } + } } -Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $lang.Complete -Completed - -# Add report on plugins -if ($reportOnPlugins) { - $Comments = "Plugins in numerical order" - $Plugins = @() - foreach ($Plugin in (Get-ChildItem $PluginsFolder -Include *.ps1, *.ps1.disabled -Recurse)) { - $Plugins += New-Object PSObject -Property @{ - "Name" = (Get-PluginID $Plugin.FullName).Title; - "Enabled" = (($vCheckPlugins | Select -ExpandProperty FullName) -Contains $plugin.FullName) - } - } + +#endregion initialization +if (-not $GUIConfig) { + + #region scriptlogic + ################################################################################ + # Script logic # + ################################################################################ + # Start generating the report + $PluginResult = @() + + Write-Warning -Message $lang.pluginBegin + + # Loop over all enabled plugins + $p = 0 + $vCheckPlugins | Foreach { + $TableFormat = $null + $PluginInfo = Get-PluginID $_.Fullname + $p++ + Write-CustomOut ($lang.pluginStart -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) + $pluginStatus = ($lang.pluginStatus -f $p, $vCheckPlugins.count, $_.Name) + Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $pluginStatus -PercentComplete (100 * $p/($vCheckPlugins.count)) + $TTR = [math]::round((Measure-Command { $Details = @(. $_.FullName)}).TotalSeconds, 2) - if ($ListEnabledPluginsFirst) { - $Plugins = $Plugins | Sort -property @{ Expression = "Enabled"; Descending = $true } - $Comments = "Plugins in numerical order, enabled plugins listed first" - } + Write-CustomOut ($lang.pluginEnd -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) + # Do a replacement for [count] for number of items returned in $header + $Header = $Header -replace "\[count\]", $Details.count - $PluginResult += New-Object PSObject -Property @{ - "Title" = $lang.repPRTitle; - "Author" = "vCheck"; - "Version" = $vCheckVersion; - "Details" = $Plugins; - "Display" = "Table"; - "TableFormat" = $null; - "Header" = $lang.repPRTitle; - "Comments" = $Comments; - "TimeToRun" = 0; - } -} + $PluginResult += New-Object PSObject -Property @{ + "Title" = $Title; + "Author" = $PluginInfo["Author"]; + "Version" = $PluginInfo["Version"]; + "Details" = $Details; + "Display" = $Display; + "TableFormat" = $TableFormat; + "Header" = $Header; + "Comments" = $Comments; + "TimeToRun" = $TTR; + } + } + Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $lang.Complete -Completed -# Add Time to Run detail for plugins - if specified in GlobalVariables.ps1 -if ($TimeToRun) { - $Finished = Get-Date - $PluginResult += New-Object PSObject -Property @{ - "Title" = $lang.repTTRTitle; - "Author" = "vCheck"; - "Version" = $vCheckVersion; - "Details" = ($PluginResult | Where { $_.TimeToRun -gt $PluginSeconds } | Select Title, TimeToRun | Sort-Object TimeToRun -Descending); - "Display" = "List"; - "TableFormat" = $null; - "Header" = ($lang.repTime -f [math]::round(($Finished - $Date).TotalMinutes, 2), ($Finished.ToLongDateString()), ($Finished.ToLongTimeString())); - "Comments" = ($lang.slowPlugins -f $PluginSeconds); - "TimeToRun" = 0; - } -} + # Add report on plugins + if ($reportOnPlugins) { + $Comments = "Plugins in numerical order" + $Plugins = @() + foreach ($Plugin in (Get-ChildItem $PluginsFolder -Include *.ps1, *.ps1.disabled -Recurse)) { + $Plugins += New-Object PSObject -Property @{ + "Name" = (Get-PluginID $Plugin.FullName).Title; + "Enabled" = (($vCheckPlugins | Select -ExpandProperty FullName) -Contains $plugin.FullName) + } + } + + if ($ListEnabledPluginsFirst) { + $Plugins = $Plugins | Sort -property @{ Expression = "Enabled"; Descending = $true } + $Comments = "Plugins in numerical order, enabled plugins listed first" + } + + $PluginResult += New-Object PSObject -Property @{ + "Title" = $lang.repPRTitle; + "Author" = "vCheck"; + "Version" = $vCheckVersion; + "Details" = $Plugins; + "Display" = "Table"; + "TableFormat" = $null; + "Header" = $lang.repPRTitle; + "Comments" = $Comments; + "TimeToRun" = 0; + } + } -#endregion scriptlogic + # Add Time to Run detail for plugins - if specified in GlobalVariables.ps1 + if ($TimeToRun) { + $Finished = Get-Date + $PluginResult += New-Object PSObject -Property @{ + "Title" = $lang.repTTRTitle; + "Author" = "vCheck"; + "Version" = $vCheckVersion; + "Details" = ($PluginResult | Where { $_.TimeToRun -gt $PluginSeconds } | Select Title, TimeToRun | Sort-Object TimeToRun -Descending); + "Display" = "List"; + "TableFormat" = $null; + "Header" = ($lang.repTime -f [math]::round(($Finished - $Date).TotalMinutes, 2), ($Finished.ToLongDateString()), ($Finished.ToLongTimeString())); + "Comments" = ($lang.slowPlugins -f $PluginSeconds); + "TimeToRun" = 0; + } + } -#region output -################################################################################ -# Output # -################################################################################ -# Loop over plugin results and generate HTML from style -$emptyReport = $true -$p = 1 -Foreach ($pr in $PluginResult) { - If ($pr.Details) { - $emptyReport = $false - switch ($pr.Display) { - "List" { $pr.Details = Get-HTMLList $pr.Details } - "Table" { $pr.Details = Get-HTMLTable $pr.Details $pr.TableFormat } - "Chart" { $pr.Details = Get-HTMLChart "plugin$($p)" $pr.Details } - default { $pr.Details = $null } - } - $pr | Add-Member -Type NoteProperty -Name pluginID -Value "plugin-$p" - $p++ - } -} + #endregion scriptlogic -# Run Style replacement -$MyReport = Get-ReportHTML + #region output + ################################################################################ + # Output # + ################################################################################ + # Loop over plugin results and generate HTML from style + $emptyReport = $true + $p = 1 + Foreach ($pr in $PluginResult) { + If ($pr.Details) { + $emptyReport = $false + switch ($pr.Display) { + "List" { $pr.Details = Get-HTMLList $pr.Details } + "Table" { $pr.Details = Get-HTMLTable $pr.Details $pr.TableFormat } + "Chart" { $pr.Details = Get-HTMLChart "plugin$($p)" $pr.Details } + default { $pr.Details = $null } + } + $pr | Add-Member -Type NoteProperty -Name pluginID -Value "plugin-$p" + $p++ + } + } -# Set the output filename -if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } -$Filename = ("{0}\{1}_vCheck_{2}.htm" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) + # Run Style replacement + $MyReport = Get-ReportHTML -# Always generate the report with embedded images -$embedReport = $MyReport -# Loop over all CIDs and replace them -Foreach ($cid in $global:ReportResources.Keys) { - $embedReport = $embedReport -replace ("cid:{0}" -f $cid), (Get-ReportResource $cid -ReturnType "embed") -} -$embedReport | Out-File -encoding ASCII -filepath $Filename + # Set the output filename + if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } + $Filename = ("{0}\{1}_vCheck_{2}.htm" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) -# Display to screen -if ($DisplayToScreen -and (!($emptyReport -and !$DisplayReportEvenIfEmpty))) { - Write-CustomOut $lang.HTMLdisp - Invoke-Item $Filename -} + # Always generate the report with embedded images + $embedReport = $MyReport + # Loop over all CIDs and replace them + Foreach ($cid in $global:ReportResources.Keys) { + $embedReport = $embedReport -replace ("cid:{0}" -f $cid), (Get-ReportResource $cid -ReturnType "embed") + } + $embedReport | Out-File -encoding ASCII -filepath $Filename -# Generate email -if ($SendEmail -and (!($emptyReport -and !$EmailReportEvenIfEmpty))) { - Write-CustomOut $lang.emailSend - $msg = New-Object System.Net.Mail.MailMessage ($EmailFrom, $EmailTo) - # If CC address specified, add - If ($EmailCc -ne "") { - $msg.CC.Add($EmailCc) - } - $msg.subject = $EmailSubject + # Display to screen + if ($DisplayToScreen -and (!($emptyReport -and !$DisplayReportEvenIfEmpty))) { + Write-CustomOut $lang.HTMLdisp + Invoke-Item $Filename + } + + # Generate email + if ($SendEmail -and (!($emptyReport -and !$EmailReportEvenIfEmpty))) { + Write-CustomOut $lang.emailSend + $msg = New-Object System.Net.Mail.MailMessage ($EmailFrom, $EmailTo) + # If CC address specified, add + If ($EmailCc -ne "") { + $msg.CC.Add($EmailCc) + } + $msg.subject = $EmailSubject - # if send attachment, just send plaintext email with HTML report attached - If ($SendAttachment) { - $msg.Body = $lang.emailAtch - $attachment = new-object System.Net.Mail.Attachment $Filename - $msg.Attachments.Add($attachment) - } - # Otherwise send the HTML email - else { - $msg.IsBodyHtml = $true; - $html = [System.Net.Mail.AlternateView]::CreateAlternateViewFromString($MyReport, $null, 'text/html') - $msg.AlternateViews.Add($html) + # if send attachment, just send plaintext email with HTML report attached + If ($SendAttachment) { + $msg.Body = $lang.emailAtch + $attachment = new-object System.Net.Mail.Attachment $Filename + $msg.Attachments.Add($attachment) + } + # Otherwise send the HTML email + else { + $msg.IsBodyHtml = $true; + $html = [System.Net.Mail.AlternateView]::CreateAlternateViewFromString($MyReport, $null, 'text/html') + $msg.AlternateViews.Add($html) - # Loop over all CIDs and replace them - Foreach ($cid in $global:ReportResources.Keys) { - if ($global:ReportResources[$cid].Uses -gt 0) { - $lr = (Get-ReportResource $cid -ReturnType "linkedresource") - $html.LinkedResources.Add($lr); - } - } - } - # Send the email - $smtpClient = New-Object System.Net.Mail.SmtpClient + # Loop over all CIDs and replace them + Foreach ($cid in $global:ReportResources.Keys) { + if ($global:ReportResources[$cid].Uses -gt 0) { + $lr = (Get-ReportResource $cid -ReturnType "linkedresource") + $html.LinkedResources.Add($lr); + } + } + } + # Send the email + $smtpClient = New-Object System.Net.Mail.SmtpClient - # Find the VI Server and port from the global settings file - $smtpClient.Host = ($SMTPSRV -Split ":")[0] - if (($SMTPSRV -split ":")[1]) { - $smtpClient.Port = ($SMTPSRV -split ":")[1] - } + # Find the VI Server and port from the global settings file + $smtpClient.Host = ($SMTPSRV -Split ":")[0] + if (($SMTPSRV -split ":")[1]) { + $smtpClient.Port = ($SMTPSRV -split ":")[1] + } - if ($EmailSSL -eq $true) { - $smtpClient.EnableSsl = $true - } - $smtpClient.UseDefaultCredentials = $true; - $smtpClient.Send($msg) - If ($SendAttachment) { $attachment.Dispose() } - $msg.Dispose() -} + if ($EmailSSL -eq $true) { + $smtpClient.EnableSsl = $true + } + $smtpClient.UseDefaultCredentials = $true; + $smtpClient.Send($msg) + If ($SendAttachment) { $attachment.Dispose() } + $msg.Dispose() + } -# Run EndScript once everything else is complete -if (Test-Path ($ScriptPath + "\EndScript.ps1")) { - . ($ScriptPath + "\EndScript.ps1") -} + # Run EndScript once everything else is complete + if (Test-Path ($ScriptPath + "\EndScript.ps1")) { + . ($ScriptPath + "\EndScript.ps1") + } -#endregion output + #endregion output +} \ No newline at end of file diff --git a/vCheckUtils.ps1 b/vCheckUtils.ps1 index 76c2ac29..62617dd2 100644 --- a/vCheckUtils.ps1 +++ b/vCheckUtils.ps1 @@ -223,11 +223,11 @@ function Add-vCheckPlugin $filename = [System.Web.HttpUtility]::UrlDecode($filename) try { - Write-Host "Downloading File..." + Write-Warning "Downloading File..." $webClient = new-object system.net.webclient $webClient.DownloadFile($pluginObject.location,"$vCheckPath\Plugins\$filename") - Write-Host -ForegroundColor green "The plugin `"$($pluginObject.name)`" has been installed to $vCheckPath\Plugins\$filename" - Write-Host -ForegroundColor green "Be sure to check the plugin for additional configuration options." + Write-Warning "The plugin `"$($pluginObject.name)`" has been installed to $vCheckPath\Plugins\$filename" + Write-Warning "Be sure to check the plugin for additional configuration options." } catch [System.Net.WebException] @@ -386,17 +386,18 @@ Function Get-PluginSettings { $Line = $OriginalLine do { $Question = $file[$Line] - $Line ++ - $Split= ($file[$Line]).Split("=") + $Line++ + $Split = ($file[$Line]).Split("=") $Var = $Split[0] $CurSet = $Split[1] $settings = @{} $settings.filename = $filename $settings.question = $Question + $settings.varname = $Var.Trim() $settings.var = $CurSet.Trim() $currentsetting = New-Object -TypeName PSObject -Prop $settings $psettings += $currentsetting - $Line ++ + $Line++ } Until ( $Line -ge ($EndLine -1) ) } $psettings @@ -430,19 +431,19 @@ Function Set-PluginSettings { $OriginalLine = ($file | Select-String -SimpleMatch "# Start of Settings").LineNumber $EndLine = ($file | Select-String -SimpleMatch "# End of Settings").LineNumber $PluginName = ($filename.split("\")[-1]).split(".")[0] - Write-Host "`nProcessing - $PluginName" -foreground $host.PrivateData.WarningForegroundColor -background $host.PrivateData.WarningBackgroundColor + Write-Warning "`nProcessing - $PluginName" if (!(($OriginalLine +1) -eq $EndLine)) { $Array = @() $Line = $OriginalLine do { - $Question = $file[$Line] + $Question = $file[$Line].Trim() $Found = $false $Line ++ $Split= ($file[$Line]).Split("=") - $Var = $Split[0] + $Var = $Split[0].Trim() $CurSet = $Split[1].Trim() Foreach ($setting in $settings) { - If ($question -eq $setting.question) { + If ($question -eq $setting.question.Trim()) { $NewSet = $setting.var $Found = $true } @@ -462,8 +463,16 @@ Function Set-PluginSettings { $NewSet = "`"$NewSet`"" } } + if ($NewSet -ne $CurSet) { + Write-Warning "Plugin setting changed:" + Write-Warning " Plugin: $PluginName" + Write-Warning " Question: $Question" + Write-Warning " Variable: $Var" + Write-Warning " Old Value: $CurSet" + Write-Warning " New Value: $NewSet" + } $Array += $Question - $Array += "$Var= $NewSet" + $Array += "$Var = $NewSet" $Line ++ } Until ( $Line -ge ($EndLine -1) ) $Array += "# End of Settings" @@ -517,6 +526,55 @@ Function Export-vCheckSettings { $Export | Select filename, question, var | Export-Csv -NoTypeInformation $outfile } + + + <# +.SYNOPSIS + Retrieves configured vCheck plugin settings and exports them to XML. + +.DESCRIPTION + Export-vCheckSettings will retrieve the settings from each plugin and export them to a XML file. + By default, the XML file will be created in the vCheck folder named vCheckSettings.xml. + You can also specify a custom path using -outfile. + Once the export has been created the settings can then be imported via Import-vCheckSettingsXML. + +.PARAMETER outfile + Full path to XML file + +.EXAMPLE + Export-vCheckSettings + Creates vCheckSettings.xml file in default location (vCheck folder) + +.EXAMPLE + Export-vCheckSettingsXML -outfile "E:\vCheck-vCenter01.xml" + Creates XML file in custom location E:\vCheck-vCenter01.xml + #> +Function Export-vCheckSettingsXML { + Param + ( + [Parameter(mandatory=$false)] [String]$outfile = "$vCheckPath\vCheckSettings.xml" + ) + + $Export = @() + $GlobalVariables = "$vCheckPath\GlobalVariables.ps1" + $Export = Get-PluginSettings -Filename $GlobalVariables + Foreach ($plugin in (Get-ChildItem -Path $vCheckPath\Plugins\* -Include *.ps1 -Recurse)) { + $Export += Get-PluginSettings -Filename $plugin.Fullname + } + + $xml = "`n" + foreach ($e in $Export) { + $xml += "`t`n" + $xml += "`t`t$($e.Filename)`n" + $xml += "`t`t$($e.Question)`n" + $xml += "`t`t$($e.VarName)`n" + $xml += "`t`t$($e.Var)`n" + $xml += "`t`n" + } + $xml += "" + $xml | Out-File -FilePath $outfile -Encoding utf8 +} + <# .SYNOPSIS Retreives settings from CSV and applies them to vCheck. @@ -559,7 +617,52 @@ Function Import-vCheckSettings { $settings = $Import | Where {($_.filename).Split("\")[-1] -eq ($plugin.Fullname).Split("\")[-1]} Set-PluginSettings -Filename $plugin.Fullname -Settings $settings } - Write-Host "`nImport Complete!`n" -foreground $host.PrivateData.WarningForegroundColor -background $host.PrivateData.WarningBackgroundColor + Write-Warning "`nImport Complete!`n" +} + + <# +.SYNOPSIS + Retreives settings from XML and applies them to vCheck. + +.DESCRIPTION + Import-vCheckSettingsXML will retrieve the settings exported via Export-vCheckSettingsXML, or via .\vCheck.ps1 -GUIConfig + and apply them to the current vCheck folder. + By default, the XML file is expected to be located in the vCheck folder named vCheckSettings.csv. + You can also specify a custom path using -xmlfile. + If the XML file is not found you will be asked to provide the path. + The Setup Wizard will be disabled. + You will be asked any questions not found in the export. This would occur for new settings introduced + enabling a quick update between versions. + +.PARAMETER csvfile + Full path to XML file + +.EXAMPLE + Import-vCheckSettingsXML + Imports settings from vCheckSettings.xml file in default location (vCheck folder) + +.EXAMPLE + Import-vCheckSettingsXML -xmlfile "E:\vCheck-vCenter01.xml" + Imports settings from XML file in custom location E:\vCheck-vCenter01.xml + #> +Function Import-vCheckSettingsXML { + Param + ( + [Parameter(mandatory=$false)] [String]$xmlFile = "$vCheckPath\vCheckSettings.xml" + ) + + If (!(Test-Path $xmlFile)) { + $xmlFile = Read-Host "Enter full path to settings XML file you want to import" + } + $Import = [xml](Get-Content $xmlFile) + $GlobalVariables = "$vCheckPath\GlobalVariables.ps1" + $settings = $Import.vCheck.Setting | Where {($_.filename).Split("\")[-1] -eq ($GlobalVariables).Split("\")[-1]} + Set-PluginSettings -Filename $GlobalVariables -Settings $settings -GB + Foreach ($plugin in (Get-ChildItem -Path "$vCheckPath\Plugins\" -Filter "*.ps1" -Recurse)) { + $settings = $Import.vCheck.Setting | Where {($_.filename).Split("\")[-1] -eq ($plugin.Fullname).Split("\")[-1]} + Set-PluginSettings -Filename $plugin.Fullname -Settings $settings + } + Write-Warning "`nImport Complete!`n" } Function Get-vCheckCommand { From c496679033de2dd5e4030658860cdc308f0806a2 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Tue, 6 Sep 2016 14:53:21 -0400 Subject: [PATCH 03/50] Feature: SchedulevCheck.ps1 can automate adding the Scheduled Job for vCheck. --- README.md | 6 ++++++ SchedulevCheck.ps1 | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 SchedulevCheck.ps1 diff --git a/README.md b/README.md index e8cb27ed..cf10aba0 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ |-----------------| |[About](#About)| |[Features](#Features)| +|[Installing](#Installing)| |[Enhancements](#Enhancements)| |[Release Notes](#ReleaseNotes)| |[Contributing](#Contributing)| @@ -89,6 +90,11 @@ The following items are included as part of the vCheck vSphere download, they ar - Inaccessible VMs - Much, Much more....... +# Installing +[*Back to top*](#Title) + +Copy the vCheck files to the desired location. Run the script `SchedulevChec.ps1` and answer the prompts to configure the scheduled job. + # Enhancements [*Back to top*](#Title) diff --git a/SchedulevCheck.ps1 b/SchedulevCheck.ps1 new file mode 100644 index 00000000..ce259965 --- /dev/null +++ b/SchedulevCheck.ps1 @@ -0,0 +1,9 @@ +$vCheckJobName = Read-Host -Prompt "Enter the name of the vCheck job to create" +$TriggerTime = Read-Host -Prompt "Enter the time $vCheckJobName should run at, in the format 'H:MM AM/PM' (e.g. '2:00 AM')" +$Location = Read-Host -Prompt "Enter the fully qualified location where the vCheck script resides" +$sb = [scriptblock]::Create($Location) + +$dailyTrigger = New-JobTrigger -Daily -At $TriggerTime +$option = New-ScheduledJobOption -StartIfOnBattery –StartIfIdle +Register-ScheduledJob -Name $vCheckJobName -Trigger $dailyTrigger -ScheduledJobOption $option ` + -ScriptBlock $sb From f2014ce986cf71b28ea59aa1615d600872839089 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Tue, 6 Sep 2016 21:59:53 -0400 Subject: [PATCH 04/50] Move the new function into vCheckUtils.ps1 --- README.md | 2 +- SchedulevCheck.ps1 | 9 --------- vCheckUtils.ps1 | 12 ++++++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) delete mode 100644 SchedulevCheck.ps1 diff --git a/README.md b/README.md index cf10aba0..dd1062e3 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ The following items are included as part of the vCheck vSphere download, they ar # Installing [*Back to top*](#Title) -Copy the vCheck files to the desired location. Run the script `SchedulevChec.ps1` and answer the prompts to configure the scheduled job. +Copy the vCheck files to the desired location. Run the script `vCheckUtils.ps1` and call the function `Schedule-vCheck`. Answer the prompts to configure the scheduled job. # Enhancements diff --git a/SchedulevCheck.ps1 b/SchedulevCheck.ps1 deleted file mode 100644 index ce259965..00000000 --- a/SchedulevCheck.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -$vCheckJobName = Read-Host -Prompt "Enter the name of the vCheck job to create" -$TriggerTime = Read-Host -Prompt "Enter the time $vCheckJobName should run at, in the format 'H:MM AM/PM' (e.g. '2:00 AM')" -$Location = Read-Host -Prompt "Enter the fully qualified location where the vCheck script resides" -$sb = [scriptblock]::Create($Location) - -$dailyTrigger = New-JobTrigger -Daily -At $TriggerTime -$option = New-ScheduledJobOption -StartIfOnBattery –StartIfIdle -Register-ScheduledJob -Name $vCheckJobName -Trigger $dailyTrigger -ScheduledJobOption $option ` - -ScriptBlock $sb diff --git a/vCheckUtils.ps1 b/vCheckUtils.ps1 index 76c2ac29..8d0095b2 100644 --- a/vCheckUtils.ps1 +++ b/vCheckUtils.ps1 @@ -568,6 +568,18 @@ Function Get-vCheckCommand { Get-vCheckCommand +function Schedule-vCheck { + $vCheckJobName = Read-Host -Prompt "Enter the name of the vCheck job to create" + $TriggerTime = Read-Host -Prompt "Enter the time $vCheckJobName should run at, in the format 'H:MM AM/PM' (e.g. '2:00 AM')" + $Location = Read-Host -Prompt "Enter the fully qualified location where the vCheck script resides" + $sb = [scriptblock]::Create($Location) + + $dailyTrigger = New-JobTrigger -Daily -At $TriggerTime + $option = New-ScheduledJobOption -StartIfOnBattery –StartIfIdle + Register-ScheduledJob -Name $vCheckJobName -Trigger $dailyTrigger -ScheduledJobOption $option ` + -ScriptBlock $sb +} + # Below is a set of functions to make upgrading a vCheck directory easier <# From 7088fb047460b9f9be6bceaae46173035ebce8de Mon Sep 17 00:00:00 2001 From: Sneddo Date: Mon, 12 Sep 2016 15:54:09 +1000 Subject: [PATCH 05/50] Handle multiple NTP servers Fix #486 --- Plugins/30 Host/31 NTP Name and Service.ps1 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Plugins/30 Host/31 NTP Name and Service.ps1 b/Plugins/30 Host/31 NTP Name and Service.ps1 index d3295121..e52b0968 100644 --- a/Plugins/30 Host/31 NTP Name and Service.ps1 +++ b/Plugins/30 Host/31 NTP Name and Service.ps1 @@ -1,15 +1,14 @@ # Start of Settings -# The NTP server which should be set on your hosts -$ntpserver = "pool.ntp.org|pool2.ntp.org" +# The NTP server which should be set on your hosts (comma-separated) +$ntpserver = "pool.ntp.org,pool2.ntp.org" # End of Settings -$Result = @($VMH | Where {$_.Connectionstate -ne "Disconnected"} | Select Name, @{N="NTPServer";E={$_ | Get-VMHostNtpServer}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -notmatch $ntpserver}) -$Result +@($VMH | Where {$_.Connectionstate -ne "Disconnected"} | Select Name, @{N="NTPServer";E={($_ | Get-VMHostNtpServer) -join ","}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver}) $Title = "NTP Name and Service" -$Header = "NTP Issues: $(@($Result).Count)" +$Header = "NTP Issues: [count]" $Comments = "The following hosts do not have the correct NTP settings and may cause issues if the time becomes far apart from the vCenter/Domain or other hosts" $Display = "Table" $Author = "Alan Renouf" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" From c0cb66a49b00859fd8c1e14447c5b0eddd14a65f Mon Sep 17 00:00:00 2001 From: Sneddo Date: Tue, 13 Sep 2016 09:53:44 +1000 Subject: [PATCH 06/50] Change to Get-VIEventPlus Change to Get-VIEventPlus, removed MaxSampleVIEvent variable. Removed Output, this will screw with the plugin content in the report. --- Plugins/70 Misc/108 SRM RPO Violations.ps1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Plugins/70 Misc/108 SRM RPO Violations.ps1 b/Plugins/70 Misc/108 SRM RPO Violations.ps1 index ca584ad7..dbf20bca 100644 --- a/Plugins/70 Misc/108 SRM RPO Violations.ps1 +++ b/Plugins/70 Misc/108 SRM RPO Violations.ps1 @@ -34,6 +34,7 @@ $ActiveViolationsOnly = $true ## 0.3 : Removed extra timing in output as this is displayed as part of Write-CustomOut ## 0.4 : Fixed a bug/typo while filtering results by duration of RPO violation. ($RPOviolationMin should have been $RPOviolationMins) ## 0.5 : Fixed a bug where filtering results by duration of RPO violation was not working. +## 0.6 : Change to Get-VIEventPlus, removed MaxSampleVIEvent variable. ## Begin code block obtained from: http://www.virtu-al.net/2013/06/14/reporting-on-rpo-violations-from-vsphere-replication/ # modified by Joel Gibson @@ -41,13 +42,13 @@ $VMs = $VM | Where { $_.name -match $VMNameRegex } $Results = @() Foreach ($RPOvm in $VMs) { - Write-CustomOut ".... Retrieving events for $($RPOvm.name)" - $Events = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Entity $RPOvm - Write-CustomOut ".... Filtering RPO events for $($RPOvm.name)" + + $Events = Get-VIEventPlus -Entity $RPOvm + $RPOEvents = $Events | where { $_.EventTypeID -match "rpo" } | Where { $_.Vm.Name -eq $RPOvm.Name } | Select EventTypeId, CreatedTime, FullFormattedMessage, @{Name="VMName";Expression={$_.Vm.Name}} | Sort CreatedTime if ($RPOEvents) { $Count = 0 - Write-CustomOut ".... Finding replication results for $($RPOvm.Name)" + do { $details = "" | Select VMName, ViolationStart, ViolationEnd, Mins if ($RPOEvents[$count].EventTypeID -match "Violated") { @@ -110,5 +111,5 @@ $Header = "Site Recovery Manager - RPO Violations: $(@($Results).count)" $Comments = "This is a customizable report of RPO violations found in the vCenter event log." $Display = "Table" $Author = "Joel Gibson, based on work by Alan Renouf" -$PluginVersion = 0.5 +$PluginVersion = 0.6 $PluginCategory = "vSphere" From 931f6b9801c6d2b11134255546c4f84b33f375f8 Mon Sep 17 00:00:00 2001 From: David Seibel Date: Fri, 16 Sep 2016 10:48:14 -0400 Subject: [PATCH 07/50] Fixed indents --- vCheck.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vCheck.ps1 b/vCheck.ps1 index d19a5850..2d9faaec 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -58,7 +58,7 @@ param ( [Switch]$config, - [Switch]$GUIConfig, + [Switch]$GUIConfig, [ValidateScript({ Test-Path $_ -PathType 'Container' })] [string]$Outputpath=$Env:TEMP, @@ -249,7 +249,7 @@ Function Invoke-HTMLSettings { <# .DESCRIPTION Run through settings for specified file, expects question on one line, and variable/value on following line. - Outputs settings to HTML file, which accepts input, and can create a configuration file. + Outputs settings to HTML file, which accepts input, and can create a configuration file. .NOTES Updated: 20160830 Updated By: David Seibel From fe3598390d8d9ef66c895612cd09fcf5332fb3da Mon Sep 17 00:00:00 2001 From: David Seibel Date: Fri, 16 Sep 2016 11:05:02 -0400 Subject: [PATCH 08/50] Fixed more indents --- vCheck.ps1 | 592 ++++++++++++++++++++++++++--------------------------- 1 file changed, 296 insertions(+), 296 deletions(-) diff --git a/vCheck.ps1 b/vCheck.ps1 index 2d9faaec..acaa62ae 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -274,43 +274,43 @@ Function Invoke-HTMLSettings { if (!(($OriginalLine + 1) -eq $EndLine)) { $Line = $OriginalLine - $PluginInfo = Get-PluginID $Filename + $PluginInfo = Get-PluginID $Filename $PluginName = $PluginInfo.Title - $htmlOutput = "" + $htmlOutput = "" If ($PluginName.EndsWith(".ps1", 1)) { $PluginName = ($PluginName.split("\")[-1]).split(".")[0] } # end if - $htmlOutput += "
" + $htmlOutput += "
" do { $Question = $file[$Line] - $QuestionWithoutHash = $Question.Replace("# ", "") + $QuestionWithoutHash = $Question.Replace("# ", "") $Line++ $Split = ($file[$Line]).Split("=") $Var = $Split[0].Trim() - if ($Split.count -gt 1) { - $CurSet = $Split[1].Trim() - # Check if the current setting is in speech marks - $String = $false - if ($CurSet -match '"') { - $String = $true - $CurSet = $CurSet.Replace('"', '').Trim() - } # end if - - $htmlOutput += "`n" - } + if ($Split.count -gt 1) { + $CurSet = $Split[1].Trim() + # Check if the current setting is in speech marks + $String = $false + if ($CurSet -match '"') { + $String = $true + $CurSet = $CurSet.Replace('"', '').Trim() + } # end if + + $htmlOutput += "`n" + } } Until ($Line -ge ($EndLine - 1)) - $htmlOutput += "
$QuestionWithoutHash
$QuestionWithoutHash
" - $PluginConfig += New-Object PSObject -Property @{ - "Details" = $htmlOutput; - "Header" = $PluginName; - "PluginID" = $PluginName; - } - - return $PluginConfig + $htmlOutput += "" + $PluginConfig += New-Object PSObject -Property @{ + "Details" = $htmlOutput; + "Header" = $PluginName; + "PluginID" = $PluginName; + } + + return $PluginConfig } # end if } # end PROCESS block @@ -355,13 +355,13 @@ Function Get-HTMLTable { # Current cell has a rule, test to see if they are valid foreach ($rule in $FormatRules[$XMLTable.table.tr[0].th[$ColN]]) { if ($XMLTable.table.tr[$RowN].td[$ColN]."#text") - { - $value = $XMLTable.table.tr[$RowN].td[$ColN]."#text" - } - else - { - $value = $XMLTable.table.tr[$RowN].td[$ColN] - } + { + $value = $XMLTable.table.tr[$RowN].td[$ColN]."#text" + } + else + { + $value = $XMLTable.table.tr[$RowN].td[$ColN] + } if ($value -notmatch "^[0-9.]+$") { $value = """$value""" } @@ -695,55 +695,55 @@ function Get-ReportResource { function Get-ConfigScripts { - return "function createCSV() { - var inputs = document.getElementsByTagName('input'); - - var strsplit = null - //var output = 'filename,question,var\n' - var output = '\n' - for (var i = 0; i < inputs.length; i += 1) { - strsplit = inputs[i].name.split('|') - output += '\t\n' - output += '\t\t' - output += strsplit[0] - output += '\n' - output += '\t\t' - output += strsplit[1] - output += '\n' - output += '\t\t' - output += strsplit[2] - output += '\n' - output += '\t\t""' - output += inputs[i].value - output += '""\n' - output += '\t\n' - } - output += '' - downloadFile('vCheckSettings.xml', output) - } - function downloadFile(filename, rows) { - var fileContent = ''; - for (var i = 0; i < rows.length; i++) { - fileContent += rows[i]; - } - - var blob = new Blob([fileContent], { type: 'text/xml;charset=utf-8;' }); - if (navigator.msSaveBlob) { // IE 10+ - navigator.msSaveBlob(blob, filename); - } else { - var link = document.createElement('a'); - if (link.download !== undefined) { // feature detection - // Browsers that support HTML5 download attribute - var url = URL.createObjectURL(blob); - link.setAttribute('href', url); - link.setAttribute('download', filename); - link.style.visibility = 'hidden'; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - } - } - }" + return "function createCSV() { + var inputs = document.getElementsByTagName('input'); + + var strsplit = null + //var output = 'filename,question,var\n' + var output = '\n' + for (var i = 0; i < inputs.length; i += 1) { + strsplit = inputs[i].name.split('|') + output += '\t\n' + output += '\t\t' + output += strsplit[0] + output += '\n' + output += '\t\t' + output += strsplit[1] + output += '\n' + output += '\t\t' + output += strsplit[2] + output += '\n' + output += '\t\t""' + output += inputs[i].value + output += '""\n' + output += '\t\n' + } + output += '' + downloadFile('vCheckSettings.xml', output) + } + function downloadFile(filename, rows) { + var fileContent = ''; + for (var i = 0; i < rows.length; i++) { + fileContent += rows[i]; + } + + var blob = new Blob([fileContent], { type: 'text/xml;charset=utf-8;' }); + if (navigator.msSaveBlob) { // IE 10+ + navigator.msSaveBlob(blob, filename); + } else { + var link = document.createElement('a'); + if (link.download !== undefined) { // feature detection + // Browsers that support HTML5 download attribute + var url = URL.createObjectURL(blob); + link.setAttribute('href', url); + link.setAttribute('download', filename); + link.style.visibility = 'hidden'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } + } + }" } #endregion functions @@ -852,226 +852,226 @@ if ($SetupSetting -or $config -or $GUIConfig) { Write-Warning -Message "$($_.value)" } - if ($GUIConfig) { - $PluginResult = @() - - # Set the output filename - if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } - $Filename = ("{0}\{1}_vCheck-Config_{2}.html" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) - - #$configHTML = "" - #$configHTML += Invoke-HTMLSettings -Filename $GlobalVariables - $PluginResult += Invoke-HTMLSettings -Filename $GlobalVariables - Foreach ($plugin in $vCheckPlugins) { - #$configHTML += Invoke-HTMLSettings -Filename $plugin.Fullname - $PluginResult += Invoke-HTMLSettings -Filename $plugin.Fullname - } - - # Run Style replacement - $MyConfig = Get-ReportHTML - # Always generate the report with embedded images - $embedConfig = $MyConfig - # Loop over all CIDs and replace them - Foreach ($cid in $global:ReportResources.Keys) { - $embedConfig = $embedConfig -replace ("cid:{0}" -f $cid), (Get-ReportResource $cid -ReturnType "embed") - } - - $embedConfig | Out-File $Filename - Invoke-Item $Filename - ($lang.GetEnumerator() | Where-Object { $_.Name -match "configMsg[0-9]*" } | Sort-Object Name) | ForEach-Object { - Write-Warning -Message "$($_.value)" - } - - } elseif ($config) { - Invoke-Settings -Filename $GlobalVariables -GB $true - Foreach ($plugin in $vCheckPlugins) { - Invoke-Settings -Filename $plugin.Fullname - } - } + if ($GUIConfig) { + $PluginResult = @() + + # Set the output filename + if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } + $Filename = ("{0}\{1}_vCheck-Config_{2}.html" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) + + #$configHTML = "
" + #$configHTML += Invoke-HTMLSettings -Filename $GlobalVariables + $PluginResult += Invoke-HTMLSettings -Filename $GlobalVariables + Foreach ($plugin in $vCheckPlugins) { + #$configHTML += Invoke-HTMLSettings -Filename $plugin.Fullname + $PluginResult += Invoke-HTMLSettings -Filename $plugin.Fullname + } + + # Run Style replacement + $MyConfig = Get-ReportHTML + # Always generate the report with embedded images + $embedConfig = $MyConfig + # Loop over all CIDs and replace them + Foreach ($cid in $global:ReportResources.Keys) { + $embedConfig = $embedConfig -replace ("cid:{0}" -f $cid), (Get-ReportResource $cid -ReturnType "embed") + } + + $embedConfig | Out-File $Filename + Invoke-Item $Filename + ($lang.GetEnumerator() | Where-Object { $_.Name -match "configMsg[0-9]*" } | Sort-Object Name) | ForEach-Object { + Write-Warning -Message "$($_.value)" + } + + } elseif ($config) { + Invoke-Settings -Filename $GlobalVariables -GB $true + Foreach ($plugin in $vCheckPlugins) { + Invoke-Settings -Filename $plugin.Fullname + } + } } #endregion initialization if (-not $GUIConfig) { - #region scriptlogic - ################################################################################ - # Script logic # - ################################################################################ - # Start generating the report - $PluginResult = @() - - Write-Warning -Message $lang.pluginBegin - - # Loop over all enabled plugins - $p = 0 - $vCheckPlugins | Foreach { - $TableFormat = $null - $PluginInfo = Get-PluginID $_.Fullname - $p++ - Write-CustomOut ($lang.pluginStart -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) - $pluginStatus = ($lang.pluginStatus -f $p, $vCheckPlugins.count, $_.Name) - Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $pluginStatus -PercentComplete (100 * $p/($vCheckPlugins.count)) - $TTR = [math]::round((Measure-Command { $Details = @(. $_.FullName)}).TotalSeconds, 2) - - Write-CustomOut ($lang.pluginEnd -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) - # Do a replacement for [count] for number of items returned in $header - $Header = $Header -replace "\[count\]", $Details.count - - $PluginResult += New-Object PSObject -Property @{ - "Title" = $Title; - "Author" = $PluginInfo["Author"]; - "Version" = $PluginInfo["Version"]; - "Details" = $Details; - "Display" = $Display; - "TableFormat" = $TableFormat; - "Header" = $Header; - "Comments" = $Comments; - "TimeToRun" = $TTR; - } - } - Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $lang.Complete -Completed - - # Add report on plugins - if ($reportOnPlugins) { - $Comments = "Plugins in numerical order" - $Plugins = @() - foreach ($Plugin in (Get-ChildItem $PluginsFolder -Include *.ps1, *.ps1.disabled -Recurse)) { - $Plugins += New-Object PSObject -Property @{ - "Name" = (Get-PluginID $Plugin.FullName).Title; - "Enabled" = (($vCheckPlugins | Select -ExpandProperty FullName) -Contains $plugin.FullName) - } - } - - if ($ListEnabledPluginsFirst) { - $Plugins = $Plugins | Sort -property @{ Expression = "Enabled"; Descending = $true } - $Comments = "Plugins in numerical order, enabled plugins listed first" - } - - $PluginResult += New-Object PSObject -Property @{ - "Title" = $lang.repPRTitle; - "Author" = "vCheck"; - "Version" = $vCheckVersion; - "Details" = $Plugins; - "Display" = "Table"; - "TableFormat" = $null; - "Header" = $lang.repPRTitle; - "Comments" = $Comments; - "TimeToRun" = 0; - } - } - - # Add Time to Run detail for plugins - if specified in GlobalVariables.ps1 - if ($TimeToRun) { - $Finished = Get-Date - $PluginResult += New-Object PSObject -Property @{ - "Title" = $lang.repTTRTitle; - "Author" = "vCheck"; - "Version" = $vCheckVersion; - "Details" = ($PluginResult | Where { $_.TimeToRun -gt $PluginSeconds } | Select Title, TimeToRun | Sort-Object TimeToRun -Descending); - "Display" = "List"; - "TableFormat" = $null; - "Header" = ($lang.repTime -f [math]::round(($Finished - $Date).TotalMinutes, 2), ($Finished.ToLongDateString()), ($Finished.ToLongTimeString())); - "Comments" = ($lang.slowPlugins -f $PluginSeconds); - "TimeToRun" = 0; - } - } - - #endregion scriptlogic - - #region output - ################################################################################ - # Output # - ################################################################################ - # Loop over plugin results and generate HTML from style - $emptyReport = $true - $p = 1 - Foreach ($pr in $PluginResult) { - If ($pr.Details) { - $emptyReport = $false - switch ($pr.Display) { - "List" { $pr.Details = Get-HTMLList $pr.Details } - "Table" { $pr.Details = Get-HTMLTable $pr.Details $pr.TableFormat } - "Chart" { $pr.Details = Get-HTMLChart "plugin$($p)" $pr.Details } - default { $pr.Details = $null } - } - $pr | Add-Member -Type NoteProperty -Name pluginID -Value "plugin-$p" - $p++ - } - } - - # Run Style replacement - $MyReport = Get-ReportHTML - - # Set the output filename - if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } - $Filename = ("{0}\{1}_vCheck_{2}.htm" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) - - # Always generate the report with embedded images - $embedReport = $MyReport - # Loop over all CIDs and replace them - Foreach ($cid in $global:ReportResources.Keys) { - $embedReport = $embedReport -replace ("cid:{0}" -f $cid), (Get-ReportResource $cid -ReturnType "embed") - } - $embedReport | Out-File -encoding ASCII -filepath $Filename - - # Display to screen - if ($DisplayToScreen -and (!($emptyReport -and !$DisplayReportEvenIfEmpty))) { - Write-CustomOut $lang.HTMLdisp - Invoke-Item $Filename - } - - # Generate email - if ($SendEmail -and (!($emptyReport -and !$EmailReportEvenIfEmpty))) { - Write-CustomOut $lang.emailSend - $msg = New-Object System.Net.Mail.MailMessage ($EmailFrom, $EmailTo) - # If CC address specified, add - If ($EmailCc -ne "") { - $msg.CC.Add($EmailCc) - } - $msg.subject = $EmailSubject - - # if send attachment, just send plaintext email with HTML report attached - If ($SendAttachment) { - $msg.Body = $lang.emailAtch - $attachment = new-object System.Net.Mail.Attachment $Filename - $msg.Attachments.Add($attachment) - } - # Otherwise send the HTML email - else { - $msg.IsBodyHtml = $true; - $html = [System.Net.Mail.AlternateView]::CreateAlternateViewFromString($MyReport, $null, 'text/html') - $msg.AlternateViews.Add($html) - - # Loop over all CIDs and replace them - Foreach ($cid in $global:ReportResources.Keys) { - if ($global:ReportResources[$cid].Uses -gt 0) { - $lr = (Get-ReportResource $cid -ReturnType "linkedresource") - $html.LinkedResources.Add($lr); - } - } - } - # Send the email - $smtpClient = New-Object System.Net.Mail.SmtpClient - - # Find the VI Server and port from the global settings file - $smtpClient.Host = ($SMTPSRV -Split ":")[0] - if (($SMTPSRV -split ":")[1]) { - $smtpClient.Port = ($SMTPSRV -split ":")[1] - } - - if ($EmailSSL -eq $true) { - $smtpClient.EnableSsl = $true - } - $smtpClient.UseDefaultCredentials = $true; - $smtpClient.Send($msg) - If ($SendAttachment) { $attachment.Dispose() } - $msg.Dispose() - } - - # Run EndScript once everything else is complete - if (Test-Path ($ScriptPath + "\EndScript.ps1")) { - . ($ScriptPath + "\EndScript.ps1") - } - - #endregion output + #region scriptlogic + ################################################################################ + # Script logic # + ################################################################################ + # Start generating the report + $PluginResult = @() + + Write-Warning -Message $lang.pluginBegin + + # Loop over all enabled plugins + $p = 0 + $vCheckPlugins | Foreach { + $TableFormat = $null + $PluginInfo = Get-PluginID $_.Fullname + $p++ + Write-CustomOut ($lang.pluginStart -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) + $pluginStatus = ($lang.pluginStatus -f $p, $vCheckPlugins.count, $_.Name) + Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $pluginStatus -PercentComplete (100 * $p/($vCheckPlugins.count)) + $TTR = [math]::round((Measure-Command { $Details = @(. $_.FullName)}).TotalSeconds, 2) + + Write-CustomOut ($lang.pluginEnd -f $PluginInfo["Title"], $PluginInfo["Author"], $PluginInfo["Version"], $p, $vCheckPlugins.count) + # Do a replacement for [count] for number of items returned in $header + $Header = $Header -replace "\[count\]", $Details.count + + $PluginResult += New-Object PSObject -Property @{ + "Title" = $Title; + "Author" = $PluginInfo["Author"]; + "Version" = $PluginInfo["Version"]; + "Details" = $Details; + "Display" = $Display; + "TableFormat" = $TableFormat; + "Header" = $Header; + "Comments" = $Comments; + "TimeToRun" = $TTR; + } + } + Write-Progress -ID 1 -Activity $lang.pluginActivity -Status $lang.Complete -Completed + + # Add report on plugins + if ($reportOnPlugins) { + $Comments = "Plugins in numerical order" + $Plugins = @() + foreach ($Plugin in (Get-ChildItem $PluginsFolder -Include *.ps1, *.ps1.disabled -Recurse)) { + $Plugins += New-Object PSObject -Property @{ + "Name" = (Get-PluginID $Plugin.FullName).Title; + "Enabled" = (($vCheckPlugins | Select -ExpandProperty FullName) -Contains $plugin.FullName) + } + } + + if ($ListEnabledPluginsFirst) { + $Plugins = $Plugins | Sort -property @{ Expression = "Enabled"; Descending = $true } + $Comments = "Plugins in numerical order, enabled plugins listed first" + } + + $PluginResult += New-Object PSObject -Property @{ + "Title" = $lang.repPRTitle; + "Author" = "vCheck"; + "Version" = $vCheckVersion; + "Details" = $Plugins; + "Display" = "Table"; + "TableFormat" = $null; + "Header" = $lang.repPRTitle; + "Comments" = $Comments; + "TimeToRun" = 0; + } + } + + # Add Time to Run detail for plugins - if specified in GlobalVariables.ps1 + if ($TimeToRun) { + $Finished = Get-Date + $PluginResult += New-Object PSObject -Property @{ + "Title" = $lang.repTTRTitle; + "Author" = "vCheck"; + "Version" = $vCheckVersion; + "Details" = ($PluginResult | Where { $_.TimeToRun -gt $PluginSeconds } | Select Title, TimeToRun | Sort-Object TimeToRun -Descending); + "Display" = "List"; + "TableFormat" = $null; + "Header" = ($lang.repTime -f [math]::round(($Finished - $Date).TotalMinutes, 2), ($Finished.ToLongDateString()), ($Finished.ToLongTimeString())); + "Comments" = ($lang.slowPlugins -f $PluginSeconds); + "TimeToRun" = 0; + } + } + + #endregion scriptlogic + + #region output + ################################################################################ + # Output # + ################################################################################ + # Loop over plugin results and generate HTML from style + $emptyReport = $true + $p = 1 + Foreach ($pr in $PluginResult) { + If ($pr.Details) { + $emptyReport = $false + switch ($pr.Display) { + "List" { $pr.Details = Get-HTMLList $pr.Details } + "Table" { $pr.Details = Get-HTMLTable $pr.Details $pr.TableFormat } + "Chart" { $pr.Details = Get-HTMLChart "plugin$($p)" $pr.Details } + default { $pr.Details = $null } + } + $pr | Add-Member -Type NoteProperty -Name pluginID -Value "plugin-$p" + $p++ + } + } + + # Run Style replacement + $MyReport = Get-ReportHTML + + # Set the output filename + if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } + $Filename = ("{0}\{1}_vCheck_{2}.htm" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) + + # Always generate the report with embedded images + $embedReport = $MyReport + # Loop over all CIDs and replace them + Foreach ($cid in $global:ReportResources.Keys) { + $embedReport = $embedReport -replace ("cid:{0}" -f $cid), (Get-ReportResource $cid -ReturnType "embed") + } + $embedReport | Out-File -encoding ASCII -filepath $Filename + + # Display to screen + if ($DisplayToScreen -and (!($emptyReport -and !$DisplayReportEvenIfEmpty))) { + Write-CustomOut $lang.HTMLdisp + Invoke-Item $Filename + } + + # Generate email + if ($SendEmail -and (!($emptyReport -and !$EmailReportEvenIfEmpty))) { + Write-CustomOut $lang.emailSend + $msg = New-Object System.Net.Mail.MailMessage ($EmailFrom, $EmailTo) + # If CC address specified, add + If ($EmailCc -ne "") { + $msg.CC.Add($EmailCc) + } + $msg.subject = $EmailSubject + + # if send attachment, just send plaintext email with HTML report attached + If ($SendAttachment) { + $msg.Body = $lang.emailAtch + $attachment = new-object System.Net.Mail.Attachment $Filename + $msg.Attachments.Add($attachment) + } + # Otherwise send the HTML email + else { + $msg.IsBodyHtml = $true; + $html = [System.Net.Mail.AlternateView]::CreateAlternateViewFromString($MyReport, $null, 'text/html') + $msg.AlternateViews.Add($html) + + # Loop over all CIDs and replace them + Foreach ($cid in $global:ReportResources.Keys) { + if ($global:ReportResources[$cid].Uses -gt 0) { + $lr = (Get-ReportResource $cid -ReturnType "linkedresource") + $html.LinkedResources.Add($lr); + } + } + } + # Send the email + $smtpClient = New-Object System.Net.Mail.SmtpClient + + # Find the VI Server and port from the global settings file + $smtpClient.Host = ($SMTPSRV -Split ":")[0] + if (($SMTPSRV -split ":")[1]) { + $smtpClient.Port = ($SMTPSRV -split ":")[1] + } + + if ($EmailSSL -eq $true) { + $smtpClient.EnableSsl = $true + } + $smtpClient.UseDefaultCredentials = $true; + $smtpClient.Send($msg) + If ($SendAttachment) { $attachment.Dispose() } + $msg.Dispose() + } + + # Run EndScript once everything else is complete + if (Test-Path ($ScriptPath + "\EndScript.ps1")) { + . ($ScriptPath + "\EndScript.ps1") + } + + #endregion output } \ No newline at end of file From 33c5e3877efb03f1292e9deb82e69c4673aa5005 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Fri, 16 Sep 2016 19:09:45 -0400 Subject: [PATCH 09/50] Typo in Schedule-vCheck A missing hyphen caused the New-ScheduledJobOption call to fail. --- vCheckUtils.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vCheckUtils.ps1 b/vCheckUtils.ps1 index 8d0095b2..c6b48aa9 100644 --- a/vCheckUtils.ps1 +++ b/vCheckUtils.ps1 @@ -575,7 +575,7 @@ function Schedule-vCheck { $sb = [scriptblock]::Create($Location) $dailyTrigger = New-JobTrigger -Daily -At $TriggerTime - $option = New-ScheduledJobOption -StartIfOnBattery –StartIfIdle + $option = New-ScheduledJobOption -StartIfOnBattery -StartIfIdle Register-ScheduledJob -Name $vCheckJobName -Trigger $dailyTrigger -ScheduledJobOption $option ` -ScriptBlock $sb } @@ -785,13 +785,13 @@ Get-ChildItem (Get-ChildItem "$($vCheckDir)\Plugins").PsParentPath -Recurse | ? This is my process for upgrading vCheck with this function. 1. Extract a new, unmodified version of the vCheck to a directory. For this example "C:\Scripts\vCheck\vCheck-vSphere-master". 2. Load the utility - ". C:\Scripts\vCheck\vCheck-vSphere-master\vCheckUtils.ps1" . - 3. Upgrade-vCheckDirectory –CurrentvCheckPath C:\Scripts\vcheck\vcenterprod -NewvCheckSource C:\Scripts\vcheck6\vCheck-vSphere-master + 3. Upgrade-vCheckDirectory –CurrentvCheckPath C:\Scripts\vcheck\vcenterprod -NewvCheckSource C:\Scripts\vcheck6\vCheck-vSphere-master 4. The list of plugin variable values is automatically opened in Notepad. 5. Change directory to C:\Scripts\vcheck\vcenterprod . - 6. Run vCheck.ps1 . Input all the prompts for variable values with the ones in the file opened by Notepad. For the global variable “ $EmailFrom = "vcheck-vcenter@monster.com" ” I use my own email address until after I done a test run. Then I change it back to the group email address. + 6. Run vCheck.ps1 . Input all the prompts for variable values with the ones in the file opened by Notepad. For the global variable “ $EmailFrom = "vcheck-vcenter@monster.com" ” I use my own email address until after I done a test run. Then I change it back to the group email address. 7. After all the variable have been entered vCheck will run. 8. Review the PowerShell console for script errors and the vCheck email report for any problems. - 9. If there are not problems set the “EmailFrom” variable in “GlobalVariables.ps1” back to it’s original value. + 9. If there are not problems set the “EmailFrom” variable in “GlobalVariables.ps1” back to it’s original value. .LINK https://github.com/alanrenouf/vCheck-vSphere From 075401164166efa1db46abb94c5c4d9d53fec15e Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 22 Sep 2016 06:54:28 +1000 Subject: [PATCH 10/50] Remove $vm variable usage Fix #493 --- Plugins/60 VM/120 Multi-writer.ps1 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Plugins/60 VM/120 Multi-writer.ps1 b/Plugins/60 VM/120 Multi-writer.ps1 index b21dee58..ca0661f6 100644 --- a/Plugins/60 VM/120 Multi-writer.ps1 +++ b/Plugins/60 VM/120 Multi-writer.ps1 @@ -3,19 +3,20 @@ # Changelog ## 1.0 : Initial Version +## 1.1 : Change $VM variable to prevent clobbering # Multi-writer parameter -$Result = @(ForEach ($vm in $FullVM){ - $vm.Config.ExtraConfig | Where {$_.Key -like "scsi*sharing"} | - Select @{N="VM";E={$vm.Name}},Key,Value -}) -$Result +ForEach ($mwvm in $FullVM){ + $mwvm.Config.ExtraConfig | Where {$_.Key -like "scsi*sharing"} | + Select @{N="VM";E={$mwvm.Name}},Key,Value +} + $Title = "Multi-writer" -$Header = "Multi-writer: $(@($Result).Count)" +$Header = "[count] VMs with Multi-writer parameter" $Comments = "The following VMs have multi-writer parameter. A problem will occur in case of svMotion without reconfiguration of the applications which are using these virtual disks and also change of the VM configuration concerned. More information here." $Display = "Table" $Author = "Petar Enchev, Luc Dekens" -$PluginVersion = 1.0 +$PluginVersion = 1.1 $PluginCategory = "vSphere" From 63e251ccd372dbb96374cf4d94029bf8f41c678c Mon Sep 17 00:00:00 2001 From: Sneddo Date: Mon, 3 Oct 2016 07:36:31 +1100 Subject: [PATCH 11/50] Removed Stray ] --- Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 b/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 index fb00217a..eb18a5a3 100644 --- a/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 +++ b/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 @@ -5,7 +5,7 @@ $FullVM | Where {$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.Connect Select Name, @{Name="ConnectionState";e={$_.Runtime.ConnectionState}}, @{Name="PowerState";e={$_.Runtime.PowerState}}, @{Name="IP_Address";e={$_.Guest.IpAddress}} $Title = "Invalid or inaccessible VM" -$Header = "VM invalid or inaccessible: [count]]" +$Header = "VM invalid or inaccessible: [count]" $Comments = "The following VMs are marked as inaccessible or invalid" $Display = "Table" $Author = "Alan Renouf" From 4e8b39b238702a3a91a353389e73dd79a6878fbb Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 4 Oct 2016 11:33:00 +0300 Subject: [PATCH 12/50] Add img.shields.io badges --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index ab1907ab..fc47ef07 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ # vCheck Daily Report for vSphere +[![stars badge]][stars] +[![forks badge]][forks] +[![issues badge]][issues] + +[stars badge]:https://img.shields.io/github/stars/alanrenouf/vCheck-vSphere.svg +[forks badge]:https://img.shields.io/github/forks/alanrenouf/vCheck-vSphere.svg +[issues badge]:https://img.shields.io/github/issues/alanrenouf/vCheck-vSphere.svg + +[stars]:https://github.com/alanrenouf/vCheck-vSphere/stargazers +[forks]:https://github.com/alanrenouf/vCheck-vSphere/network +[issues]:https://github.com/alanrenouf/vCheck-vSphere/issues + [Join the VMware Code and #vCheck channel on slack and ask questions here!](https://code.vmware.com/slack/) ![Alt text](http://www.virtu-al.net/wp-content/uploads/2014/02/vCheck619.jpg "vCheck Sample") From 758b05a1a7281012e0e1a21e0ca4cd3a2011ee58 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 4 Oct 2016 11:35:00 +0300 Subject: [PATCH 13/50] Add MIT License --- LICENSE.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..a4f899c1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +# The MIT License (MIT) + +Copyright (c) 2016 Alan Renouf + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 1a8b08297b04191ab37e396c16dd0a3acb853184 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Wed, 5 Oct 2016 07:47:33 +1100 Subject: [PATCH 14/50] Updated ToC Fonts made more consistent, allow customisation of ToC Columns (default to 1 to keep the same look) --- Styles/VMware/Style.ps1 | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Styles/VMware/Style.ps1 b/Styles/VMware/Style.ps1 index be2b120b..c6ef3952 100644 --- a/Styles/VMware/Style.ps1 +++ b/Styles/VMware/Style.ps1 @@ -1,9 +1,11 @@ # Start of Settings # Show table of centents in report? $ShowTOC = $true +# Number of columns in table of contents +$ToCColumns = 1 # End of Settings -$StyleVersion = 1.3 +$StyleVersion = 1.4 # Define Chart Colours $ChartColours = @("377C2B", "0A77BA", "1D6325", "89CBE1") @@ -21,7 +23,7 @@ $StyleReplace = @{"_HEADER_" = ("'$reportHeader'"); "_CONTENT_" = "Get-ReportContentHTML"; "_TOC_" = "Get-ReportTOC"} -#region Function Defniitions +#region Function Definitions <# Get-ReportHTML - *REQUIRED* Returns the HTML for the report @@ -68,17 +70,26 @@ function Get-PluginHTML { Generate table of contents #> function Get-ReportTOC { - if ($ShowTOC) { - $TOCHTML = "
" + + $i = 0 + foreach ($pr in ($PluginResult | Where {$_.Details})) { + $TOCHTML += ("" -f $pr.PluginID, $pr.Title) + + $i++ + # We have hit the end of the line + if ($i%$ToCColumns -eq 0) { + $TOCHTML +="" } - $TOCHTML += "" - - return $TOCHTML } + # If the row is unfinished, need to pad it out with a cell + if ($i%$ToCColumns -gt 0) { + $TOCHTML += ("" -f ($ToCColumns-($i%$ToCColumns))) + } + + $TOCHTML += "
{1}
 
" + + return $TOCHTML } #endregion From ead7385ee32af8177bf8a729041b7f45d94782d6 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Fri, 7 Oct 2016 15:11:28 +1100 Subject: [PATCH 15/50] Replace Gitter/Waffle info with Slack We're no longer really using these services, we should promote Slack --- CONTRIBUTING.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0abc89b3..fa3cae52 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,11 +87,9 @@ We are in the process of adding/consolidating more detailed documentation around We are in the process of adding/consolidating more detailed documentation around this. In the meantime, you can review the documentation that we do have inside the [README.md](README.md) file for the repo. -## Gitter & Waffle +## Slack -We are using [![Join the chat at https://gitter.im/alanrenouf/vCheck-vSphere](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/alanrenouf/vCheck-vSphere?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) for general discussion around the vCheck utility. This is a good place for general questions or minor issues that someone might be able to answer, on the spot. If something cannot be resolved in the chat, it may warrant the submission of an Issue. - -We are also using Waffle.io to help track and resolve issues. You can visit the the dashboard [![Stories in Ready](http://badge.waffle.io/alanrenouf/vCheck-vSphere.png)](http://waffle.io/alanrenouf/vCheck-vSphere) to view or submit issues (you can also still use the GitHub web interface to submit/view issues). +To join in discussions or ask questions, join the #vCheck channel on [VMware Code Slack Team](https://code.vmware.com/slack/). ## Style guidelines From ac29e0010229c4d061811198e91bc93ecb6645ba Mon Sep 17 00:00:00 2001 From: Sneddo Date: Mon, 10 Oct 2016 15:44:59 +1100 Subject: [PATCH 16/50] Update to fix #478 Made sure $fileList is an array, so adding to it won't throw an error. Updated to use Write-Progress to provide feedback on long-running plugin. --- ...Find VMs in Uncontrolled Snapshot Mode.ps1 | 73 ++++++++++++------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 b/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 index 4fbdbc95..81789561 100644 --- a/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 +++ b/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 @@ -1,33 +1,52 @@ +$Title = "VMs in uncontrolled snapshot mode" +$Header = "VMs in uncontrolled snapshot mode: [count]" +$Comments = "The following VMs are in snapshot mode, but vCenter isn't aware of it. See http://kb.vmware.com/kb/1002310" +$Display = "Table" +$Author = "Rick Glover, Matthias Koehler, Dan Rowe" +$PluginVersion = 1.5 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings +# Setup plugin-specific language table +$pLang = DATA { + ConvertFrom-StringData @' + pluginActivity = Searching Datastores + pluginStatus = [{0} of {1}] {2} + Complete = Complete +'@ +} +# Override the default (en) if it exists in lang directory +Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLang -ErrorAction SilentlyContinue + $VMFolder = @() -foreach ($eachDS in $Datastores) { - $FilePath = $eachDS.DatastoreBrowserPath + '\*\*delta.vmdk*' - $fileList = Get-ChildItem -Path "$FilePath" | Select Name, FolderPath, FullName - $FilePath = $eachDS.DatastoreBrowserPath + '\*\-*-flat.vmdk' - $fileList += Get-ChildItem -Path "$FilePath" | Select Name, FolderPath, FullName +$i=0; +foreach ($eachDS in ($Datastores | Where {$_.Accessible})) { + Write-Progress -ID 2 -Parent 1 -Activity $pLang.pluginActivity -Status ($pLang.pluginStatus -f $i, $Datastores.count, $eachDS.Name) -PercentComplete ($i*100/$Datastores.count) + $eachDS.Name + $FilePath = $eachDS.DatastoreBrowserPath + '\*\*delta.vmdk*' + $fileList = @(Get-ChildItem -Path "$FilePath" | Select Name, FolderPath, FullName) + $FilePath = $eachDS.DatastoreBrowserPath + '\*\-*-flat.vmdk' + $fileList += Get-ChildItem -Path "$FilePath" | Select Name, FolderPath, FullName - foreach ($vmFile in $filelist | sort FolderPath) { - $vmFile.FolderPath -match '^\[([^\]]+)\] ([^/]+)' > $null - $VMName = $matches[2] - $eachVM = $FullVM | where {$_.Name -eq $VMName} - if (!$eachVM.snapshot) { # Only process VMs without snapshots - $Details = "" | Select-Object VM, Datacenter, Path - $Details.VM = $eachVM.Name - $Details.Datacenter = $eachDS.Datacenter - $Details.Path = $vmFile.FullName - $VMFolder += $Details - } - } + $i++ + + foreach ($vmFile in $filelist | sort FolderPath) + { + $vmFile.FolderPath -match '^\[([^\]]+)\] ([^/]+)' > $null + $VMName = $matches[2] + $eachVM = $FullVM | where {$_.Name -eq $VMName} + if (!$eachVM.snapshot) + { + # Only process VMs without snapshots + $Details = "" | Select-Object VM, Datacenter, Path + $Details.VM = $eachVM.Name + $Details.Datacenter = $eachDS.Datacenter + $Details.Path = $vmFile.FullName + $VMFolder += $Details + } + } } -$Results = $VMFolder | sort VM -$Results - -$Title = "VMs in uncontrolled snapshot mode" -$Header = "VMs in uncontrolled snapshot mode: $(@($Result).Count)" -$Comments = "The following VMs are in snapshot mode, but vCenter isn't aware of it. See http://kb.vmware.com/kb/1002310" -$Display = "Table" -$Author = "Rick Glover, Matthias Koehler, Dan Rowe" -$PluginVersion = 1.4 -$PluginCategory = "vSphere" +Write-Progress -ID 1 -Activity $pLang.pluginActivity -Status $pLang.Complete -Completed +$VMFolder | sort VM From 5716c7cee6e73e906da5eec24229533404752e9d Mon Sep 17 00:00:00 2001 From: Sneddo Date: Tue, 11 Oct 2016 08:12:53 +1100 Subject: [PATCH 17/50] Fix for VMs in vApp Fix #498 --- Plugins/60 VM/66 Misnamed VM.ps1 | 43 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Plugins/60 VM/66 Misnamed VM.ps1 b/Plugins/60 VM/66 Misnamed VM.ps1 index 8e0d8e31..2724808a 100644 --- a/Plugins/60 VM/66 Misnamed VM.ps1 +++ b/Plugins/60 VM/66 Misnamed VM.ps1 @@ -1,28 +1,35 @@ -# Start of Settings -# Misnamed VMs, do not report on any VMs who are defined here -$MNDoNotInclude = "VM1_*|VM2_*" -# End of Settings - -$misnamed = @() -foreach ($vmguest in ($FullVM | Where {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name })) { - $myObj = "" | select Cluster,Folder,VMName,GuestName - $myObj.Cluster = (Get-VMHost -Id ($vmguest.Runtime.Host.Type + "-" + $vmguest.Runtime.Host.Value)).Parent.Name - $myObj.Folder = (Get-Folder -Id ($vmguest.Parent.Type + "-" + $vmguest.Parent.Value)).Name - $myObj.VMName = $vmguest.name - $myObj.GuestName = $vmguest.Guest.HostName - $misnamed += $myObj -} - -$misnamed | Sort-Object Folder,VMName - $Title = "Mis-named virtual machines" -$Header = "Mis-named virtual machines" +$Header = "[count] Mis-named virtual machines" $Comments = "The following guest names do not match the name inside of the guest." $Display = "Table" $Author = "Frederic Martin" $PluginVersion = 1.2 $PluginCategory = "vSphere" +# Start of Settings +# Misnamed VMs, do not report on any VMs who are defined here +$MNDoNotInclude = "VM1_*|VM2_*" +# End of Settings + +($FullVM | Where {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name }) | + foreach { + $vmguest = $_ + if ($vmguest.Parent -ne $null) + { + $Parent = (Get-Folder -Id $vmguest.Parent.ToString()).Name; + } + else + { + $Parent = (Get-vApp -Id $vmguest.ParentVApp.ToString()).Name; + } + New-Object PSObject -Property @{ + Cluster = (Get-VMHost -Id $vmguest.Runtime.Host.ToString()).Parent.Name + Folder = $Parent + VMName = $vmguest.name + GuestName = $vmguest.Guest.HostName + } + } | Sort-Object Folder,VMName + <# 20141002 monahancj - Added filter to exclude powered off VMs. Because powered off VMs aren't running the VMtools to get the guest host name it report as null and then potentially a false positive for a name From 2151cbc44864e272185e5ee4b6716b2011892df3 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Wed, 12 Oct 2016 11:56:22 +1100 Subject: [PATCH 18/50] Update sample image Update image on vcheck.reports domain --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c3d29b8..4a464372 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [Join the VMware Code and #vCheck channel on slack and ask questions here!](https://code.vmware.com/slack/) -![Alt text](http://www.virtu-al.net/wp-content/uploads/2014/02/vCheck619.jpg "vCheck Sample") +![Alt text](https://vcheck.report/samples/vCheck-vSphere_Screenshot.PNG "vCheck Sample") |Navigation| |-----------------| From 5f49bfa5e97fdb97f3bec43d77c3d182ee2f00dd Mon Sep 17 00:00:00 2001 From: Sneddo <> Date: Wed, 12 Oct 2016 15:48:23 +1100 Subject: [PATCH 19/50] Added Get-vCheckSetting to vCheck. Started updating plugins to use this, as a first step to better handling of settings. Also cleaned up a lot of redundant code, so hopefully might help with some of the SSL issues with less objects being kept for no good reason. --- .../00 Connection Plugin for vCenter.ps1 | 217 +++++++++--------- .../00 Initialize/01 General Information.ps1 | 67 +++--- Plugins/10 vCenter/23 VI Events.ps1 | 18 +- Plugins/10 vCenter/41 vCenter Services.ps1 | 134 +++++------ Plugins/10 vCenter/47 vCenter Session Age.ps1 | 39 ++-- Plugins/10 vCenter/82 License Report.ps1 | 46 ++-- .../20 Cluster/10 HA Configuration Issues.ps1 | 25 +- .../104 Clusters with no Host Profile.ps1 | 16 +- Plugins/20 Cluster/15 HA VMs restarted.ps1 | 20 +- Plugins/20 Cluster/17 DRS Migrations.ps1 | 37 +-- Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 | 21 +- .../38 Cluster Configuration Issues.ps1 | 38 ++- .../20 Cluster/52 Datastore Consistency.ps1 | 35 +-- .../55 Clusters with DRS Disabled.ps1 | 28 +-- .../20 Cluster/70 Cluster Node Version.ps1 | 46 ++-- Plugins/20 Cluster/71 Capacity Planning.ps1 | 23 +- .../20 Cluster/72 s-vMotion Information.ps1 | 23 +- ... More RAM than free space on Datastore.ps1 | 25 +- Plugins/20 Cluster/75 DRS Rules.ps1 | 42 ++-- Plugins/30 Host/07 Hosts Overcommit State.ps1 | 79 ++++--- Plugins/30 Host/08 Hosts Dead LUN Path.ps1 | 38 ++- Plugins/30 Host/101 ESXi Inode Usage.ps1 | 32 +-- .../30 Host/105 Host Profile Compliance.ps1 | 22 +- .../110 Host Certificate Expiration Check.ps1 | 21 +- .../30 Host/16 Host Swapfile datastores.ps1 | 44 ++-- ...Xi with Technical Support mode enabled.ps1 | 17 +- ...hich do not have Lockdown mode enabled.ps1 | 16 +- Plugins/30 Host/31 NTP Name and Service.ps1 | 14 +- .../30 Host/35 Host Configuration Issues.ps1 | 36 +-- Plugins/30 Host/36 Host Alarms.ps1 | 18 +- Plugins/30 Host/44 VMKernel Warnings.ps1 | 111 ++++----- Plugins/30 Host/46 Missing ESX patches.ps1 | 36 ++- Plugins/30 Host/51 Syslog Name.ps1 | 19 +- .../53 Hardware status warnings-errors.ps1 | 77 +++---- .../30 Host/57 Hosts with reboot required.ps1 | 14 +- Plugins/30 Host/67 Host OS Pivot Table.ps1 | 12 +- Plugins/30 Host/68 Disk Max Total Latency.ps1 | 69 +++--- .../74 Host - Network Redundancy lost.ps1 | 22 +- .../75 Hosts with Different Hostnames.ps1 | 13 +- Plugins/30 Host/77 Lost Access to Volume.ps1 | 25 +- Plugins/30 Host/81 LUN Paths Check.ps1 | 72 +++--- ...Hosts not Connected or Alarms Disabled.ps1 | 13 +- Plugins/60 VM/66 Misnamed VM.ps1 | 46 ++-- vCheck.ps1 | 14 ++ 44 files changed, 921 insertions(+), 859 deletions(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index ef034da9..fb0610fb 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -1,6 +1,6 @@ $Title = "Connection settings for vCenter" $Author = "Alan Renouf" -$PluginVersion = 1.7 +$PluginVersion = 1.8 $Header = "Connection Settings" $Comments = "Connection Plugin for connecting to vSphere" $Display = "None" @@ -9,10 +9,11 @@ $PluginCategory = "vSphere" # Start of Settings # Please Specify the address (and optional port) of the vCenter server to connect to [servername(:port)] $Server = "192.168.0.0" -# Maximum number of samples to gather for events -$MaxSampleVIEvent = 100000 # End of Settings +# Update settings where there is an override +$Server = Get-vCheckSetting $Title "Server" $Server + # Setup plugin-specific language table $pLang = DATA { ConvertFrom-StringData @' @@ -52,22 +53,22 @@ $Credfile = $ScriptPath + "\Windowscreds.xml" # Adding PowerCLI core snapin, also check if powerCLI module is alsready added if (!(get-module -name VMware.VimAutomation.Core -erroraction silentlycontinue)) { - if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) { - add-pssnapin VMware.VimAutomation.Core -erroraction silentlycontinue - } + if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) { + add-pssnapin VMware.VimAutomation.Core -erroraction silentlycontinue + } } $OpenConnection = $global:DefaultVIServers | where { $_.Name -eq $VIServer } if($OpenConnection.IsConnected) { - Write-CustomOut ( "{0}: {1}" -f $pLang.connReuse, $Server ) - $VIConnection = $OpenConnection + Write-CustomOut ( "{0}: {1}" -f $pLang.connReuse, $Server ) + $VIConnection = $OpenConnection } else { - Write-CustomOut ( "{0}: {1}" -f $pLang.connOpen, $Server ) - $VIConnection = Connect-VIServer -Server $VIServer -Port $Port + Write-CustomOut ( "{0}: {1}" -f $pLang.connOpen, $Server ) + $VIConnection = Connect-VIServer -Server $VIServer -Port $Port } if (-not $VIConnection.IsConnected) { - Write-Error $pLang.connError + Write-Error $pLang.connError } Write-CustomOut $pLang.custAttr @@ -103,14 +104,14 @@ New-VIProperty -Name LastPoweredOffDate -ObjectType VirtualMachine -Value {(Get- New-VIProperty -Name LastPoweredOnDate -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOnDate -vm $Args[0]).LastPoweredOnDate} | Out-Null New-VIProperty -Name PercentFree -ObjectType Datastore -Value { - param($ds) - [math]::Round(((100 * ($ds.FreeSpaceMB)) / ($ds.CapacityMB)),2) + param($ds) + [math]::Round(((100 * ($ds.FreeSpaceMB)) / ($ds.CapacityMB)),2) } -Force | Out-Null New-VIProperty -Name "HWVersion" -ObjectType VirtualMachine -Value { - param($vm) + param($vm) - $vm.ExtensionData.Config.Version.Substring(4) + $vm.ExtensionData.Config.Version.Substring(4) } -BasedOnExtensionProperty "Config.Version" -Force | Out-Null Write-CustomOut $pLang.collectVM @@ -144,121 +145,121 @@ if ($ServiceInstance.Client.ServiceContent.About.OsType -eq "linux-x64"){ $VCSA # Check for vSphere If ($VIVersion -ge 4){ - $vSphere = $true + $vSphere = $true } if ($VIVersion -ge 5) { - Write-CustomOut $pLang.collectDDatastoreCluster - $DatastoreClustersView = Get-View -viewtype StoragePod + Write-CustomOut $pLang.collectDDatastoreCluster + $DatastoreClustersView = Get-View -viewtype StoragePod } <# .SYNOPSIS Returns vSphere events .DESCRIPTION The function will return vSphere events. With - the available parameters, the execution time can be - improved, compered to the original Get-VIEvent cmdlet. + the available parameters, the execution time can be + improved, compered to the original Get-VIEvent cmdlet. .NOTES Author: Luc Dekens .PARAMETER Entity - When specified the function returns events for the - specific vSphere entity. By default events for all - vSphere entities are returned. + When specified the function returns events for the + specific vSphere entity. By default events for all + vSphere entities are returned. .PARAMETER EventType - This parameter limits the returned events to those - specified on this parameter. + This parameter limits the returned events to those + specified on this parameter. .PARAMETER Start - The start date of the events to retrieve + The start date of the events to retrieve .PARAMETER Finish - The end date of the events to retrieve. + The end date of the events to retrieve. .PARAMETER Recurse - A switch indicating if the events for the children of - the Entity will also be returned + A switch indicating if the events for the children of + the Entity will also be returned .PARAMETER User - The list of usernames for which events will be returned + The list of usernames for which events will be returned .PARAMETER System - A switch that allows the selection of all system events. + A switch that allows the selection of all system events. .PARAMETER ScheduledTask - The name of a scheduled task for which the events - will be returned + The name of a scheduled task for which the events + will be returned .PARAMETER FullMessage - A switch indicating if the full message shall be compiled. - This switch can improve the execution speed if the full - message is not needed. + A switch indicating if the full message shall be compiled. + This switch can improve the execution speed if the full + message is not needed. .PARAMETER UseUTC - A switch indicating if the event shoukld remain in UTC or - local time. + A switch indicating if the event shoukld remain in UTC or + local time. .EXAMPLE - PS> Get-VIEventPlus -Entity $vm + PS> Get-VIEventPlus -Entity $vm .EXAMPLE - PS> Get-VIEventPlus -Entity $cluster -Recurse:$true + PS> Get-VIEventPlus -Entity $cluster -Recurse:$true #> function Get-VIEventPlus { - - param( - [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, - [string[]]$EventType, - [DateTime]$Start, - [DateTime]$Finish = (Get-Date), - [switch]$Recurse, - [string[]]$User, - [Switch]$System, - [string]$ScheduledTask, - [switch]$FullMessage = $false, - [switch]$UseUTC = $false - ) + + param( + [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, + [string[]]$EventType, + [DateTime]$Start, + [DateTime]$Finish = (Get-Date), + [switch]$Recurse, + [string[]]$User, + [Switch]$System, + [string]$ScheduledTask, + [switch]$FullMessage = $false, + [switch]$UseUTC = $false + ) - process { - $eventnumber = 100 - $events = @() - $eventMgr = Get-View EventManager - $eventFilter = New-Object VMware.Vim.EventFilterSpec - $eventFilter.disableFullMessage = ! $FullMessage - $eventFilter.entity = New-Object VMware.Vim.EventFilterSpecByEntity - $eventFilter.entity.recursion = &{if($Recurse){"all"}else{"self"}} - $eventFilter.eventTypeId = $EventType - if($Start -or $Finish){ - $eventFilter.time = New-Object VMware.Vim.EventFilterSpecByTime - if($Start){ - $eventFilter.time.beginTime = $Start - } - if($Finish){ - $eventFilter.time.endTime = $Finish - } - } - if($User -or $System){ - $eventFilter.UserName = New-Object VMware.Vim.EventFilterSpecByUsername - if($User){ - $eventFilter.UserName.userList = $User - } - if($System){ - $eventFilter.UserName.systemUser = $System - } - } - if($ScheduledTask){ - $si = Get-View ServiceInstance - $schTskMgr = Get-View $si.Content.ScheduledTaskManager - $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | - where {$_.Info.Name -match $ScheduledTask} | - Select -First 1 | - Select -ExpandProperty MoRef - } - if(!$Entity){ - $Entity = @(Get-Folder -NoRecursion) - } - $entity | %{ - $eventFilter.entity.entity = $_.ExtensionData.MoRef - $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter)) - $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) - while($eventsBuffer){ - $events += $eventsBuffer - $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) - } - $eventCollector.DestroyCollector() - } - if (-not $UseUTC) - { - $events | % { $_.createdTime = $_.createdTime.ToLocalTime() } - } - - $events - } + process { + $eventnumber = 100 + $events = @() + $eventMgr = Get-View EventManager + $eventFilter = New-Object VMware.Vim.EventFilterSpec + $eventFilter.disableFullMessage = ! $FullMessage + $eventFilter.entity = New-Object VMware.Vim.EventFilterSpecByEntity + $eventFilter.entity.recursion = &{if($Recurse){"all"}else{"self"}} + $eventFilter.eventTypeId = $EventType + if($Start -or $Finish){ + $eventFilter.time = New-Object VMware.Vim.EventFilterSpecByTime + if($Start){ + $eventFilter.time.beginTime = $Start + } + if($Finish){ + $eventFilter.time.endTime = $Finish + } + } + if($User -or $System){ + $eventFilter.UserName = New-Object VMware.Vim.EventFilterSpecByUsername + if($User){ + $eventFilter.UserName.userList = $User + } + if($System){ + $eventFilter.UserName.systemUser = $System + } + } + if($ScheduledTask){ + $si = Get-View ServiceInstance + $schTskMgr = Get-View $si.Content.ScheduledTaskManager + $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | + where {$_.Info.Name -match $ScheduledTask} | + Select -First 1 | + Select -ExpandProperty MoRef + } + if(!$Entity){ + $Entity = @(Get-Folder -NoRecursion) + } + $entity | %{ + $eventFilter.entity.entity = $_.ExtensionData.MoRef + $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter)) + $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) + while($eventsBuffer){ + $events += $eventsBuffer + $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) + } + $eventCollector.DestroyCollector() + } + if (-not $UseUTC) + { + $events | % { $_.createdTime = $_.createdTime.ToLocalTime() } + } + + $events + } } diff --git a/Plugins/00 Initialize/01 General Information.ps1 b/Plugins/00 Initialize/01 General Information.ps1 index cc14d78e..f0a7269f 100644 --- a/Plugins/00 Initialize/01 General Information.ps1 +++ b/Plugins/00 Initialize/01 General Information.ps1 @@ -1,3 +1,11 @@ +$Title = "General Information" +$Header = "General Information" +$Comments = "General details on the infrastructure" +$Display = "List" +$Author = "Alan Renouf, Frederic Martin" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days of DRS Migrations to report and count on $DRSMigrateAge = 1 @@ -5,54 +13,45 @@ $DRSMigrateAge = 1 $SDRSMigrateAge = 1 # End of Settings -# Changelog -## 1.1 : Adding some vSphere5 features (Storage Pod, StorageDRS migration) -## 1.2 : Generalised the DRS Event Log Queries for use here and Plugin 17, potentially more efficient if $DRSMigrateAge and $SDRSMigrateAge are equal +# Update settings where there is an override +$DRSMigrateAge = Get-vCheckSetting $Title "DRSMigrateAge" $DRSMigrateAge +$SDRSMigrateAge = Get-vCheckSetting $Title "SDRSMigrateAge" $SDRSMigrateAge -if ($DRSMigrateAge -eq $SDRSMigrateAge){ - $MigrationQuery1 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info +if ($DRSMigrateAge -eq $SDRSMigrateAge -or $VIVersion -lt 5){ + $MigrationQuery1 = Get-VIEventPlus -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info } - -else { - if ($VIVersion -ge 5) { - $MigrationQuery1 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info - $MigrationQuery2 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$SDRSMigrateAge) -Type Info - } - else { - $MigrationQuery1 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info - } +else +{ + $MigrationQuery1 = Get-VIEventPlus -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info + $MigrationQuery2 = Get-VIEventPlus -Start ($Date).AddDays(-$SDRSMigrateAge) -Type Info } $Info = New-Object -TypeName PSObject -Property @{ - "Number of Hosts" = (@($VMH).Count) - "Number of VMs" = (@($VM).Count) - "Number of Templates" = (@($VMTmpl).Count) - "Number of Clusters" = (@($Clusters).Count) - "Number of Datastores" = (@($Datastores).Count) - "Active VMs" = (@($FullVM | Where { $_.Runtime.PowerState -eq "poweredOn" }).Count) - "In-active VMs" = (@($FullVM | Where { $_.Runtime.PowerState -eq "poweredOff" }).Count) + "Number of Hosts" = (@($VMH).Count) + "Number of VMs" = (@($VM).Count) + "Number of Templates" = (@($VMTmpl).Count) + "Number of Clusters" = (@($Clusters).Count) + "Number of Datastores" = (@($Datastores).Count) + "Active VMs" = (@($FullVM | Where { $_.Runtime.PowerState -eq "poweredOn" }).Count) + "In-active VMs" = (@($FullVM | Where { $_.Runtime.PowerState -eq "poweredOff" }).Count) } # Don't display DRS line if 0 days are set if ($DRSMigrateAge -gt 0) { - $Info | Add-Member Noteproperty "DRS Migrations for last $($DRSMigrateAge) Days" (@($MigrationQuery1 | Where {$_.GetType().Name -eq "DrsVmMigratedEvent"}).Count) + $Info | Add-Member Noteproperty "DRS Migrations for last $($DRSMigrateAge) Days" (@($MigrationQuery1 | Where {$_.GetType().Name -eq "DrsVmMigratedEvent"}).Count) } # Adding vSphere 5 informations if ($VIVersion -ge 5) { - $Info | Add-Member Noteproperty "Number of Datastore Clusters" $(@($DatastoreClustersView).Count) - if (($MigrationQuery2) -and ($SDRSMigrateAge -gt 0)) { - $Info | Add-Member Noteproperty "Storage DRS Migrations for last $($SDRSMigrateAge) Days" (@($MigrationQuery2 | Where {$_.FullFormattedMessage -imatch "(Storage vMotion){1}.*(DRS){1}"}).Count) - } + $Info | Add-Member Noteproperty "Number of Datastore Clusters" $(@($DatastoreClustersView).Count) + if (($MigrationQuery2) -and ($SDRSMigrateAge -gt 0)) { + $Info | Add-Member Noteproperty "Storage DRS Migrations for last $($SDRSMigrateAge) Days" (@($MigrationQuery2 | Where {$_.FullFormattedMessage -imatch "(Storage vMotion){1}.*(DRS){1}"}).Count) + } } $Info -$Title = "General Information" -$Header = "General Information" -$Comments = "General details on the infrastructure" -$Display = "List" -$Author = "Alan Renouf, Frederic Martin" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" - +# Changelog +## 1.1 : Adding some vSphere5 features (Storage Pod, StorageDRS migration) +## 1.2 : Generalised the DRS Event Log Queries for use here and Plugin 17, potentially more efficient if $DRSMigrateAge and $SDRSMigrateAge are equal +## 1.3 : Add Get-vCheckSetting calls \ No newline at end of file diff --git a/Plugins/10 vCenter/23 VI Events.ps1 b/Plugins/10 vCenter/23 VI Events.ps1 index f7e9b11b..3c1ae955 100644 --- a/Plugins/10 vCenter/23 VI Events.ps1 +++ b/Plugins/10 vCenter/23 VI Events.ps1 @@ -1,13 +1,15 @@ -# Start of Settings -# End of Settings - -$Result = @(Get-VIEvent -maxsamples $MaxSampleVIEvent -Start ($Date).AddDays(-$VCEventAge ) -Types Error | Select @{N="Host";E={$_.host.name}}, createdTime, @{N="User";E={($_.userName.split("\"))[1]}}, fullFormattedMessage) -$Result - $Title = "Checking VI Events" -$Header = "Error Events (Last $VCEventAge Day(s)): $(@($Result).Count)" $Comments = "The following errors were logged in the vCenter Events tab, you may wish to investigate these" $Display = "Table" $Author = "Alan Renouf" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# Set the number of days of VC Events to check for errors +$VCEventAge = 1 +# End of Settings + +Get-VIEventPlus -Start ($Date).AddDays(-$VCEventAge ) -EventType Error | Select @{N="Host";E={$_.host.name}}, createdTime, @{N="User";E={($_.userName.split("\"))[1]}}, fullFormattedMessage + +$Header = ("Error Events (Last {0} Day(s)): [count]" -f $VCEventAge) \ No newline at end of file diff --git a/Plugins/10 vCenter/41 vCenter Services.ps1 b/Plugins/10 vCenter/41 vCenter Services.ps1 index 984a173a..067214db 100644 --- a/Plugins/10 vCenter/41 vCenter Services.ps1 +++ b/Plugins/10 vCenter/41 vCenter Services.ps1 @@ -2,78 +2,78 @@ # End of Settings If (! $VCSA) { - If (Test-Path $Credfile) { - $LoadedCredentials = Import-Clixml $Credfile - $creds = New-Object System.Management.Automation.PsCredential($LoadedCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString)) - $Services = get-wmiobject -Credential $creds win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue| Where {$_.DisplayName -like "VMware*" } - } Else { - $Services = get-wmiobject win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue | Where {$_.DisplayName -like "VMware*" } - if ($Error[0].Exception.Message -match "Access is denied.") { - # Access Denied Error found so asking to store windows credentials in a file for future use - Write-Host "Current windows credentials do not allow for access to WMI on the host $VIServer, please enter Administrator credentials for this check to work, these will be stored in an encrypted file: $credfile" - $Credential = Get-Credential - $Pass = $credential.Password | ConvertFrom-SecureString - $Username = $Credential.UserName - $Store = "" | Select Username, Password - $Store.Username = $Username - $Store.Password = $Pass - $Store | Export-Clixml $credfile - $Services = get-wmiobject win32_service -ComputerName $VIserver -ErrorAction SilentlyContinue | Where {$_.DisplayName -like "VMware*" } - } - } + If (Test-Path $Credfile) { + $LoadedCredentials = Import-Clixml $Credfile + $creds = New-Object System.Management.Automation.PsCredential($LoadedCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString)) + $Services = get-wmiobject -Credential $creds win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue| Where {$_.DisplayName -like "VMware*" } + } Else { + $Services = get-wmiobject win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue | Where {$_.DisplayName -like "VMware*" } + if ($Error[0].Exception.Message -match "Access is denied.") { + # Access Denied Error found so asking to store windows credentials in a file for future use + Write-Host "Current windows credentials do not allow for access to WMI on the host $VIServer, please enter Administrator credentials for this check to work, these will be stored in an encrypted file: $credfile" + $Credential = Get-Credential + $Pass = $credential.Password | ConvertFrom-SecureString + $Username = $Credential.UserName + $Store = "" | Select Username, Password + $Store.Username = $Username + $Store.Password = $Pass + $Store | Export-Clixml $credfile + $Services = get-wmiobject win32_service -ComputerName $VIserver -ErrorAction SilentlyContinue | Where {$_.DisplayName -like "VMware*" } + } + } - $myCol = @() - Foreach ($service in $Services){ - $MyDetails = "" | select-Object Name, State, StartMode, Health - If ($service.StartMode -eq "Auto") - { - if ($service.State -eq "Stopped") - { - $MyDetails.Name = $service.Displayname - $MyDetails.State = $service.State - $MyDetails.StartMode = $service.StartMode - $MyDetails.Health = "Unexpected State" - } - } - If ($service.StartMode -eq "Auto") - { - if ($service.State -eq "Running") - { - $MyDetails.Name = $service.Displayname - $MyDetails.State = $service.State - $MyDetails.StartMode = $service.StartMode - $MyDetails.Health = "OK" - } - } - If ($service.StartMode -eq "Disabled") - { - If ($service.State -eq "Running") - { - $MyDetails.Name = $service.Displayname - $MyDetails.State = $service.State - $MyDetails.StartMode = $service.StartMode - $MyDetails.Health = "Unexpected State" - } - } - If ($service.StartMode -eq "Disabled") - { - if ($service.State -eq "Stopped") - { - $MyDetails.Name = $service.Displayname - $MyDetails.State = $service.State - $MyDetails.StartMode = $service.StartMode - $MyDetails.Health = "OK" - } - } - $myCol += $MyDetails - } + $myCol = @() + Foreach ($service in $Services){ + $MyDetails = "" | select-Object Name, State, StartMode, Health + If ($service.StartMode -eq "Auto") + { + if ($service.State -eq "Stopped") + { + $MyDetails.Name = $service.Displayname + $MyDetails.State = $service.State + $MyDetails.StartMode = $service.StartMode + $MyDetails.Health = "Unexpected State" + } + } + If ($service.StartMode -eq "Auto") + { + if ($service.State -eq "Running") + { + $MyDetails.Name = $service.Displayname + $MyDetails.State = $service.State + $MyDetails.StartMode = $service.StartMode + $MyDetails.Health = "OK" + } + } + If ($service.StartMode -eq "Disabled") + { + If ($service.State -eq "Running") + { + $MyDetails.Name = $service.Displayname + $MyDetails.State = $service.State + $MyDetails.StartMode = $service.StartMode + $MyDetails.Health = "Unexpected State" + } + } + If ($service.StartMode -eq "Disabled") + { + if ($service.State -eq "Stopped") + { + $MyDetails.Name = $service.Displayname + $MyDetails.State = $service.State + $MyDetails.StartMode = $service.StartMode + $MyDetails.Health = "OK" + } + } + $myCol += $MyDetails + } - $Results = $MyCol | Where {$_.Name -ne $null -and $_.Health -ne "OK"} - $Results + $Results = $MyCol | Where {$_.Name -ne $null -and $_.Health -ne "OK"} + $Results } $Title = "VC Services" -$Header = "$VIServer Service Details: $(@($Results).Count)" +$Header = "$VIServer Service Details: [count]" $Comments = "The following vCenter Services are not in the required state" $Display = "Table" $Author = "Alan Renouf" diff --git a/Plugins/10 vCenter/47 vCenter Session Age.ps1 b/Plugins/10 vCenter/47 vCenter Session Age.ps1 index b727d706..7f77af48 100644 --- a/Plugins/10 vCenter/47 vCenter Session Age.ps1 +++ b/Plugins/10 vCenter/47 vCenter Session Age.ps1 @@ -1,3 +1,10 @@ +$Title = "vCenter Sessions Age" +$Header = "vCenter Sessions Age Report" +$Display = "Table" +$Author = "Rudolf Kleijwegt" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Enter maximum vCenter session length in hours $MaxvCenterSessionAge = 48 @@ -7,22 +14,22 @@ $MinvCenterSessionAge = 10 $vCenterSessionsDoNotInclude = "DOMAIN\\user1|DOMAIN\\user2" # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Modified the plug-in to not report active sessions, only report sessions that have been inactive for more than $MinvCenterSessionAge minutes +# Update settings where there is an override +$MaxvCenterSessionAge = Get-vCheckSetting $Title "MaxvCenterSessionAge" $MaxvCenterSessionAge +$MinvCenterSessionAge = Get-vCheckSetting $Title "MinvCenterSessionAge" $MinvCenterSessionAge +$vCenterSessionsDoNotInclude = Get-vCheckSetting $Title "vCenterSessionsDoNotInclude" $vCenterSessionsDoNotInclude -# Retreive vCenter sessions and report any sessions that exceed the maximum session age -$SessionManager = Get-View $ServiceInstance.Content.SessionManager -$SessionManager.SessionList | ` - Where {$_.LoginTime -lt (Get-Date).AddHours(-$MaxvCenterSessionAge) -AND ` - $_.UserName -notmatch $vCenterSessionsDoNotInclude} | ` - select LoginTime, UserName, FullName, @{N="IdleMinutes";e={([Math]::Round(((Get-Date)-($_.lastActiveTime).ToLocalTime()).TotalMinutes))}} | ` - Where {$_.IdleMinutes -ge $MinvCenterSessionAge} +# Retrieve vCenter sessions and report any sessions that exceed the maximum session age + +(Get-View $ServiceInstance.Content.SessionManager).SessionList | ` + Where {$_.LoginTime -lt (Get-Date).AddHours(-$MaxvCenterSessionAge) -AND ` + $_.UserName -notmatch $vCenterSessionsDoNotInclude} | ` + select LoginTime, UserName, FullName, @{N="IdleMinutes";e={([Math]::Round(((Get-Date)-($_.lastActiveTime).ToLocalTime()).TotalMinutes))}} | ` + Where {$_.IdleMinutes -ge $MinvCenterSessionAge} -$Title = "vCenter Sessions Age" -$Header = "vCenter Sessions Age Report" $Comments = "The following displays vCenter sessions that exceed the maximum session age ($MaxvCenterSessionAge Hour(s))." -$Display = "Table" -$Author = "Rudolf Kleijwegt" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" + +# Changelog +## 1.0 : Initial Release +## 1.1 : Modified the plug-in to not report active sessions, only report sessions that have been inactive for more than $MinvCenterSessionAge minutes +## 1.2 : Updated to use Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/10 vCenter/82 License Report.ps1 b/Plugins/10 vCenter/82 License Report.ps1 index 62e178d0..95d135f4 100644 --- a/Plugins/10 vCenter/82 License Report.ps1 +++ b/Plugins/10 vCenter/82 License Report.ps1 @@ -1,37 +1,23 @@ +$Title = "vCenter License Report" +$Header = "License Report" +$Comments = "The following displays licenses registered with this server and usage." +$Display = "Table" +$Author = "Justin Mercier" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings -# Enable License Reporting? -$licenseReport = $true # End of Settings -# Changelog -## 1.0 : Initial Release - -if ($licenseReport) { - $vSphereLicInfo = @() -$ServiceInstance = Get-View ServiceInstance -Foreach ($LicenseMan in Get-View ($ServiceInstance | Select -First 1).Content.LicenseManager) { - Foreach ($License in ($LicenseMan | Select -ExpandProperty Licenses)) { - $Details = "" |Select VC, Name, Key, Total, Used, ExpirationDate , Information - $Details.VC = ([Uri]$LicenseMan.Client.ServiceUrl).Host - $Details.Name= $License.Name - $Details.Key= $License.LicenseKey - $Details.Total= $License.Total - $Details.Used= $License.Used - $Details.Information= $License.Labels | Select -expand Value - $Details.ExpirationDate = $License.Properties | Where { $_.key -eq "expirationDate" } | Select -ExpandProperty Value - $vSphereLicInfo += $Details - } -} - -$vSphereLicInfo +Foreach ($LicenseMan in Get-View ($ServiceInstance | Select -First 1).Content.LicenseManager) +{ + ($LicenseMan | Select -ExpandProperty Licenses) | Select @{Name="VC";e={([Uri]$LicenseMan.Client.ServiceUrl).Host}}, ` + Name, LicenseKey, Total, Used, @{Name="Information";e={$_.Labels | Select -ExpandProperty Value}}, ` + @{"Name"="ExpirationDate";e={$_.Properties | Where { $_.key -eq "expirationDate" } | Select -ExpandProperty Value}} } -$Title = "vCenter License Report" -$Header = "License Report" -$Comments = "The following displays licenses registered with this server and usage." -$Display = "Table" -$Author = "Justin Mercier" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Release +## 1.1 : Code refactor \ No newline at end of file diff --git a/Plugins/20 Cluster/10 HA Configuration Issues.ps1 b/Plugins/20 Cluster/10 HA Configuration Issues.ps1 index bd78aad0..392e6d66 100644 --- a/Plugins/20 Cluster/10 HA Configuration Issues.ps1 +++ b/Plugins/20 Cluster/10 HA Configuration Issues.ps1 @@ -1,3 +1,11 @@ +$Title = "HA configuration issues" +$Header = "HA configuration issues: [count]" +$Comments = "The following clusters have HA configuration issues. This will impact your disaster recovery." +$Display = "Table" +$Author = "John Sneddon" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # HA Configuration Issues, do not report on any Clusters that are defined here $ClustersDoNotInclude = "Example_Cluster_*|Test_Cluster_*" @@ -9,6 +17,13 @@ $ClusterHAHostMonitoringShouldBeEnabled = $true $ClusterHAAdmissionControlShouldBeEnabled = $true # End of Settings +# Update settings where there is an override +$ClustersDoNotInclude = Get-vCheckSetting $Title "ClustersDoNotInclude" $ClustersDoNotInclude +$CLusterHAShouldBeEnabled = Get-vCheckSetting $CLusterHAShouldBeEnabled "vMotionAge" $CLusterHAShouldBeEnabled +$ClusterHAHostMonitoringShouldBeEnabled = Get-vCheckSetting $Title "ClusterHAHostMonitoringShouldBeEnabled" $ClusterHAHostMonitoringShouldBeEnabled +$ClusterHAAdmissionControlShouldBeEnabled = Get-vCheckSetting $Title "ClusterHAAdmissionControlShouldBeEnabled" $ClusterHAAdmissionControlShouldBeEnabled + + # Setup plugin-specific language table $pLang = DATA { ConvertFrom-StringData @' @@ -36,11 +51,5 @@ $HAIssues += $Clusters | Where-Object {$_.Name -notmatch $ClustersDoNotInclude - # Sort and return $HAIssues | Sort-Object Cluster - -$Title = "HA configuration issues" -$Header = "HA configuration issues: [count]" -$Comments = "The following clusters have HA configuration issues. This will impact your disaster recovery." -$Display = "Table" -$Author = "John Sneddon" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" + +Remove-Variable HAIssues, pLang \ No newline at end of file diff --git a/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 b/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 index 0d1015cd..5b48cf87 100644 --- a/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 +++ b/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 @@ -1,11 +1,3 @@ -# Start of Settings -# End of Settings - -# Get all host profiles and corresponding cluster ID (don't really care about individual hosts at this stage!) -$HostProfiles = Get-VMHostProfile | Select Name, @{Name="ClusterID";Expression={$_.ExtensionData.Entity | ?{ $_.type -eq "ClusterComputeResource" }}} - -$clusviews | ?{($HostProfiles | Select -expandProperty ClusterID) -notcontains $_.moref } | Sort-Object Name | Select Name - $Title = "Clusters Without Host Profile attached" $Header = "Clusters Without Host Profile attached" $Comments = "The following clusters do not have a host profile attached" @@ -13,3 +5,11 @@ $Display = "Table" $Author = "John Sneddon" $PluginVersion = 1.0 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +# Get all host profiles and corresponding cluster ID (don't really care about individual hosts at this stage!) +$HostProfiles = Get-VMHostProfile | Select Name, @{Name="ClusterID";Expression={$_.ExtensionData.Entity | ?{ $_.type -eq "ClusterComputeResource" }}} + +$clusviews | ?{($HostProfiles | Select -expandProperty ClusterID) -notcontains $_.moref } | Sort-Object Name | Select Name \ No newline at end of file diff --git a/Plugins/20 Cluster/15 HA VMs restarted.ps1 b/Plugins/20 Cluster/15 HA VMs restarted.ps1 index 2c06f834..081fe32a 100644 --- a/Plugins/20 Cluster/15 HA VMs restarted.ps1 +++ b/Plugins/20 Cluster/15 HA VMs restarted.ps1 @@ -1,14 +1,18 @@ +$Title = "HA VMs restarted" +$Comments = "The following VMs have been restarted by HA in the last $HAVMresetold days" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # HA VM restart day(s) number $HAVMrestartold = 5 # End of Settings -@(Get-VIEventPlus -EventType "com.vmware.vc.ha.VmRestartedByHAEvent" -Start (Get-Date).AddDays(-$HAVMrestartold) | Select-Object CreatedTime, FullFormattedMessage | Sort-Object CreatedTime -Descending) +# Update settings where there is an override +$HAVMrestartold = Get-vCheckSetting $Title "HAVMrestartold" $HAVMrestartold -$Title = "HA VMs restarted" -$Header = ("HA: VM restart (Last {0} Day(s)) : [count]" -f $HAVMrestartold) -$Comments = "The following VMs have been restarted by HA in the last $HAVMresetold days" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +@(Get-VIEventPlus -EventType "com.vmware.vc.ha.VmRestartedByHAEvent" -Start ($Date).AddDays(-$HAVMrestartold) | Select-Object CreatedTime, FullFormattedMessage | Sort-Object CreatedTime -Descending) + +$Header = ("HA: VM restart (Last {0} Day(s)) : [count]" -f $HAVMrestartold) \ No newline at end of file diff --git a/Plugins/20 Cluster/17 DRS Migrations.ps1 b/Plugins/20 Cluster/17 DRS Migrations.ps1 index 3b1df443..3a0a565b 100644 --- a/Plugins/20 Cluster/17 DRS Migrations.ps1 +++ b/Plugins/20 Cluster/17 DRS Migrations.ps1 @@ -1,3 +1,10 @@ +$Title = "DRS & SDRS Migrations" +$Comments = "Multiple DRS Migrations may be an indication of overloaded hosts, check resource levels of the cluster" +$Display = "Table" +$Author = "Alan Renouf, Jonathan Medd" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days of DRS Migrations to report and count on $DRSMigrateAge = 1 @@ -5,21 +12,23 @@ $DRSMigrateAge = 1 $SDRSMigrateAge = 1 # End of Settings -# Changelog -## 1.2 : Removed setting $DRSMigrateAge since already specified in Plugin 01. Also added Storage DRS info -## 1.3 : Added $MigrationQuery# section in case General Info plugin is disabled. Issue #285 +# Update settings where there is an override +$DRSMigrateAge = Get-vCheckSetting $Title "DRSMigrateAge" $DRSMigrateAge +$SDRSMigrateAge = Get-vCheckSetting $Title "SDRSMigrateAge" $SDRSMigrateAge -if (-not $MigrationQuery1) { - if ($DRSMigrateAge -eq $SDRSMigrateAge){ - $MigrationQuery1 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info +if (-not $MigrationQuery1) +{ + if ($DRSMigrateAge -eq $SDRSMigrateAge) + { + $MigrationQuery1 = Get-VIEventPlus -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info } else { if ($VIVersion -ge 5) { - $MigrationQuery1 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info - $MigrationQuery2 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$SDRSMigrateAge) -Type Info + $MigrationQuery1 = Get-VIEventPlus -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info + $MigrationQuery2 = Get-VIEventPlus -Start ($Date).AddDays(-$SDRSMigrateAge) -Type Info } else { - $MigrationQuery1 = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info + $MigrationQuery1 = Get-VIEventPlus -Start ($Date).AddDays(-$DRSMigrateAge) -Type Info } } } @@ -38,10 +47,8 @@ else { $HeaderText = "DRS Migrations (Last $DRSMigrateAge Day(s)) : $(@($DRSMigrations).count)" } -$Title = "DRS & SDRS Migrations" $Header = $HeaderText -$Comments = "Multiple DRS Migrations may be an indication of overloaded hosts, check resource levels of the cluster" -$Display = "Table" -$Author = "Alan Renouf, Jonathan Medd" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" + +# Changelog +## 1.2 : Removed setting $DRSMigrateAge since already specified in Plugin 01. Also added Storage DRS info +## 1.3 : Added $MigrationQuery# section in case General Info plugin is disabled. Issue #285 \ No newline at end of file diff --git a/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 b/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 index acd3ef97..423977aa 100644 --- a/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 +++ b/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 @@ -1,8 +1,19 @@ +$Title = "Cluster Slot Sizes" +$Header = "Clusters with less than $numslots Slot Sizes : [count]" +$Comments = "Available slots in the below cluster are less than is specified, this may cause issues with creating new VMs, for more information click here: Yellow-Bricks HA Deep Dive" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Number of slots available in a cluster $numslots = 10 # End of Settings +# Update settings where there is an override +$numslots = Get-vCheckSetting $Title "numslots" $numslots + If ($vSphere){ $SlotInfo = @() Foreach ($Cluster in ($Clusters)){ @@ -22,12 +33,4 @@ If ($vSphere){ $SlotCHK = @($SlotInfo | Where { $_.AvailableSlots -lt $numslots}) } -$SlotCHK - -$Title = "Cluster Slot Sizes" -$Header = "Clusters with less than $numslots Slot Sizes : $(@($SlotCHK).count)" -$Comments = "Slot sizes in the below cluster are less than is specified, this may cause issues with creating new VMs, for more information click here: Yellow-Bricks HA Deep Dive" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +$SlotCHK \ No newline at end of file diff --git a/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 b/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 index 3e6efbea..30279cbc 100644 --- a/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 +++ b/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 @@ -1,27 +1,25 @@ +$Title = "Cluster Configuration Issues" +$Header = "Cluster(s) Config Issue(s): [count]" +$Comments = "The following alarms have been registered against clusters in vCenter" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings $clualarms = @() foreach ($clusview in $clusviews) { - if ($clusview.ConfigIssue) { - $CluConfigIssues = $clusview.ConfigIssue - Foreach ($CluConfigIssue in $CluConfigIssues) { - $Details = "" | Select-Object Name, Message - $Details.name = $clusview.name - $Details.Message = $CluConfigIssue.FullFormattedMessage - $clualarms += $Details - } - } + if ($clusview.ConfigIssue) { + $CluConfigIssues = $clusview.ConfigIssue + Foreach ($CluConfigIssue in $CluConfigIssues) { + $Details = "" | Select-Object Name, Message + $Details.name = $clusview.name + $Details.Message = $CluConfigIssue.FullFormattedMessage + $clualarms += $Details + } + } } -$clualarms | sort name - -$Title = "Cluster Configuration Issues" -$Header = "Cluster(s) Config Issue(s): $(@($clualarms).Count)" -$Comments = "The following alarms have been registered against clusters in vCenter" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 - - -$PluginCategory = "vSphere" +$clualarms | sort name \ No newline at end of file diff --git a/Plugins/20 Cluster/52 Datastore Consistency.ps1 b/Plugins/20 Cluster/52 Datastore Consistency.ps1 index f10b753c..82b54c7d 100644 --- a/Plugins/20 Cluster/52 Datastore Consistency.ps1 +++ b/Plugins/20 Cluster/52 Datastore Consistency.ps1 @@ -1,24 +1,25 @@ +$Title = "Datastore Consistency" +$Header = "Datastores not connected to every host in cluster" +$Comments = "Virtual Machines residing on these datastores will not be able to run on all hosts in the cluster" +$Display = "Table" +$Author = "Robert Sexstone" +$PluginVersion = 1.6 +$PluginCategory = "vSphere" + # Start of Settings # Do not report on any Datastores that are defined here (Datastore Consistency Plugin) $DSDoNotInclude = "local*|datastore*" # End of Settings -$problemDatastores = @() +# Update settings where there is an override +$DSDoNotInclude = Get-vCheckSetting $Title "DSDoNotInclude" $DSDoNotInclude -if ($Clusters -ne $null) { - ForEach ($Cluster in ($Clusters)) { - $problemDatastores += $Cluster.ExtensionData.Host | %{ $h = $_; $Datastores | Where {$_.ExtensionData.Host.key -contains $h}} | - Where {$_.Name -notmatch $DSDoNotInclude } | Group-Object Name | Where { $_.Count -ne $cluster.ExtensionData.Host.count } | - Select @{Name="Name"; Expression={$_.Group.name}}, @{Name="Cluster";Expression={$Cluster.Name}} +if ($Clusters -ne $null) +{ + ForEach ($Cluster in ($Clusters)) + { + $Cluster.ExtensionData.Host | %{ $h = $_; $Datastores | Where {$_.ExtensionData.Host.key -contains $h}} | + Where {$_.Name -notmatch $DSDoNotInclude } | Group-Object Name | Where { $_.Count -ne $cluster.ExtensionData.Host.count } | + Select @{Name="Name"; Expression={$_.Group.name}}, @{Name="Cluster";Expression={$Cluster.Name}} } -} - -$problemDatastores - -$Title = "Datastore Consistency" -$Header = "Datastores not connected to every host in cluster" -$Comments = "Virtual Machines residing on these datastores will not be able to run on all hosts in the cluster" -$Display = "Table" -$Author = "Robert Sexstone" -$PluginVersion = 1.5 -$PluginCategory = "vSphere" +} \ No newline at end of file diff --git a/Plugins/20 Cluster/55 Clusters with DRS Disabled.ps1 b/Plugins/20 Cluster/55 Clusters with DRS Disabled.ps1 index ed861d93..1973507b 100644 --- a/Plugins/20 Cluster/55 Clusters with DRS Disabled.ps1 +++ b/Plugins/20 Cluster/55 Clusters with DRS Disabled.ps1 @@ -1,18 +1,20 @@ -# Start of Settings -# Clusters with DRS Disabled, do not report on any Clusters that are defined here -$ClustersDoNotInclude = "VM1_*|VM2_*" -# End of Settings - -$Result = @( $Clusters | - Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and -not $_.DRSEnabled} | - Select-Object -Property Name,DRSEnabled -) -$Result - $Title = "Clusters with DRS disabled" -$Header = "Clusters with DRS disabled : $(@($Result).Count)" +$Header = "Clusters with DRS disabled : [count]" $Comments = "The following clusters have DRS disabled. This may impact the performance of your cluster." $Display = "Table" $Author = "Robert van den Nieuwendijk" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" + +# Start of Settings +# Clusters with DRS Disabled, do not report on any Clusters that are defined here +$ClustersDoNotInclude = "VM1_*|VM2_*" +# End of Settings + +# Update settings where there is an override +$ClustersDoNotInclude = Get-vCheckSetting $Title "ClustersDoNotInclude" $ClustersDoNotInclude + +@( $Clusters | + Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and -not $_.DRSEnabled} | + Select-Object -Property Name,DRSEnabled +) \ No newline at end of file diff --git a/Plugins/20 Cluster/70 Cluster Node Version.ps1 b/Plugins/20 Cluster/70 Cluster Node Version.ps1 index b88ea57e..13069d3d 100644 --- a/Plugins/20 Cluster/70 Cluster Node Version.ps1 +++ b/Plugins/20 Cluster/70 Cluster Node Version.ps1 @@ -1,26 +1,3 @@ -# Start of Settings -# End of Settings - -$HostsVer = @() -foreach ($clusview in $clusviews) { - $HostsVerMiss = $HostsViews | ?{ $_.Parent -match "^$($clusview.MoRef)$"} | select @{N="FullName";E={$_.Config.Product.FullName}} -Unique - if (($HostsVerMiss | Measure-Object).Count -gt 1) { - $allVer = "" - foreach ($Ver in $HostsVerMiss) { $allVer = $allVer + $Ver.FullName + ";" } - $Details = "" | Select-Object Cluster, Ver - $Details.Cluster = $clusview.name - $Details.Ver = "*mismatch* " + $allVer.Substring(0, $allVer.Length-1) - $HostsVer += $Details - } elseif (($HostsVerMiss | Measure-Object).Count -eq 1) { - $Details = "" | Select-Object Cluster, Ver - $Details.Cluster = $clusview.name - $Details.Ver = $HostsVerMiss.FullName - $HostsVer += $Details - } -} - -$HostsVer | Sort Cluster - $Title = "Cluster Node version" $Header = "Cluster Node version" $Comments = "Display per cluster nodes version if unique or mismatch" @@ -28,3 +5,26 @@ $Display = "Table" $Author = "Raphael Schitz, Frederic Martin" $PluginVersion = 1.1 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$HostsVer = @() +foreach ($clusview in $clusviews) { + $HostsVerMiss = $HostsViews | ?{ $_.Parent -match "^$($clusview.MoRef)$"} | select @{N="FullName";E={$_.Config.Product.FullName}} -Unique + if (($HostsVerMiss | Measure-Object).Count -gt 1) { + $allVer = "" + foreach ($Ver in $HostsVerMiss) { $allVer = $allVer + $Ver.FullName + ";" } + $Details = "" | Select-Object Cluster, Ver + $Details.Cluster = $clusview.name + $Details.Ver = "*mismatch* " + $allVer.Substring(0, $allVer.Length-1) + $HostsVer += $Details + } elseif (($HostsVerMiss | Measure-Object).Count -eq 1) { + $Details = "" | Select-Object Cluster, Ver + $Details.Cluster = $clusview.name + $Details.Ver = $HostsVerMiss.FullName + $HostsVer += $Details + } +} + +$HostsVer | Sort Cluster \ No newline at end of file diff --git a/Plugins/20 Cluster/71 Capacity Planning.ps1 b/Plugins/20 Cluster/71 Capacity Planning.ps1 index 3ecbeeaf..a697f594 100644 --- a/Plugins/20 Cluster/71 Capacity Planning.ps1 +++ b/Plugins/20 Cluster/71 Capacity Planning.ps1 @@ -1,3 +1,12 @@ +$Title = "QuickStats Capacity Planning" +$Header = "QuickStats Capacity Planning" +$Comments = "The following gives brief capacity information for each cluster based on QuickStats CPU/Mem usage and counting for HA failover requirements" +$Display = "Table" +$Author = "Raphael Schitz, Frederic Martin" +$PluginVersion = 1.7 +$PluginCategory = "vSphere" + + # Start of Settings # Max CPU usage for non HA cluster $limitResourceCPUClusNonHA = 0.6 @@ -5,6 +14,10 @@ $limitResourceCPUClusNonHA = 0.6 $limitResourceMEMClusNonHA = 0.6 # End of Settings +# Update settings where there is an override +$limitResourceCPUClusNonHA = Get-vCheckSetting $Title "limitResourceCPUClusNonHA" $limitResourceCPUClusNonHA +$limitResourceMEMClusNonHA = Get-vCheckSetting $Title "limitResourceMEMClusNonHA" $limitResourceMEMClusNonHA + $capacityinfo = @() foreach ($cluv in ($clusviews | Where {$_.Summary.NumHosts -gt 0 } | Sort Name)) { @@ -61,12 +74,4 @@ foreach ($cluv in ($clusviews | Where {$_.Summary.NumHosts -gt 0 } | Sort Name)) $capacityinfo += $clucapacity } -$capacityinfo | Sort Datacenter, ClusterName - -$Title = "QuickStats Capacity Planning" -$Header = "QuickStats Capacity Planning" -$Comments = "The following gives brief capacity information for each cluster based on QuickStats CPU/Mem usage and counting for HA failover requirements" -$Display = "Table" -$Author = "Raphael Schitz, Frederic Martin" -$PluginVersion = 1.7 -$PluginCategory = "vSphere" +$capacityinfo | Sort Datacenter, ClusterName \ No newline at end of file diff --git a/Plugins/20 Cluster/72 s-vMotion Information.ps1 b/Plugins/20 Cluster/72 s-vMotion Information.ps1 index 20483e05..2b581b47 100644 --- a/Plugins/20 Cluster/72 s-vMotion Information.ps1 +++ b/Plugins/20 Cluster/72 s-vMotion Information.ps1 @@ -1,3 +1,11 @@ +$Title = "s/vMotion Information" +$Header = "s/vMotion Information (Over $vMotionAge Days Old) : $(@($Motions).count)" +$Comments = "s/vMotions and how long they took to migrate between hosts and datastores" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days to go back and check for s/vMotions $vMotionAge = 5 @@ -7,6 +15,11 @@ $IncludevMotions = $true; $IncludeSvMotions = $true; # End of Settings +# Update settings where there is an override +$vMotionAge = Get-vCheckSetting $Title "vMotionAge" $vMotionAge +$IncludevMotions = Get-vCheckSetting $Title "IncludevMotions" $IncludevMotions +$IncludeSvMotions = Get-vCheckSetting $Title "IncludeSvMotions" $IncludeSvMotions + # Search for any vmotion-related events $EventFilterSpec = New-Object VMware.Vim.EventFilterSpec $EventFilterSpec.Category = "info" @@ -46,12 +59,4 @@ if (-not $IncludevMotions) { $Motions = $Motions | Where { $_.Type -ne "vMotion" if (-not $IncludeSvMotions) { $Motions = $Motions | Where { $_.Type -ne "SvMotion" }} $Motions -$Title = "s/vMotion Information" -$Header = "s/vMotion Information (Over $vMotionAge Days Old) : $(@($Motions).count)" -$Comments = "s/vMotions and how long they took to migrate between hosts and datastores" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" - -Remove-Variable Motions, EventFilterSpec, vmotions +Remove-Variable Motions, EventFilterSpec, vmotions \ No newline at end of file diff --git a/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 b/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 index 4508b7d5..8ddf1ed8 100644 --- a/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 +++ b/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 @@ -1,21 +1,14 @@ -# Start of Settings -# End of Settings - -$vmInfo = @() -Foreach($Machine in $VM | Where {$_.PowerState -eq "PoweredOn"}) { - $Details = "" | Select Name, MemoryMB, FreeSpaceMB - $Details.Name = $Machine.Name - $Details.MemoryMB = $Machine.MemoryMB - $Details.FreeSpaceMB = ($Datastores|Where {$_.Name -eq (($Machine.ExtensionData.Config.Files.VmPathName).Split('[')[1]).Split(']')[0]}).FreeSpaceMB - $vmInfo += $Details -} -$Result = @($vmInfo | Where {($_.FreeSpaceMB -ne $null) -and ($_.MemoryMB -gt $_.FreeSpaceMB)} | Sort Name) -$Result - $Title = "More RAM than free space on Datastore" -$Header = "More RAM than free space on Datastore: $(@($Result).Count)" +$Header = "More RAM than free space on Datastore: [count]" $Comments = "The following VMs can't vMotion because they have more RAM than free space on datastore" $Display = "Table" $Author = "Olivier TABUT, Bob Cote" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$VM | Where {$_.PowerState -eq "PoweredOn"} | + Select Name, MemoryMB, @{"Name"="FreeSpaceMB";e={($Datastores|Where {$_.Name -eq (($Machine.ExtensionData.Config.Files.VmPathName).Split('[')[1]).Split(']')[0]}).FreeSpaceMB}} | + Where {($_.FreeSpaceMB -ne $null) -and ($_.MemoryMB -gt $_.FreeSpaceMB)} | Sort Name \ No newline at end of file diff --git a/Plugins/20 Cluster/75 DRS Rules.ps1 b/Plugins/20 Cluster/75 DRS Rules.ps1 index 7de1cd7f..1cb4601c 100644 --- a/Plugins/20 Cluster/75 DRS Rules.ps1 +++ b/Plugins/20 Cluster/75 DRS Rules.ps1 @@ -1,3 +1,10 @@ +$Title = "DRS Rules" +$Header = "DRS Rules" +$Display = "Table" +$Author = "John Sneddon" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Display VM affinity rules? $ShowVMAffinity = $true @@ -9,13 +16,11 @@ $ShowHostAffinity = $true $excludeName = "ExcludeMe" # End of Settings -# Changelog -## 1.0 : Initial Version -## 1.1 : Add filter option (Pull #391 - @mtehonica) - -# Add pretty icons -Add-ReportResource -cid "Error" -Type "SystemIcons" -ResourceData "Error" -Add-ReportResource -cid "OK" -Type "base64" -ResourceData "png|iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAI5ElEQVR42p1XC1BU1xn+7j7YXR4LLCu6CwiKIuBbVBRj8YE0iokEWydpO2k64yRtmqRTzWTsKxmbxlTHWCdN00yeTowdkzRFi4yKWlTwgW80LIigyAILy0seK/u69/Y/Z5cra6yPnp3/nrv3cb7v/85//v9cAQ/ZNE8hl7r5ZDPJ0smSyKLJ+sjsZHVkF8lO+Ytx7GHHFR4AGkHdD8mKrAmWlYlJCYLVaoF5VByio43QG/RwD7nR19ePrs5utLU50GJvldvsjoNQ4Ut672si4/q/CBD4MurWTkhLXZOZmY7ktCQIagE6lR6RmkgYtTHQawxw+4fQ7+vDoL8fHskDWZRxs94Om60ODbbGfVDjr/49KHskAgT+Qpw5bsPMWdNS0mekQavRwWIYg2htrPKMTD+B92wQgf9njZFxDLXB5/ei7lI9Lpypdva092z278e2hyJA4OvHJif9cV7O3PAxKfEYrR8Dsy5egb3ziqyA333Ozro8TnS429He5MSpyipfc13LVrEMv70vAeY5gW9buGRB+CiLGenGzBEPfFcsOXgUlONIegFaV/tt6HR04fjhSl/zty1vif/BxnsSYHNOsn+4dNmiFOs4CzIIfPh2wKeA6PfyfySVe9GsJRJtNxw4VFLe33O952XxBD4PIRCM9k/z8hevycxKR2b0FLqhUgYO9QtBOv8rgmU03WxCq7MNer0eWVOzINGvtu9b2M7X4dDX5dXydayUmtAyksBzFO2fPV6YB0uENTjnsgI0DDkstixL/Loky4rfggBO2tvnQ864HGSYpqHtdguu9dfB7mqmmOhEu6sNB/YcxrXyxu3iGaxjLw8T+PeThQVPpGamYpIxXYEUQmYZEGV/wCSJe8WISEECakEF320/ViSvxHjTRGhVYURKQIvLjrLWfXy8OpqKRtt17P2s9KZ4FN+ji80Cy3CUZMpX/3iVkBiVjBha37IicACaeeqTffBLfjLq6VwkcFEWFeHV5P0k9RQUTi4iYJVynalwoKWEj9fn64V9oBnf7NqLliOO16VavMkIbJg7b/bb8xbPobmfGhLLjIhEID4C9lKS8UpeboyEj0waoYC3VcTbBZuho+Q0su25+U/0eLqUEK7pu4zT5Wdxeve5U9JFrGAEviwsemLNxIxUTIhKC5ltBsAAWYbziB64xSHqvZyMP6gIjwWvhHVTf4M006QQ8JPOClzqPocwmg6VoObPNgxcRUNtI4o/LGkWKwIEqte+8Nw06+gEWMMTR/gO8tJLoG4OPEQpd0gMGFeDiDDvVT4VViWvRmHqD0LAB32DeK92G/RqPXTqMJ7CWWulKWnraMVH23b0U2J6mhHoWf/aK7ENQw3Is+RT8Og4CRZsbvL6Sv0VOHucCIvQIjrRyD1najBVBFHA6FuJeLfofahV6hACb176PY+RcE04DOpwIqEnRX047DiECYYJeGfTuz5/CV5mBMTfvfGa6u+172G2eS5yRi2kvG/h0tdU1+Lny17kyjSSdDsufYrusE6uhkjy69wGfJC3A2aDWQFm0/JK1fO0KtS8aEVoIxFOBFiNONt9Bue6qvCLjJfw1sYtMlXKjYoC/7B/waVOihiLGbFZyIjOwOqUZ5BA/7UU4b2eXh54vyxfCyFCQHd7N16a82sUTVgT4vnrFzfQ2r9K1TKKCETx+W9y3aBEZOMrQq824EdJP2EK+EmB7UoMVLiPwjnUoQw0NiIFHy/YiRmmrEBU0FLsdfeg39uHF/evRVpUOv5S8LeQ5HuwtRTv1LyNKK2R54gB30CgIA05lGfiDaOxUL+IxcAgxcBWZRU4zW2ovWUL8WaJZRk2Z21HcuQ4hUTnbScutJzHotQltB/QK892up1YenA+nwKWM1z+QX5+d8uIyUR8lxXFH5Q4qCZsVPKANTsexxzl33lhtjkbu3P3kqRG/p+tfJdnEFE6Y8hzuQfmkAM1eFDLtSxGW5UTp3eds0mX8aqSCQuezhcOtu/nst3dpptm4qtF+xAbdmdDQnLwRM6mYGvNJmy58qcHgkdRXHx/zHKU7i6DvdhxRG7FrwK1YBX2P1lU8PiA5RYljgv3fHlq7HQiUYI4nTnkOvN6ycFsnpof1GbEzUKUIwZ7PyntFI/zPeMfQqrhYwXzUNF1jFJnd8iLQjDO0o2TUZZfwdc0F4F+2aVT0DrYBH/wygiBQppJF4eF5lxUlp5GfXHjRakeTLJ/3dkP+LE7b8XilZEZeoqFowHg4EEIHHh1+9n45/HMuGf5/a+ad+HzGx/xYiVT0hGl4NQEuQzvExmZXMsiDNa6ceiL8g7xLErh5Tuj5js7okLkm2JNO/OWL47vie3E+a6zHJB5rwr2Gg0ru1qoKelpVBq6zjJmIPn4/QyO9YHVwncKQRlmxc2FqdeMsj1H3F3He8/Kdmyhy6UY3g8oJJZjXdLExD8vWDJf2x3p5CRUhMIsjPUaLVU7NU2BFmFqDScoUcr2ketDVBsYuES7YTYdkiRzz7NM2TC5RqHyyAnxRpndRiV4J93+hKxHUXlkU+dj09j0xFdzFs7T+uPdsFGQ9fo7odOqyMJo7YfBQNt0vVZP+VEI1AZCdvmpQvp8PAd4SY1RWgvf2qmdOlRWnBQbDt+4RsuOef0+2XUlvu4VreqleCMuMW7dnJyZxuQpSejwtqPJ0wA3blFx0SEiLJwI6IiAipdsN4Hf9lPV9HkQqY7DeEM6rNoE0FYcJ0+cdrdWOa6Jl/jHyccIfMLhvgQ4icfwLAxYNzk7ffq0KVORNNEKl+TCgDQAt3wbHnmQ+l7ohVgYVEYYhAgYNdGIUcXA0dRBVbQGZyqrOvwNqJdsYFuib0Z6/kACrKnGI1FlwXpE4alJMycmp6akYlxiCqxmC0xGE/Q6+jb0uNE70EcluwPNDjtutFxH9ZXLnVILWvzV9LHqQjENdXJ4zh+JwIhnktRZ+CnCsVxlRoLGSI5GktMaaNjqk12k/gAG5B70Sh1wSDWopXdYXj+HwJezfL/BH6XFkCWQjQ3aGLJIskGydrLmoLWS3XqYAf8LHVgyvLhECXAAAAAASUVORK5CYII=" +# Update settings where there is an override +$ShowVMAffinity = Get-vCheckSetting $Title "ShowVMAffinity" $ShowVMAffinity +$ShowVMAntiAffinity = Get-vCheckSetting $Title "ShowVMAntiAffinity" $ShowVMAntiAffinity +$ShowHostAffinity = Get-vCheckSetting $Title "ShowHostAffinity" $ShowHostAffinity +$excludeName = Get-vCheckSetting $Title "excludeName" $excludeName #Compile an array of rule types to return $Types = @() @@ -24,21 +29,24 @@ if ($ShowVMAntiAffinity) { $Types += "VMAntiAffinity"} if ($ShowHostAffinity) { $Types += "VMHostAffinity"} $Clusters | Foreach { - Get-DrsRule -Cluster $_ -Type $Types | Where { $_.Name -notmatch $excludeName } | - Select Cluster, Enabled, Name, Type, @{N="VM";E={(Get-View $_.VMIDS | Select -ExpandProperty Name) -join "
"}}, - @{N="Rule Host";E={(Get-View $_.AffineHostIds | Select -ExpandProperty Name) -join "
" }}, - @{N="Running on";E={(Get-View (Get-View $_.VMIDS | %{$_.Runtime.Host}) | Select -ExpandProperty Name) -join "
"}} + Get-DrsRule -Cluster $_ -Type $Types | Where { $_.Name -notmatch $excludeName } | + Select Cluster, Enabled, Name, Type, @{N="VM";E={(Get-View $_.VMIDS | Select -ExpandProperty Name) -join "
"}}, + @{N="Rule Host";E={(Get-View $_.AffineHostIds | Select -ExpandProperty Name) -join "
" }}, + @{N="Running on";E={(Get-View (Get-View $_.VMIDS | %{$_.Runtime.Host}) | Select -ExpandProperty Name) -join "
"}} } -$Title = "DRS Rules" -$Header = "DRS Rules" $Comments = ("Contains all DRS rules defined in this vCenter - {0}" -f ($types -join ",")) -$Display = "Table" -$Author = "John Sneddon" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" + +# Add pretty icons +Add-ReportResource -cid "Error" -Type "SystemIcons" -ResourceData "Error" +Add-ReportResource -cid "OK" -Type "base64" -ResourceData "png|iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAI5ElEQVR42p1XC1BU1xn+7j7YXR4LLCu6CwiKIuBbVBRj8YE0iokEWydpO2k64yRtmqRTzWTsKxmbxlTHWCdN00yeTowdkzRFi4yKWlTwgW80LIigyAILy0seK/u69/Y/Z5cra6yPnp3/nrv3cb7v/85//v9cAQ/ZNE8hl7r5ZDPJ0smSyKLJ+sjsZHVkF8lO+Ytx7GHHFR4AGkHdD8mKrAmWlYlJCYLVaoF5VByio43QG/RwD7nR19ePrs5utLU50GJvldvsjoNQ4Ut672si4/q/CBD4MurWTkhLXZOZmY7ktCQIagE6lR6RmkgYtTHQawxw+4fQ7+vDoL8fHskDWZRxs94Om60ODbbGfVDjr/49KHskAgT+Qpw5bsPMWdNS0mekQavRwWIYg2htrPKMTD+B92wQgf9njZFxDLXB5/ei7lI9Lpypdva092z278e2hyJA4OvHJif9cV7O3PAxKfEYrR8Dsy5egb3ziqyA333Ozro8TnS429He5MSpyipfc13LVrEMv70vAeY5gW9buGRB+CiLGenGzBEPfFcsOXgUlONIegFaV/tt6HR04fjhSl/zty1vif/BxnsSYHNOsn+4dNmiFOs4CzIIfPh2wKeA6PfyfySVe9GsJRJtNxw4VFLe33O952XxBD4PIRCM9k/z8hevycxKR2b0FLqhUgYO9QtBOv8rgmU03WxCq7MNer0eWVOzINGvtu9b2M7X4dDX5dXydayUmtAyksBzFO2fPV6YB0uENTjnsgI0DDkstixL/Loky4rfggBO2tvnQ864HGSYpqHtdguu9dfB7mqmmOhEu6sNB/YcxrXyxu3iGaxjLw8T+PeThQVPpGamYpIxXYEUQmYZEGV/wCSJe8WISEECakEF320/ViSvxHjTRGhVYURKQIvLjrLWfXy8OpqKRtt17P2s9KZ4FN+ji80Cy3CUZMpX/3iVkBiVjBha37IicACaeeqTffBLfjLq6VwkcFEWFeHV5P0k9RQUTi4iYJVynalwoKWEj9fn64V9oBnf7NqLliOO16VavMkIbJg7b/bb8xbPobmfGhLLjIhEID4C9lKS8UpeboyEj0waoYC3VcTbBZuho+Q0su25+U/0eLqUEK7pu4zT5Wdxeve5U9JFrGAEviwsemLNxIxUTIhKC5ltBsAAWYbziB64xSHqvZyMP6gIjwWvhHVTf4M006QQ8JPOClzqPocwmg6VoObPNgxcRUNtI4o/LGkWKwIEqte+8Nw06+gEWMMTR/gO8tJLoG4OPEQpd0gMGFeDiDDvVT4VViWvRmHqD0LAB32DeK92G/RqPXTqMJ7CWWulKWnraMVH23b0U2J6mhHoWf/aK7ENQw3Is+RT8Og4CRZsbvL6Sv0VOHucCIvQIjrRyD1najBVBFHA6FuJeLfofahV6hACb176PY+RcE04DOpwIqEnRX047DiECYYJeGfTuz5/CV5mBMTfvfGa6u+172G2eS5yRi2kvG/h0tdU1+Lny17kyjSSdDsufYrusE6uhkjy69wGfJC3A2aDWQFm0/JK1fO0KtS8aEVoIxFOBFiNONt9Bue6qvCLjJfw1sYtMlXKjYoC/7B/waVOihiLGbFZyIjOwOqUZ5BA/7UU4b2eXh54vyxfCyFCQHd7N16a82sUTVgT4vnrFzfQ2r9K1TKKCETx+W9y3aBEZOMrQq824EdJP2EK+EmB7UoMVLiPwjnUoQw0NiIFHy/YiRmmrEBU0FLsdfeg39uHF/evRVpUOv5S8LeQ5HuwtRTv1LyNKK2R54gB30CgIA05lGfiDaOxUL+IxcAgxcBWZRU4zW2ovWUL8WaJZRk2Z21HcuQ4hUTnbScutJzHotQltB/QK892up1YenA+nwKWM1z+QX5+d8uIyUR8lxXFH5Q4qCZsVPKANTsexxzl33lhtjkbu3P3kqRG/p+tfJdnEFE6Y8hzuQfmkAM1eFDLtSxGW5UTp3eds0mX8aqSCQuezhcOtu/nst3dpptm4qtF+xAbdmdDQnLwRM6mYGvNJmy58qcHgkdRXHx/zHKU7i6DvdhxRG7FrwK1YBX2P1lU8PiA5RYljgv3fHlq7HQiUYI4nTnkOvN6ycFsnpof1GbEzUKUIwZ7PyntFI/zPeMfQqrhYwXzUNF1jFJnd8iLQjDO0o2TUZZfwdc0F4F+2aVT0DrYBH/wygiBQppJF4eF5lxUlp5GfXHjRakeTLJ/3dkP+LE7b8XilZEZeoqFowHg4EEIHHh1+9n45/HMuGf5/a+ad+HzGx/xYiVT0hGl4NQEuQzvExmZXMsiDNa6ceiL8g7xLErh5Tuj5js7okLkm2JNO/OWL47vie3E+a6zHJB5rwr2Gg0ru1qoKelpVBq6zjJmIPn4/QyO9YHVwncKQRlmxc2FqdeMsj1H3F3He8/Kdmyhy6UY3g8oJJZjXdLExD8vWDJf2x3p5CRUhMIsjPUaLVU7NU2BFmFqDScoUcr2ketDVBsYuES7YTYdkiRzz7NM2TC5RqHyyAnxRpndRiV4J93+hKxHUXlkU+dj09j0xFdzFs7T+uPdsFGQ9fo7odOqyMJo7YfBQNt0vVZP+VEI1AZCdvmpQvp8PAd4SY1RWgvf2qmdOlRWnBQbDt+4RsuOef0+2XUlvu4VreqleCMuMW7dnJyZxuQpSejwtqPJ0wA3blFx0SEiLJwI6IiAipdsN4Hf9lPV9HkQqY7DeEM6rNoE0FYcJ0+cdrdWOa6Jl/jHyccIfMLhvgQ4icfwLAxYNzk7ffq0KVORNNEKl+TCgDQAt3wbHnmQ+l7ohVgYVEYYhAgYNdGIUcXA0dRBVbQGZyqrOvwNqJdsYFuib0Z6/kACrKnGI1FlwXpE4alJMycmp6akYlxiCqxmC0xGE/Q6+jb0uNE70EcluwPNDjtutFxH9ZXLnVILWvzV9LHqQjENdXJ4zh+JwIhnktRZ+CnCsVxlRoLGSI5GktMaaNjqk12k/gAG5B70Sh1wSDWopXdYXj+HwJezfL/BH6XFkCWQjQ3aGLJIskGydrLmoLWS3XqYAf8LHVgyvLhECXAAAAAASUVORK5CYII=" # Table formatting rules $TableFormat = @{"Enabled" = @(@{ "-eq `$true" = "Cell,cid|OK|16x16"; }, @{ "-eq `$false" = "Cell,cid|Error|16x16" }) } + +# Changelog +## 1.0 : Initial Version +## 1.1 : Add filter option (Pull #391 - @mtehonica) +## 1.2 : Update to Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/30 Host/07 Hosts Overcommit State.ps1 b/Plugins/30 Host/07 Hosts Overcommit State.ps1 index 97cf8edd..650d3a4c 100644 --- a/Plugins/30 Host/07 Hosts Overcommit State.ps1 +++ b/Plugins/30 Host/07 Hosts Overcommit State.ps1 @@ -1,8 +1,19 @@ +$Title = "Hosts Overcommit state" +$Header = "Hosts overcommitting memory: [count]]" +$Comments = "Overcommitted hosts may cause issues with performance if memory is not issued when needed, this may cause ballooning and swapping" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # Return results in GB or MB? $Units = "GB" # End of Settings +# Update settings where there is an override +$Units = Get-vCheckSetting $Title "Units" $Units + # Setup plugin-specific language table $pLang = DATA { ConvertFrom-StringData @' @@ -16,46 +27,34 @@ $OverCommit = @() $i = 0 $VMHCount = $VMH | Measure Foreach ($VMHost in $VMH) { - Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $VMHost.Name -PercentComplete ((100*$i)/$VMHCount.Count) - if ($VMMem) { Clear-Variable VMMem } - $VM | ?{$_.VMHost.Name -eq $VMHost.Name -and $_.PowerState -ne "PoweredOff"} | Foreach { - [INT]$VMMem += $_.MemoryMB - } - - - If ([Math]::Round(($VMMem - $VMHost.MemoryTotalMB), 0) -gt 0) { - $OverCommitMB = [Math]::Round(($VMMem - $VMHost.MemoryTotalMB), 0) - - - if ($Units -eq "MB") { - $OverCommit += New-Object PSObject -Property @{"Host" = $VMHost.Name; - "TotalMemMB" = [Math]::Round($VMHost.MemoryTotalMB,0); - "TotalAssignedMemMB" = $VMMem; - "TotalUsedMB" = [Math]::Round($VMHost.MemoryUsageMB,0); - "OverCommitMB" = $OverCommitMB; - } - } - else { - $OverCommit += New-Object PSObject -Property @{"Host" = $VMHost.Name; - "TotalMemGB" = [Math]::Round(($VMHost.MemoryTotalMB)/1024,0); - "TotalAssignedMemGB" = [Math]::Round($VMMem/1024,0); - "TotalUsedGB" = [Math]::Round(($VMHost.MemoryUsageMB)/1024,0); - "OverCommitGB" = [Math]::Round($OverCommitMB/1024, 0); - } - } - } - $i++ + Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $VMHost.Name -PercentComplete ((100*$i)/$VMHCount.Count) + if ($VMMem) { Clear-Variable VMMem } + $VM | ?{$_.VMHost.Name -eq $VMHost.Name -and $_.PowerState -ne "PoweredOff"} | Foreach { + [INT]$VMMem += $_.MemoryMB + } + + If ([Math]::Round(($VMMem - $VMHost.MemoryTotalMB), 0) -gt 0) { + $OverCommitMB = [Math]::Round(($VMMem - $VMHost.MemoryTotalMB), 0) + + if ($Units -eq "MB") { + $OverCommit += New-Object PSObject -Property @{"Host" = $VMHost.Name; + "TotalMemMB" = [Math]::Round($VMHost.MemoryTotalMB,0); + "TotalAssignedMemMB" = $VMMem; + "TotalUsedMB" = [Math]::Round($VMHost.MemoryUsageMB,0); + "OverCommitMB" = $OverCommitMB; + } + } + else { + $OverCommit += New-Object PSObject -Property @{"Host" = $VMHost.Name; + "TotalMemGB" = [Math]::Round(($VMHost.MemoryTotalMB)/1024,0); + "TotalAssignedMemGB" = [Math]::Round($VMMem/1024,0); + "TotalUsedGB" = [Math]::Round(($VMHost.MemoryUsageMB)/1024,0); + "OverCommitGB" = [Math]::Round($OverCommitMB/1024, 0); + } + } + } + $i++ } Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $lang.Complete -Completed - -$OverCommit | Select Host, "TotalMem$Units", "TotalAssignedMem$Units", "TotalUsed$Units", "OverCommit$Units" - - -$Title = "Hosts Overcommit state" -$Header = "Hosts overcommitting memory: [count]]" -$Comments = "Overcommitted hosts may cause issues with performance if memory is not issued when needed, this may cause ballooning and swapping" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.4 -$PluginCategory = "vSphere" +$OverCommit | Select Host, "TotalMem$Units", "TotalAssignedMem$Units", "TotalUsed$Units", "OverCommit$Units" \ No newline at end of file diff --git a/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 b/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 index af69980e..2a3fb226 100644 --- a/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 +++ b/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 @@ -1,26 +1,24 @@ +$Title = "Hosts Dead LUN Path" +$Header = "Dead LunPath : [count]" +$Comments = "Dead LUN Paths may cause issues with storage performance or be an indication of loss of redundancy" +$Display = "Table" +$Author = "Alan Renouf, Frederic Martin" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings -# Changelog -## 1.1 : Alternate code in order to avoid usage of Get-ScsiLun for performance matter - -$deadluns = @() foreach ($esxhost in ($HostsViews | where {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { - $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.State -eq "Dead"} | %{ - $myObj = "" | Select VMHost, Lunpath, State - $myObj.VMHost = $esxhost.Name - $myObj.Lunpath = $_.Name - $myObj.State = $_.state - $deadluns += $myObj - } + $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.State -eq "Dead"} | %{ + New-Object PSObject -Property @{ + VMHost = $esxhost.Name + Lunpath = $_.Name + State = $_.state + } + } } - -$deadluns -$Title = "Hosts Dead LUN Path" -$Header = "Dead LunPath : $(@($deadluns).count)" -$Comments = "Dead LUN Paths may cause issues with storage performance or be an indication of loss of redundancy" -$Display = "Table" -$Author = "Alan Renouf, Frederic Martin" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +# Changelog +## 1.1 : Alternate code in order to avoid usage of Get-ScsiLun for performance matter +## 1.2 : Code refactor \ No newline at end of file diff --git a/Plugins/30 Host/101 ESXi Inode Usage.ps1 b/Plugins/30 Host/101 ESXi Inode Usage.ps1 index 58e677ef..62ea6333 100644 --- a/Plugins/30 Host/101 ESXi Inode Usage.ps1 +++ b/Plugins/30 Host/101 ESXi Inode Usage.ps1 @@ -1,21 +1,25 @@ +$Title = "ESXi Inode Exhaustion" +$Comments = "The following hosts have an excessive amount of Inodes in use on the local ESXi filesystem. This can cause hosts to disconnect from vCenter and becoming completely unmanageable even locally, requiring a hard reboot. See KB2037798 and KB1008643" +$Display = "Table" +$Author = "Matthias Koehler" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Set the ESXi filesystem free Inode threshold in percent $InodeThreshold = 40 # End of Settings -# Changelog -## 1.1 : Added filter for connected Hosts only +# Update settings where there is an override +$diskmaxtotallatency = Get-vCheckSetting $Title "diskmaxtotallatency" $diskmaxtotallatency -$Result = @($VMH | Where-Object {$_.Version -match "^5\." -and ($_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance")} | Sort-Object | ForEach-Object { - $EsxCli = Get-EsxCli -VMHost $_ - $EsxCli.system.visorfs.get() | Where-Object {[int]$_.FreeInodePercent -lt $InodeThreshold} | Add-Member -MemberType NoteProperty -Name VMHost -Value $_.Name -PassThru | Select-Object VMHost, FreeInodePercent, TotalInodes, UsedInodes -}) -$Result +$VMH | Where-Object {$_.Version -match "^5\." -and ($_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance")} | Sort-Object | ForEach-Object { + $EsxCli = Get-EsxCli -VMHost $_ + $EsxCli.system.visorfs.get() | Where-Object {[int]$_.FreeInodePercent -lt $InodeThreshold} | Add-Member -MemberType NoteProperty -Name VMHost -Value $_.Name -PassThru | Select-Object VMHost, FreeInodePercent, TotalInodes, UsedInodes +} -$Title = "ESXi Inode Exhaustion" -$Header = "Hosts with few free Inodes (< ${InodeThreshold}%) on the local ESXi visorfs: $(@($Result).count)" -$Comments = "The following hosts have an excessive amount of Inodes in use on the local ESXi filesystem. This can cause hosts to disconnect from vCenter and becoming completely unmanageable even locally, requiring a hard reboot. See KB2037798 and KB1008643" -$Display = "Table" -$Author = "Matthias Koehler" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$Header = ("Hosts with few free Inodes (< {0}%) on the local ESXi visorfs: [count]" -f $InodeThreshold) + +# Changelog +## 1.1 : Added filter for connected Hosts only +## 1.2 : Update to Get-vCheckSetting, code refactor \ No newline at end of file diff --git a/Plugins/30 Host/105 Host Profile Compliance.ps1 b/Plugins/30 Host/105 Host Profile Compliance.ps1 index 53edbc11..337776ed 100644 --- a/Plugins/30 Host/105 Host Profile Compliance.ps1 +++ b/Plugins/30 Host/105 Host Profile Compliance.ps1 @@ -1,3 +1,11 @@ +$Title = "Host Profile Compliance" +$Header = "List of host profiles and compliance status" +$Comments = "Host profiles are useful for ensuring hosts are configured in a consistent manner." +$Display = "Table" +$Author = "John Sneddon" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Show detailed information in report $ShowDetail = $true @@ -5,6 +13,10 @@ $ShowDetail = $true $ShowCompliant = $false # End of Settings +# Update settings where there is an override +$ShowDetail = Get-vCheckSetting $Title "ShowDetail" $ShowDetail +$ShowCompliant = Get-vCheckSetting $Title "ShowCompliant" $ShowCompliant + # Add resources for report Add-ReportResource -cid "Error" -Type "SystemIcons" -ResourceData "Error" Add-ReportResource -cid "OK" -Type "base64" -ResourceData "png|iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAI5ElEQVR42p1XC1BU1xn+7j7YXR4LLCu6CwiKIuBbVBRj8YE0iokEWydpO2k64yRtmqRTzWTsKxmbxlTHWCdN00yeTowdkzRFi4yKWlTwgW80LIigyAILy0seK/u69/Y/Z5cra6yPnp3/nrv3cb7v/85//v9cAQ/ZNE8hl7r5ZDPJ0smSyKLJ+sjsZHVkF8lO+Ytx7GHHFR4AGkHdD8mKrAmWlYlJCYLVaoF5VByio43QG/RwD7nR19ePrs5utLU50GJvldvsjoNQ4Ut672si4/q/CBD4MurWTkhLXZOZmY7ktCQIagE6lR6RmkgYtTHQawxw+4fQ7+vDoL8fHskDWZRxs94Om60ODbbGfVDjr/49KHskAgT+Qpw5bsPMWdNS0mekQavRwWIYg2htrPKMTD+B92wQgf9njZFxDLXB5/ei7lI9Lpypdva092z278e2hyJA4OvHJif9cV7O3PAxKfEYrR8Dsy5egb3ziqyA333Ozro8TnS429He5MSpyipfc13LVrEMv70vAeY5gW9buGRB+CiLGenGzBEPfFcsOXgUlONIegFaV/tt6HR04fjhSl/zty1vif/BxnsSYHNOsn+4dNmiFOs4CzIIfPh2wKeA6PfyfySVe9GsJRJtNxw4VFLe33O952XxBD4PIRCM9k/z8hevycxKR2b0FLqhUgYO9QtBOv8rgmU03WxCq7MNer0eWVOzINGvtu9b2M7X4dDX5dXydayUmtAyksBzFO2fPV6YB0uENTjnsgI0DDkstixL/Loky4rfggBO2tvnQ864HGSYpqHtdguu9dfB7mqmmOhEu6sNB/YcxrXyxu3iGaxjLw8T+PeThQVPpGamYpIxXYEUQmYZEGV/wCSJe8WISEECakEF320/ViSvxHjTRGhVYURKQIvLjrLWfXy8OpqKRtt17P2s9KZ4FN+ji80Cy3CUZMpX/3iVkBiVjBha37IicACaeeqTffBLfjLq6VwkcFEWFeHV5P0k9RQUTi4iYJVynalwoKWEj9fn64V9oBnf7NqLliOO16VavMkIbJg7b/bb8xbPobmfGhLLjIhEID4C9lKS8UpeboyEj0waoYC3VcTbBZuho+Q0su25+U/0eLqUEK7pu4zT5Wdxeve5U9JFrGAEviwsemLNxIxUTIhKC5ltBsAAWYbziB64xSHqvZyMP6gIjwWvhHVTf4M006QQ8JPOClzqPocwmg6VoObPNgxcRUNtI4o/LGkWKwIEqte+8Nw06+gEWMMTR/gO8tJLoG4OPEQpd0gMGFeDiDDvVT4VViWvRmHqD0LAB32DeK92G/RqPXTqMJ7CWWulKWnraMVH23b0U2J6mhHoWf/aK7ENQw3Is+RT8Og4CRZsbvL6Sv0VOHucCIvQIjrRyD1najBVBFHA6FuJeLfofahV6hACb176PY+RcE04DOpwIqEnRX047DiECYYJeGfTuz5/CV5mBMTfvfGa6u+172G2eS5yRi2kvG/h0tdU1+Lny17kyjSSdDsufYrusE6uhkjy69wGfJC3A2aDWQFm0/JK1fO0KtS8aEVoIxFOBFiNONt9Bue6qvCLjJfw1sYtMlXKjYoC/7B/waVOihiLGbFZyIjOwOqUZ5BA/7UU4b2eXh54vyxfCyFCQHd7N16a82sUTVgT4vnrFzfQ2r9K1TKKCETx+W9y3aBEZOMrQq824EdJP2EK+EmB7UoMVLiPwjnUoQw0NiIFHy/YiRmmrEBU0FLsdfeg39uHF/evRVpUOv5S8LeQ5HuwtRTv1LyNKK2R54gB30CgIA05lGfiDaOxUL+IxcAgxcBWZRU4zW2ovWUL8WaJZRk2Z21HcuQ4hUTnbScutJzHotQltB/QK892up1YenA+nwKWM1z+QX5+d8uIyUR8lxXFH5Q4qCZsVPKANTsexxzl33lhtjkbu3P3kqRG/p+tfJdnEFE6Y8hzuQfmkAM1eFDLtSxGW5UTp3eds0mX8aqSCQuezhcOtu/nst3dpptm4qtF+xAbdmdDQnLwRM6mYGvNJmy58qcHgkdRXHx/zHKU7i6DvdhxRG7FrwK1YBX2P1lU8PiA5RYljgv3fHlq7HQiUYI4nTnkOvN6ycFsnpof1GbEzUKUIwZ7PyntFI/zPeMfQqrhYwXzUNF1jFJnd8iLQjDO0o2TUZZfwdc0F4F+2aVT0DrYBH/wygiBQppJF4eF5lxUlp5GfXHjRakeTLJ/3dkP+LE7b8XilZEZeoqFowHg4EEIHHh1+9n45/HMuGf5/a+ad+HzGx/xYiVT0hGl4NQEuQzvExmZXMsiDNa6ceiL8g7xLErh5Tuj5js7okLkm2JNO/OWL47vie3E+a6zHJB5rwr2Gg0ru1qoKelpVBq6zjJmIPn4/QyO9YHVwncKQRlmxc2FqdeMsj1H3F3He8/Kdmyhy6UY3g8oJJZjXdLExD8vWDJf2x3p5CRUhMIsjPUaLVU7NU2BFmFqDScoUcr2ketDVBsYuES7YTYdkiRzz7NM2TC5RqHyyAnxRpndRiV4J93+hKxHUXlkU+dj09j0xFdzFs7T+uPdsFGQ9fo7odOqyMJo7YfBQNt0vVZP+VEI1AZCdvmpQvp8PAd4SY1RWgvf2qmdOlRWnBQbDt+4RsuOef0+2XUlvu4VreqleCMuMW7dnJyZxuQpSejwtqPJ0wA3blFx0SEiLJwI6IiAipdsN4Hf9lPV9HkQqY7DeEM6rNoE0FYcJ0+cdrdWOa6Jl/jHyccIfMLhvgQ4icfwLAxYNzk7ffq0KVORNNEKl+TCgDQAt3wbHnmQ+l7ohVgYVEYYhAgYNdGIUcXA0dRBVbQGZyqrOvwNqJdsYFuib0Z6/kACrKnGI1FlwXpE4alJMycmp6akYlxiCqxmC0xGE/Q6+jb0uNE70EcluwPNDjtutFxH9ZXLnVILWvzV9LHqQjENdXJ4zh+JwIhnktRZ+CnCsVxlRoLGSI5GktMaaNjqk12k/gAG5B70Sh1wSDWopXdYXj+HwJezfL/BH6XFkCWQjQ3aGLJIskGydrLmoLWS3XqYAf8LHVgyvLhECXAAAAAASUVORK5CYII=" @@ -53,15 +65,7 @@ foreach ($Profile in $HostProfiles) { } } -$Title = "Host Profile Compliance" -$Header = "List of host profiles and compliance status" -$Comments = "" -$Display = "Table" -$Author = "John Sneddon" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" - # Table formatting rules - requires formatting modification $TableFormat = @{"Compliant" = @(@{ "-eq `$true" = "Cell,cid|OK|16x16"; }, @{ "-eq `$false" = "Cell,cid|Error|16x16" }) - } + } \ No newline at end of file diff --git a/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 b/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 index da0080d5..c983e2c4 100644 --- a/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 +++ b/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 @@ -1,8 +1,18 @@ +$Title = "Hosts with Upcoming Certificate Expiration" +$Comments = "The following hosts have certificates that will expire soon and will need to be replaced." +$Display = "Table" +$Author = "" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # How many days to warn before cert expiration (Default 60) $WarningDays = 60 # End of Settings +# Update settings where there is an override +$WarningDays = Get-vCheckSetting $Title "WarningDays" $WarningDays + # Changelog ## 1.1 : Added filter for connected Hosts only @@ -80,13 +90,6 @@ namespace PKI { # Plugin to report on upcoming host certificate expirations # Check for Host Certificates -$report = $VMH | Where {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Foreach { Test-WebServerSSL -URL $_.Name | Select OriginalURi, Issuer, @{N="Expires";E={$_.Certificate.NotAfter} }, @{N="DaysTillExpire";E={(New-TimeSpan -Start (Get-Date) -End ($_.Certificate.NotAfter)).Days} }|? {$_.DaysTillExpire -le $WarningDays}} -$report +$VMH | Where {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Foreach { Test-WebServerSSL -URL $_.Name | Select OriginalURi, Issuer, @{N="Expires";E={$_.Certificate.NotAfter} }, @{N="DaysTillExpire";E={(New-TimeSpan -Start (Get-Date) -End ($_.Certificate.NotAfter)).Days} }|? {$_.DaysTillExpire -le $WarningDays}} -$Title = "Hosts with Upcoming Certificate Expiration" -$Header = "Hosts with upcoming Certificate Expirations: $WarningDays Days" -$Comments = "The following hosts have certificates that will expire soon and will need to be replaced." -$Display = "Table" -$Author = "" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$Header = ("Hosts with upcoming Certificate Expirations: {0} Days" -f $WarningDays) \ No newline at end of file diff --git a/Plugins/30 Host/16 Host Swapfile datastores.ps1 b/Plugins/30 Host/16 Host Swapfile datastores.ps1 index f1effc3e..4823e327 100644 --- a/Plugins/30 Host/16 Host Swapfile datastores.ps1 +++ b/Plugins/30 Host/16 Host Swapfile datastores.ps1 @@ -1,29 +1,27 @@ -# Start of Settings -# End of Settings - -$cluswap = @() -foreach ($clusview in $clusviews) { - if ($clusview.ConfigurationEx.VmSwapPlacement -eq "hostLocal") { - $CluNodes = $VMH | where {$clusview.Host -contains $_.Id } - foreach ($CluNode in $CluNodes) { - if ($CluNode.VMSwapfileDatastore.Name -eq $null){ - if ($CluNode.ExtensionData.Config.LocalSwapDatastore.Value) { - $Details = "" | Select-Object Cluster, Host, Message - $Details.cluster = $clusview.name - $Details.host = $CluNode.name - $Details.Message = "Swap file location NOT SET" - $cluswap += $Details - } - } - } - } -} -$cluswap | sort name - $Title = "Host Swapfile datastores" -$Header = "Host Swapfile datastores not set : $(@($cluswap).count)" +$Header = "Host Swapfile datastores not set : [count]" $Comments = "The following hosts are in a cluster which is set to store the swap file in the datastore specified by the host but no location has been set on the host" $Display = "Table" $Author = "Alan Renouf" $PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +foreach ($clusview in $clusviews) { + if ($clusview.ConfigurationEx.VmSwapPlacement -eq "hostLocal") { + $CluNodes = $VMH | where {$clusview.Host -contains $_.Id } + foreach ($CluNode in $CluNodes) { + if ($CluNode.VMSwapfileDatastore.Name -eq $null){ + if ($CluNode.ExtensionData.Config.LocalSwapDatastore.Value) { + New-Object PSObject -Property @{ + Cluster = $clusview.name + Host = $CluNode.name + Message = "Swap file location NOT SET" + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 b/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 index 77a20a3f..f23b0600 100644 --- a/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 +++ b/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 @@ -1,16 +1,13 @@ -# Start of Settings -# End of Settings - -$ESXiTechMode = @() -$ESXiTechMode += $VMH | Where { ($_.Version -lt 4.1) -and ($_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance") -and ($_.ExtensionData.Summary.Config.Product.Name -match "i")} | Select Name, @{N="TechSuportModeEnabled";E={($_ | Get-AdvancedSetting -Name VMkernel.Boot.techSupportMode).value}} -$ESXiTechMode += $VMH | Where { $_.Version -ge "4.1.0" } | Where {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Select Name, @{N="TechSuportModeEnabled";E={($_ | Get-VMHostService | Where {$_.key -eq "TSM"}).Running}} -$Result = @($ESXiTechMode | Where { $_.TechSuportModeEnabled -eq "True" }) -$Result - $Title = "ESXi with Technical Support mode or ESXi Shell enabled" -$Header = "ESXi Hosts with Tech Support Mode or ESXi Shell Enabled : $(@($Result).count)" +$Header = "ESXi Hosts with Tech Support Mode or ESXi Shell Enabled : [count]" $Comments = "The following ESXi Hosts have Technical support mode or ESXi Shell enabled, this may not be the best security option, see here for more information: Yellow-Bricks Disable Tech Support on ESXi." $Display = "Table" $Author = "Alan Renouf" $PluginVersion = 1.3 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$VMH | Where { ($_.Version -lt 4.1) -and ($_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance") -and ($_.ExtensionData.Summary.Config.Product.Name -match "i")} | Select Name, @{N="TechSuportModeEnabled";E={($_ | Get-AdvancedSetting -Name VMkernel.Boot.techSupportMode).value}} | Where { $_.TechSuportModeEnabled -eq "True" } +$VMH | Where { $_.Version -ge "4.1.0" } | Where {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Select Name, @{N="TechSuportModeEnabled";E={($_ | Get-VMHostService | Where {$_.key -eq "TSM"}).Running}} | Where { $_.TechSuportModeEnabled -eq "True" } \ No newline at end of file diff --git a/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 b/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 index 945e3a7a..b0a3ff6f 100644 --- a/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 +++ b/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 @@ -1,11 +1,3 @@ -# Start of Settings -# End of Settings - -$VMH | Where {@("Connected","Maintenance") -contains $_.ConnectionState -and - $_.ExtensionData.Summary.Config.Product.Name -match "i" -and - -not $_.ExtensionData.Config.AdminDisabled} | ` - Select Name, @{N="LockedMode";E={$_.ExtensionData.Config.AdminDisabled}} - $Title = "ESXi hosts which do not have Lockdown mode enabled" $Header = "ESXi Hosts with Lockdown Mode not Enabled: [count]" $Comments = "The following ESXi Hosts do not have lockdown enabled, think about using lockdown as an extra security feature." @@ -13,3 +5,11 @@ $Display = "Table" $Author = "Alan Renouf" $PluginVersion = 1.1 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$VMH | Where {@("Connected","Maintenance") -contains $_.ConnectionState -and + $_.ExtensionData.Summary.Config.Product.Name -match "i" -and + -not $_.ExtensionData.Config.AdminDisabled} | ` + Select Name, @{N="LockedMode";E={$_.ExtensionData.Config.AdminDisabled}} \ No newline at end of file diff --git a/Plugins/30 Host/31 NTP Name and Service.ps1 b/Plugins/30 Host/31 NTP Name and Service.ps1 index e52b0968..be2233a4 100644 --- a/Plugins/30 Host/31 NTP Name and Service.ps1 +++ b/Plugins/30 Host/31 NTP Name and Service.ps1 @@ -1,10 +1,3 @@ -# Start of Settings -# The NTP server which should be set on your hosts (comma-separated) -$ntpserver = "pool.ntp.org,pool2.ntp.org" -# End of Settings - -@($VMH | Where {$_.Connectionstate -ne "Disconnected"} | Select Name, @{N="NTPServer";E={($_ | Get-VMHostNtpServer) -join ","}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver}) - $Title = "NTP Name and Service" $Header = "NTP Issues: [count]" $Comments = "The following hosts do not have the correct NTP settings and may cause issues if the time becomes far apart from the vCenter/Domain or other hosts" @@ -12,3 +5,10 @@ $Display = "Table" $Author = "Alan Renouf" $PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# The NTP server which should be set on your hosts (comma-separated) +$ntpserver = "pool.ntp.org,pool2.ntp.org" +# End of Settings + +@($VMH | Where {$_.Connectionstate -ne "Disconnected"} | Select Name, @{N="NTPServer";E={($_ | Get-VMHostNtpServer) -join ","}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver}) \ No newline at end of file diff --git a/Plugins/30 Host/35 Host Configuration Issues.ps1 b/Plugins/30 Host/35 Host Configuration Issues.ps1 index 050d2d7c..d7b6742d 100644 --- a/Plugins/30 Host/35 Host Configuration Issues.ps1 +++ b/Plugins/30 Host/35 Host Configuration Issues.ps1 @@ -1,25 +1,25 @@ +$Title = "Host Configuration Issues" +$Header = "Host(s) Config Issue(s): [count]" +$Comments = "The following configuration issues have been registered against Hosts in vCenter" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings $hostcialarms = @() foreach ($HostsView in $HostsViews) { - if ($HostsView.ConfigIssue) { - $HostConfigIssues = $HostsView.ConfigIssue - Foreach ($HostConfigIssue in $HostConfigIssues) { - $Details = "" | Select-Object Name, Message - $Details.Name = $HostsView.name - $Details.Message = $HostConfigIssue.FullFormattedMessage - $hostcialarms += $Details - } - } + if ($HostsView.ConfigIssue) { + $HostConfigIssues = $HostsView.ConfigIssue + Foreach ($HostConfigIssue in $HostConfigIssues) { + $Details = "" | Select-Object Name, Message + $Details.Name = $HostsView.name + $Details.Message = $HostConfigIssue.FullFormattedMessage + $hostcialarms += $Details + } + } } -$hostcialarms | sort name - -$Title = "Host Configuration Issues" -$Header = "Host(s) Config Issue(s): $(@($hostcialarms).Count)" -$Comments = "The following configuration issues have been registered against Hosts in vCenter" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$hostcialarms | sort name \ No newline at end of file diff --git a/Plugins/30 Host/36 Host Alarms.ps1 b/Plugins/30 Host/36 Host Alarms.ps1 index 2fe7c27c..8921af91 100644 --- a/Plugins/30 Host/36 Host Alarms.ps1 +++ b/Plugins/30 Host/36 Host Alarms.ps1 @@ -1,3 +1,11 @@ +$Title = "Host Alarms" +$Header = "Host(s) Alarm(s): [count]" +$Comments = "The following alarms have been registered against hosts in vCenter" +$Display = "Table" +$Author = "Alan Renouf, John Sneddon" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings @@ -13,14 +21,6 @@ foreach ($HostsView in ($HostsViews | Where {$_.TriggeredAlarmState} | Sort-Obje } | Select Object, Alarm, Status, Time } } - -$Title = "Host Alarms" -$Header = "Host(s) Alarm(s): [count]]" -$Comments = "The following alarms have been registered against hosts in vCenter" -$Display = "Table" -$Author = "Alan Renouf, John Sneddon" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" -$TableFormat = @{"Status" = @(@{ "-eq 'yellow'" = "Row,class|warning"; }, +$TableFormat = @{"Status" = @(@{ "-eq 'yellow'" = "Row,class|warning"; }, @{ "-eq 'red'" = "Row,class|critical" })} diff --git a/Plugins/30 Host/44 VMKernel Warnings.ps1 b/Plugins/30 Host/44 VMKernel Warnings.ps1 index de37314a..5d1369e9 100644 --- a/Plugins/30 Host/44 VMKernel Warnings.ps1 +++ b/Plugins/30 Host/44 VMKernel Warnings.ps1 @@ -1,62 +1,65 @@ +$Title = "VMKernel Warnings" +$Header = "ESX/ESXi VMKernel Warnings: [count]" +$Comments = "The following VMKernel issues were found, it is suggested all unknown issues are explored on the VMware Knowledge Base. Use the below links to automatically search for the string" +$Display = "Table" +$Author = "Alan Renouf, Frederic Martin" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Disabling displaying Google/KB links in order to have wider message column $simpleWarning = $true # End of Settings +# Update settings where there is an override +$simpleWarning = Get-vCheckSetting $Title "simpleWarning" $simpleWarning + $VMKernelWarnings = @() foreach ($VMHost in ($HostsViews)){ - $product = $VMHost.config.product.ProductLineId - if ($product -eq "embeddedEsx" -and $VIVersion -lt 5){ - $Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries |where {$_ -match "warning" -and $_ -match "vmkernel"} - if ($Warnings -ne $null) { - $VMKernelWarning = @() - $Warnings | % { - if ($simpleWarning) { - $Details = "" | Select-Object VMHost, Message - $Details.VMHost = $VMHost.Name - $Details.Message = $_ - } else { - $Details = "" | Select-Object VMHost, Message, Length, KBSearch, Google - $Details.VMHost = $VMHost.Name - $Details.Message = $_ - $Details.Length = ($Details.Message).Length - $Details.KBSearch = "Click Here" - $Details.Google = "Click Here" - } - $VMKernelWarning += $Details - } - $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google - } - } else { - $Warnings = (Get-Log -VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$_ -match "warning"} - if ($Warnings -ne $null) { - $VMKernelWarning = @() - $Warnings | Foreach { - if ($simpleWarning) { - $Details = "" | Select-Object VMHost, Message - $Details.VMHost = $VMHost.Name - $Details.Message = $_ - } else { - $Details = "" | Select-Object VMHost, Message, Length, KBSearch, Google - $Details.VMHost = $VMHost.Name - $Details.Message = $_ - $Details.Length = ($Details.Message).Length - $Details.KBSearch = "Click Here" - $Details.Google = "Click Here" - } - $VMKernelWarning += $Details - } - $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google - } - } -} - -$VMKernelWarnings | sort Message -Descending + $product = $VMHost.config.product.ProductLineId + if ($product -eq "embeddedEsx" -and $VIVersion -lt 5){ + $Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries |where {$_ -match "warning" -and $_ -match "vmkernel"} + if ($Warnings -ne $null) { + $VMKernelWarning = @() + $Warnings | % { + if ($simpleWarning) { + $Details = "" | Select-Object VMHost, Message + $Details.VMHost = $VMHost.Name + $Details.Message = $_ + } else { + $Details = "" | Select-Object VMHost, Message, Length, KBSearch, Google + $Details.VMHost = $VMHost.Name + $Details.Message = $_ + $Details.Length = ($Details.Message).Length + $Details.KBSearch = "Click Here" + $Details.Google = "Click Here" + } + $VMKernelWarning += $Details + } + $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google + } + } else { + $Warnings = (Get-Log -VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$_ -match "warning"} + if ($Warnings -ne $null) { + $VMKernelWarning = @() + $Warnings | Foreach { + if ($simpleWarning) { + $Details = "" | Select-Object VMHost, Message + $Details.VMHost = $VMHost.Name + $Details.Message = $_ + } else { + $Details = "" | Select-Object VMHost, Message, Length, KBSearch, Google + $Details.VMHost = $VMHost.Name + $Details.Message = $_ + $Details.Length = ($Details.Message).Length + $Details.KBSearch = "Click Here" + $Details.Google = "Click Here" + } + $VMKernelWarning += $Details + } + $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google + } + } +} -$Title = "VMKernel Warnings" -$Header = "ESX/ESXi VMKernel Warnings: $(@($VMKernelWarnings).Count)" -$Comments = "The following VMKernel issues were found, it is suggested all unknown issues are explored on the VMware Knowledge Base. Use the below links to automatically search for the string" -$Display = "Table" -$Author = "Alan Renouf, Frederic Martin" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" +$VMKernelWarnings | sort Message -Descending \ No newline at end of file diff --git a/Plugins/30 Host/46 Missing ESX patches.ps1 b/Plugins/30 Host/46 Missing ESX patches.ps1 index 2b137bf4..6ce51efc 100644 --- a/Plugins/30 Host/46 Missing ESX patches.ps1 +++ b/Plugins/30 Host/46 Missing ESX patches.ps1 @@ -1,3 +1,11 @@ +$Title = "Missing ESX(i) updates and patches" +$Header = "Missing ESX(i) updates and patches: [count]" +$Comments = "The following updates and/or patches are not applied." +$Display = "Table" +$Author = "Luc Dekens" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings @@ -5,25 +13,13 @@ # https://communities.vmware.com/community/vmtn/automationtools/powercli/updatemanager # (Current version 5.1 locks up in PowerShell v3; use "-version 2" when launching.) -$Results = @() - If (Get-PSSnapin Vmware.VumAutomation -ErrorAction SilentlyContinue) { - foreach($esx in $VMH){ - foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where {$_.Status -eq "NotCompliant"})){ - $Results = $baseline.NotCompliantPatches | - select @{N="Host";E={$esx.Name}}, - @{N="Baseline";E={$baseline.Baseline.Name}},Name,ReleaseDate,IdByVendor, - @{N="KB";E={(Select-String "(?http://[\w|\.|/]*\w{1})" -InputObject $_.Description).Matches[0].Groups['url'].Value}} - } - } + foreach($esx in $VMH){ + foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where {$_.Status -eq "NotCompliant"})){ + $baseline.NotCompliantPatches | + select @{N="Host";E={$esx.Name}}, + @{N="Baseline";E={$baseline.Baseline.Name}},Name,ReleaseDate,IdByVendor, + @{N="KB";E={(Select-String "(?http://[\w|\.|/]*\w{1})" -InputObject $_.Description).Matches[0].Groups['url'].Value}} + } + } } - -$Results - -$Title = "Missing ESX(i) updates and patches" -$Header = "Missing ESX(i) updates and patches: $(@($Results).Count)" -$Comments = "The following updates and/or patches are not applied." -$Display = "Table" -$Author = "Luc Dekens" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" diff --git a/Plugins/30 Host/51 Syslog Name.ps1 b/Plugins/30 Host/51 Syslog Name.ps1 index 400e4ebf..cf468c25 100644 --- a/Plugins/30 Host/51 Syslog Name.ps1 +++ b/Plugins/30 Host/51 Syslog Name.ps1 @@ -1,14 +1,17 @@ -# Start of Settings -# The Syslog server which should be set on your hosts -$SyslogServer = "syslogserver" -# End of Settings - -@($VMH | Where-Object {$_.ExtensionData.Summary.Config.Product.Name -eq 'VMware ESXi'} | Select-Object Name,@{Name='SyslogServer';Expression = {($_ | Get-VMHostSysLogServer).Host}},@{Name='SyslogSetting';Expression = {($_ | Get-AdvancedSetting -Name Syslog.Local.DatastorePath).Value| Where-Object {$_ -ne $NULL}}} | Where-Object {$_.SyslogServer -ne $SyslogServer -and $_.SyslogSetting -ne $SyslogServer}) -$PluginCategory = "vSphere" - $Title = "Syslog Name" $Header = "Syslog Issues" $Comments = "The following hosts do not have the correct Syslog settings which may cause issues if ESXi hosts experience issues and logs need to be investigated" $Display = "Table" $Author = "Jonathan Medd" $PluginVersion = 1.1 +$PluginCategory = "vSphere" + +# Start of Settings +# The Syslog server which should be set on your hosts +$SyslogServer = "syslogserver" +# End of Settings + +# Update settings where there is an override +$SyslogServer = Get-vCheckSetting $Title "SyslogServer" $SyslogServer + +@($VMH | Where-Object {$_.ExtensionData.Summary.Config.Product.Name -eq 'VMware ESXi'} | Select-Object Name,@{Name='SyslogServer';Expression = {($_ | Get-VMHostSysLogServer).Host}},@{Name='SyslogSetting';Expression = {($_ | Get-AdvancedSetting -Name Syslog.Local.DatastorePath).Value| Where-Object {$_ -ne $NULL}}} | Where-Object {$_.SyslogServer -ne $SyslogServer -and $_.SyslogSetting -ne $SyslogServer}) \ No newline at end of file diff --git a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 index 73f0d64f..5d72c362 100644 --- a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 +++ b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 @@ -1,46 +1,43 @@ -# Start of Settings -# End of Settings - -$HWalarms = @() -foreach ($HostsView in ($HostsViews|?{$_.runtime.connectionstate -eq "Connected"})) { - $HealthStatus = ((Get-View ($HostsView).ConfigManager.HealthStatusSystem).runtime) - $HWStatus = $HealthStatus.HardwareStatusInfo - if ($HWStatus) { - $HWStatusProp = $HWStatus|gm|?{$_.membertype -eq "property"} - $HWStatusDetails = $HWStatusProp|%{$HWStatus.($_.name)}|?{$_.status.key -inotmatch "green" -band $_.status.key -inotmatch "unknown"}|select @{N="sensor";E={$_.name}},@{N="status";E={$_.status.key}} - $HealthStatusDetails = ($HealthStatus.SystemHealthInfo).NumericSensorInfo|?{$_.HealthState.key -inotmatch "green" -band $_.HealthState.key -inotmatch "unknown"}|select @{N="sensor";E={$_.name}},@{N="status";E={$_.HealthState.key}} - if ($HWStatusDetails) { - foreach ($HWStatusDetail in $HWStatusDetails) { - $Details = "" | Select-Object Cluster, Host, Sensor, Status - $Details.Cluster = $HostsView | %{(Get-View $_.Parent).Name} - $Details.Host = $HostsView.name - $Details.Sensor = $HWStatusDetail.sensor - $Details.Status = $HWStatusDetail.status - $HWalarms += $Details - } - } - if ($HealthStatusDetails) { - foreach ($HealthStatusDetail in $HealthStatusDetails) { - $Details = "" | Select-Object Cluster, Host, Sensor, Status - $Details.Cluster = $HostsView | %{(Get-View $_.Parent).Name} - $Details.Host = $HostsView.name - $Details.Sensor = $HealthStatusDetail.sensor - $Details.Status = $HealthStatusDetail.status - $HWalarms += $Details - } - } - } - Remove-Variable -name "HWStatus" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue - Remove-Variable -name "HWStatusDetails" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue - Remove-Variable -name "HealthStatusDetails" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -} - -$HWalarms - $Title = "Hardware status warnings/errors" $Header = "Hardware status warnings/errors" $Comments = "Details can be found in the Hardware Status tab" $Display = "Table" $Author = "Raphael Schitz" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +foreach ($HostsView in ($HostsViews|?{$_.runtime.connectionstate -eq "Connected"})) { + $HealthStatus = ((Get-View ($HostsView).ConfigManager.HealthStatusSystem).runtime) + $HWStatus = $HealthStatus.HardwareStatusInfo + if ($HWStatus) { + $HWStatusProp = $HWStatus|gm|?{$_.membertype -eq "property"} + $HWStatusDetails = $HWStatusProp|%{$HWStatus.($_.name)}|?{$_.status.key -inotmatch "green" -band $_.status.key -inotmatch "unknown"}|select @{N="sensor";E={$_.name}},@{N="status";E={$_.status.key}} + $HealthStatusDetails = ($HealthStatus.SystemHealthInfo).NumericSensorInfo|?{$_.HealthState.key -inotmatch "green" -band $_.HealthState.key -inotmatch "unknown"}|select @{N="sensor";E={$_.name}},@{N="status";E={$_.HealthState.key}} + if ($HWStatusDetails) { + foreach ($HWStatusDetail in $HWStatusDetails) { + New-Object PSObject -Property @{ + $Details.Cluster = $HostsView | %{(Get-View $_.Parent).Name} + $Details.Host = $HostsView.name + $Details.Sensor = $HWStatusDetail.sensor + $Details.Status = $HWStatusDetail.status + } + } + } + if ($HealthStatusDetails) { + foreach ($HealthStatusDetail in $HealthStatusDetails) { + New-Object PSObject -Property @{ + $Details.Cluster = $HostsView | %{(Get-View $_.Parent).Name} + $Details.Host = $HostsView.name + $Details.Sensor = $HealthStatusDetail.sensor + $Details.Status = $HealthStatusDetail.status + } + } + } + } + Remove-Variable -name "HWStatus" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue + Remove-Variable -name "HWStatusDetails" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue + Remove-Variable -name "HealthStatusDetails" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue +} \ No newline at end of file diff --git a/Plugins/30 Host/57 Hosts with reboot required.ps1 b/Plugins/30 Host/57 Hosts with reboot required.ps1 index ac5a1a07..70385b1f 100644 --- a/Plugins/30 Host/57 Hosts with reboot required.ps1 +++ b/Plugins/30 Host/57 Hosts with reboot required.ps1 @@ -1,13 +1,13 @@ -# Start of Settings -# End of Settings - -$Result = @($VMH | Where-Object {$_.ExtensionData.Summary.RebootRequired} | Select-Object -Property Name, State) -$Result - $Title = "Hosts with reboot required" -$Header = "Hosts with reboot required : $(@($Result).count)" +$Header = "Hosts with reboot required : [count]" $Comments = "The following hosts require a reboot." $Display = "Table" $Author = "Robert van den Nieuwendijk" $PluginVersion = 1.1 $PluginCategory = "vSphere" + + +# Start of Settings +# End of Settings + +$VMH | Where-Object {$_.ExtensionData.Summary.RebootRequired} | Select-Object -Property Name, State \ No newline at end of file diff --git a/Plugins/30 Host/67 Host OS Pivot Table.ps1 b/Plugins/30 Host/67 Host OS Pivot Table.ps1 index 9b799b76..98c239af 100644 --- a/Plugins/30 Host/67 Host OS Pivot Table.ps1 +++ b/Plugins/30 Host/67 Host OS Pivot Table.ps1 @@ -1,9 +1,3 @@ -# Start of Settings -# End of Settings - -$HostsViews | Group-Object {$_.Summary.config.product.fullname} | ` - Select @{Name="Version";Expression={$_.Name}}, Count | Sort-Object Count -Descending - $Title = "Host Build versions in use" $Header = "Host Build versions in use" $Comments = "The following host builds are in use in this vCenter" @@ -11,3 +5,9 @@ $Display = "Table" $Author = "Frederic Martin" $PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$HostsViews | Group-Object {$_.Summary.config.product.fullname} | ` + Select @{Name="Version";Expression={$_.Name}}, Count | Sort-Object Count -Descending \ No newline at end of file diff --git a/Plugins/30 Host/68 Disk Max Total Latency.ps1 b/Plugins/30 Host/68 Disk Max Total Latency.ps1 index c118e881..ed579874 100644 --- a/Plugins/30 Host/68 Disk Max Total Latency.ps1 +++ b/Plugins/30 Host/68 Disk Max Total Latency.ps1 @@ -1,44 +1,49 @@ +$Title = "Disk Max Total Latency" +$Display = "Table" +$Author = "Raphael Schitz, Frederic Martin" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # Disk Max Total Latency Settings in Milliseconds $diskmaxtotallatency = "50" -# Disk Max Total Latency range to inspect (1-24) +# Disk Max Total Latency range to inspect (1-24) Hours $stattotallatency = "24" # End of Settings +# Update settings where there is an override +$diskmaxtotallatency = Get-vCheckSetting $Title "diskmaxtotallatency" $diskmaxtotallatency +$stattotallatency = Get-vCheckSetting $Title "stattotallatency" $stattotallatency + $HostsDiskLatency = @() foreach ($VMHost in $VMH | ?{$_.ConnectionState -eq "Connected"}) { - if ($VMHost.Version -lt 4){continue}# not an esx 4.x host - $HostDiskLatency = @() - $VHHMaxLatency = $VMHost | get-stat -stat "disk.maxTotalLatency.latest" -start ($Date).addhours(-$stattotallatency) -finish ($Date)|?{$_.value -gt $diskmaxtotallatency}|sort Timestamp -Descending - if ($VHHMaxLatency.Count -gt 0) { - $Details = "" | Select-Object Host, Timestamp, milliseconds - $Details.host = $VMHost.name - $Details.Timestamp = $VHHMaxLatency[0].Timestamp - $Details.milliseconds = $VHHMaxLatency[0].Value - $HostDiskLatency += $Details - if ($VHHMaxLatency.Count -gt 2) { - $vmhlatid = [int]"1" - while ($vmhlatid -cle $VHHMaxLatency.Count-2) { - if (($VHHMaxLatency[$vmhlatid].timestamp).addminutes(5) -gt $Details.Timestamp -or ($VHHMaxLatency[$vmhlatid].timestamp).addminutes(-5) -gt $Details.Timestamp) { # keeps only high values strictly <> 5 min to avoid flood period - $Details = "" | Select-Object Host, Timestamp, milliseconds - $Details.host = $VMHost.name - $Details.Timestamp = $VHHMaxLatency[$vmhlatid].Timestamp - $Details.milliseconds = $VHHMaxLatency[$vmhlatid].Value - $HostDiskLatency += $Details - } - $vmhlatid++ - } - } - } - $HostsDiskLatency += $HostDiskLatency + if ($VMHost.Version -lt 4){continue}# not an esx 4.x host + $HostDiskLatency = @() + $VHHMaxLatency = $VMHost | get-stat -stat "disk.maxTotalLatency.latest" -start ($Date).addhours(-$stattotallatency) -finish ($Date)|?{$_.value -gt $diskmaxtotallatency}|sort Timestamp -Descending + if ($VHHMaxLatency.Count -gt 0) { + $Details = "" | Select-Object Host, Timestamp, milliseconds + $Details.host = $VMHost.name + $Details.Timestamp = $VHHMaxLatency[0].Timestamp + $Details.milliseconds = $VHHMaxLatency[0].Value + $HostDiskLatency += $Details + if ($VHHMaxLatency.Count -gt 2) { + $vmhlatid = [int]"1" + while ($vmhlatid -cle $VHHMaxLatency.Count-2) { + if (($VHHMaxLatency[$vmhlatid].timestamp).addminutes(5) -gt $Details.Timestamp -or ($VHHMaxLatency[$vmhlatid].timestamp).addminutes(-5) -gt $Details.Timestamp) { # keeps only high values strictly <> 5 min to avoid flood period + $Details = "" | Select-Object Host, Timestamp, milliseconds + $Details.host = $VMHost.name + $Details.Timestamp = $VHHMaxLatency[$vmhlatid].Timestamp + $Details.milliseconds = $VHHMaxLatency[$vmhlatid].Value + $HostDiskLatency += $Details + } + $vmhlatid++ + } + } + } + $HostsDiskLatency += $HostDiskLatency } $HostsDiskLatency -$Title = "Disk Max Total Latency" -$Header = "Disk Max Total Latency over $diskmaxtotallatency" -$Comments = "Check VM per LUN dispatch and esxtop for very high values over $diskmaxtotallatency" -$Display = "Table" -$Author = "Raphael Schitz, Frederic Martin" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$Header = ("Disk Max Total Latency over {0}ms" -f $diskmaxtotallatency) +$Comments = ("Check VM per LUN dispatch and esxtop for very high values over {0}ms" -f $diskmaxtotallatency) \ No newline at end of file diff --git a/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 b/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 index 22752a3e..ff0c3f54 100644 --- a/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 +++ b/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 @@ -1,3 +1,11 @@ +$Title = "Network redundancy lost" +$Header = "Network redundancy lost: [count]" +$Comments = "The following Hosts have lost network redundancy" +$Display = "Table" +$Author = "Olivier TABUT" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings @@ -5,16 +13,6 @@ $vsList = Get-VirtualSwitch foreach ($VMHost in $VMH) { foreach($pnic in $VMHost.ExtensionData.Config.Network.Pnic){ $vSw = $vsList | where {($_.VMHost -eq $VMHost) -and ($_.Nic -contains $pNic.Device)} - $result = $pnic | Select @{N="ESXname";E={$VMHost.Name}},@{N="pNic";E={$pnic.Device}},@{N="vSwitch";E={$vSw.Name}},@{N="Status";E={if($pnic.LinkSpeed -ne $null){"up"}else{"down"}}} - if (($result.vSwitch -ne $null) -and ($result.status -eq "down")) {$result} + $pnic | Select @{N="ESXname";E={$VMHost.Name}},@{N="pNic";E={$pnic.Device}},@{N="vSwitch";E={$vSw.Name}},@{N="Status";E={if($pnic.LinkSpeed -ne $null){"up"}else{"down"}}} | Where {$_.Status -eq "down"} } -} - - -$Title = "Network redundancy lost" -$Header = "Network redundancy lost: $(@($Result).Count)" -$Comments = "The following Hosts have lost network redundancy" -$Display = "Table" -$Author = "Olivier TABUT" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +} \ No newline at end of file diff --git a/Plugins/30 Host/75 Hosts with Different Hostnames.ps1 b/Plugins/30 Host/75 Hosts with Different Hostnames.ps1 index 8a8c9101..de7eb193 100644 --- a/Plugins/30 Host/75 Hosts with Different Hostnames.ps1 +++ b/Plugins/30 Host/75 Hosts with Different Hostnames.ps1 @@ -1,13 +1,12 @@ -# Start of Settings -# End of Settings - -$report = @($VMH | Where-Object {$_.Name.Split('.')[0] -ne $_.NetworkInfo.HostName} | Select-Object -Property Name,@{Name="HostName";Expression={$_.NetworkInfo.HostName}} | Sort-Object -Property Name) -$report - $Title = "Hosts with different hostname" -$Header = "Hosts with different hostname: $($Report.Count)" +$Header = "Hosts with different hostname: [count]" $Comments = "The following hosts have a different hostname than their name in the vCenter Server. This might give troubles with HA." $Display = "Table" $Author = "Robert van den Nieuwendijk" $PluginVersion = 1.0 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$VMH | Where-Object {$_.Name.Split('.')[0] -ne $_.NetworkInfo.HostName} | Select-Object -Property Name,@{Name="HostName";Expression={$_.NetworkInfo.HostName}} | Sort-Object -Property Name \ No newline at end of file diff --git a/Plugins/30 Host/77 Lost Access to Volume.ps1 b/Plugins/30 Host/77 Lost Access to Volume.ps1 index a09185fd..395ff36b 100644 --- a/Plugins/30 Host/77 Lost Access to Volume.ps1 +++ b/Plugins/30 Host/77 Lost Access to Volume.ps1 @@ -1,18 +1,21 @@ +$Title = "Lost Access to Volume" +$Header = "Lost Access to Volume: [count]" +$Comments = "The following hosts have lost access to a volume. This may indicate a problem with your storage solution." +$Display = "Table" +$Author = "Robert van den Nieuwendijk, Jonathan Medd" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days of Lost Action Volume to report and count on $LostAccessVolumeAge = 1 # End of Settings +# Update settings where there is an override +$LostAccessVolumeAge = Get-vCheckSetting $Title "LostAccessVolumeAge" $LostAccessVolumeAge + +Get-VIEventPlus -Start ($Date).AddDays(-$LostAccessVolumeAge) | Where-Object {$_.GetType().Name -eq "EventEx" -and $_.EventTypeId -like "esx.problem.vmfs.heartbeat.*"} | Select-Object -Property @{Name="VMHost";Expression={$_.Host.Name}},CreatedTime,FullFormattedMessage | Sort-Object -Property VMHost,CreatedTime + # Changelog ## 1.1 : Correctly formatted the Start / End Settings and used $MaxSampleVIEvent which is defined in plugin 00 -## 1.2 : Update to use Get-VIEventPlus -$Result = @(Get-VIEventPlus -Start ($Date).AddDays(-$LostAccessVolumeAge) | Where-Object {$_.GetType().Name -eq "EventEx" -and $_.EventTypeId -like "esx.problem.vmfs.heartbeat.*"} | Select-Object -Property @{Name="VMHost";Expression={$_.Host.Name}},CreatedTime,FullFormattedMessage | Sort-Object -Property VMHost,CreatedTime) -$Result - -$Title = "Lost Access to Volume" -$Header = "Lost Access to Volume: $(@($Result | Where-Object {$_.FullFormattedMessage -like "Lost access to volume *"}).Count)" -$Comments = "The following hosts have lost access to a volume. This may indicate a problem with your storage solution." -$Display = "Table" -$Author = "Robert van den Nieuwendijk, Jonathan Medd" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +## 1.2 : Update to use Get-VIEventPlus \ No newline at end of file diff --git a/Plugins/30 Host/81 LUN Paths Check.ps1 b/Plugins/30 Host/81 LUN Paths Check.ps1 index 5046f820..99e6deee 100644 --- a/Plugins/30 Host/81 LUN Paths Check.ps1 +++ b/Plugins/30 Host/81 LUN Paths Check.ps1 @@ -1,46 +1,48 @@ +$Title = "Check LUNS have the recommended number of paths" +$Comments = "Not enough storage paths can effect storage availability in a FC SAN environment" +$Display = "Table" +$Author = "Craig Smith" +$PluginVersion = 1.0 +$PluginCategory = "vSphere" + # Start of Settings # Set the Recommended number of paths per LUN $RecLUNPaths = 2 # End of Settings +# Update settings where there is an override +$RecLUNPaths = Get-vCheckSetting $Title "RecLUNPaths" $RecLUNPaths + $missingpaths = @() foreach ($esxhost in ($HostsViews | where {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { #Write-Host $esxhost.Name - $lun_array = @() # 2D array - LUN Name & Path Count - $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.name -like "fc.*"} | %{ - $short_path_array = $_.name.split('-') - $short_path = $short_path_array[2] - $found = $false - foreach ($lun in $lun_array) { - if ($lun[0] -eq $short_path) { - $found = $true - $lun[1]++ - } - } - if (!($found)) { - $lun_array +=(,($short_path,1)) - } - } + $lun_array = @() # 2D array - LUN Name & Path Count + $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.name -like "fc.*"} | %{ + $short_path_array = $_.name.split('-') + $short_path = $short_path_array[2] + $found = $false + foreach ($lun in $lun_array) { + if ($lun[0] -eq $short_path) { + $found = $true + $lun[1]++ + } + } + if (!($found)) { + $lun_array +=(,($short_path,1)) + } + } - #Create report for ESX host - foreach ($lun in $lun_array) { - if ($lun[1] -lt $RecLUNPaths) { - #Write-Host "Alerting due to lack of paths (" $lun[1] "looking for" $RecLUNPaths "), for LUN: " $lun[0] - $myObj = "" | Select ESXHost, LUN , Paths - $myObj.ESXHost = $esxhost.Name - $myObj.LUN = $lun[0] - $myObj.Paths = $lun[1] - $missingpaths += $myObj - } - } + #Create report for ESX host + foreach ($lun in $lun_array) { + if ($lun[1] -lt $RecLUNPaths) { + #Write-Host "Alerting due to lack of paths (" $lun[1] "looking for" $RecLUNPaths "), for LUN: " $lun[0] + New-Object PSObject -Property @{ + ESXHost = $esxhost.Name + LUN = $lun[0] + Paths = $lun[1] + } + } + } } - -$missingpaths -$Title = "Check LUNS have the recommended number of paths" -$Header = "LUNs not having the recommended number of paths ($RecLUNPaths): $(@($missingpaths).count)" -$Comments = "Not enough storage paths can effect storage availability in a FC SAN environment" -$Display = "Table" -$Author = "Craig Smith" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +$Header = ("LUNs not having the recommended number of paths ({0}): [count]" -f $RecLUNPaths) diff --git a/Plugins/30 Host/83 Hosts not Connected or Alarms Disabled.ps1 b/Plugins/30 Host/83 Hosts not Connected or Alarms Disabled.ps1 index 83134f02..46f6f506 100644 --- a/Plugins/30 Host/83 Hosts not Connected or Alarms Disabled.ps1 +++ b/Plugins/30 Host/83 Hosts not Connected or Alarms Disabled.ps1 @@ -1,17 +1,16 @@ -# Start of Settings -# End of Settings - -$Hosts_notConnected_disabledAlarms = @($VMH | Select-Object Name,PowerState,ConnectionState,@{n='AlarmActionsEnabled';e={$_.ExtensionData.AlarmActionsEnabled}} | Where-Object { ($_.ConnectionState -ne 'Connected') -or ($_.AlarmActionsEnabled -ne 'True') } ) -$Hosts_notConnected_disabledAlarms - $Title = "Hosts not Connected or Alarms Disabled" -$Header = "Hosts not Connected or Alarms Disabled : $(@($Hosts_notConnected_disabledAlarms).count)" +$Header = "Hosts not Connected or Alarms Disabled : [count]" $Comments = "Shows hosts not in service and those with alarms disabled." $Display = "Table" $Author = "Chris Monahan" $PluginVersion = 1.0 $PluginCategory = "vSphere" +# Start of Settings +# End of Settings + +$VMH | Select-Object Name,PowerState,ConnectionState,@{n='AlarmActionsEnabled';e={$_.ExtensionData.AlarmActionsEnabled}} | Where-Object { ($_.ConnectionState -ne 'Connected') -or ($_.AlarmActionsEnabled -ne 'True') } + <# Essentially a hosts not happy report. Combines/replaces three plugins, "05 Hosts in Maintenance mode.ps1", "06 Hosts not responding or Disconnected.ps1" and "117 Hosts with Alarm disabled.ps1". diff --git a/Plugins/60 VM/66 Misnamed VM.ps1 b/Plugins/60 VM/66 Misnamed VM.ps1 index 8e0d8e31..da5e8886 100644 --- a/Plugins/60 VM/66 Misnamed VM.ps1 +++ b/Plugins/60 VM/66 Misnamed VM.ps1 @@ -1,28 +1,38 @@ -# Start of Settings -# Misnamed VMs, do not report on any VMs who are defined here -$MNDoNotInclude = "VM1_*|VM2_*" -# End of Settings - -$misnamed = @() -foreach ($vmguest in ($FullVM | Where {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name })) { - $myObj = "" | select Cluster,Folder,VMName,GuestName - $myObj.Cluster = (Get-VMHost -Id ($vmguest.Runtime.Host.Type + "-" + $vmguest.Runtime.Host.Value)).Parent.Name - $myObj.Folder = (Get-Folder -Id ($vmguest.Parent.Type + "-" + $vmguest.Parent.Value)).Name - $myObj.VMName = $vmguest.name - $myObj.GuestName = $vmguest.Guest.HostName - $misnamed += $myObj -} - -$misnamed | Sort-Object Folder,VMName - $Title = "Mis-named virtual machines" -$Header = "Mis-named virtual machines" +$Header = "[count] Mis-named virtual machines" $Comments = "The following guest names do not match the name inside of the guest." $Display = "Table" $Author = "Frederic Martin" $PluginVersion = 1.2 $PluginCategory = "vSphere" +# Start of Settings +# Misnamed VMs, do not report on any VMs who are defined here +$MNDoNotInclude = "VM1_*|VM2_*" +# End of Settings + +# Update settings where there is an override +$MNDoNotInclude = Get-vCheckSetting $Title "MNDoNotInclude" $MNDoNotInclude + +($FullVM | Where {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name }) | + foreach { + $vmguest = $_ + if ($vmguest.Parent -ne $null) + { + $Parent = (Get-Folder -Id $vmguest.Parent.ToString()).Name; + } + else + { + $Parent = (Get-vApp -Id $vmguest.ParentVApp.ToString()).Name; + } + New-Object PSObject -Property @{ + Cluster = (Get-VMHost -Id $vmguest.Runtime.Host.ToString()).Parent.Name + Folder = $Parent + VMName = $vmguest.name + GuestName = $vmguest.Guest.HostName + } + } | Sort-Object Folder,VMName + <# 20141002 monahancj - Added filter to exclude powered off VMs. Because powered off VMs aren't running the VMtools to get the guest host name it report as null and then potentially a false positive for a name diff --git a/vCheck.ps1 b/vCheck.ps1 index 203faa52..08bf6450 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -120,6 +120,20 @@ function Write-CustomOut ($Details) { Write-OutPut "[$($LogDate)] $Details" } +<# Placeholder for now, just return the setting passed to it. Eventually this + will be used for new settings handling #> +function Get-vCheckSetting +{ + param + ( + [string]$Module, + [string]$Setting, + $default + ) + + return $default +} + <# Search $file_content for name/value pair with ID_Name and return value #> Function Get-ID-String ($file_content, $ID_name) { if ($file_content | Select-String -Pattern "\$+$ID_name\s*=") { From 003126911108b181674502c8c565acb9211f8d86 Mon Sep 17 00:00:00 2001 From: Sneddo <> Date: Wed, 12 Oct 2016 15:58:52 +1100 Subject: [PATCH 20/50] Fixing merge conflict (I hope!) --- Plugins/60 VM/66 Misnamed VM.ps1 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Plugins/60 VM/66 Misnamed VM.ps1 b/Plugins/60 VM/66 Misnamed VM.ps1 index da5e8886..feac3b43 100644 --- a/Plugins/60 VM/66 Misnamed VM.ps1 +++ b/Plugins/60 VM/66 Misnamed VM.ps1 @@ -11,9 +11,6 @@ $PluginCategory = "vSphere" $MNDoNotInclude = "VM1_*|VM2_*" # End of Settings -# Update settings where there is an override -$MNDoNotInclude = Get-vCheckSetting $Title "MNDoNotInclude" $MNDoNotInclude - ($FullVM | Where {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name }) | foreach { $vmguest = $_ @@ -37,8 +34,7 @@ $MNDoNotInclude = Get-vCheckSetting $Title "MNDoNotInclude" $MNDoNotInclude 20141002 monahancj - Added filter to exclude powered off VMs. Because powered off VMs aren't running the VMtools to get the guest host name it report as null and then potentially a false positive for a name mismatch. - Added the columns Cluster and Folder, and sorted by folder and VM name, to make it easier to find a problem VM and decide if there is an urgent problem. For instance, I'm not gong to worry about a misnamed VM in the folder "testingstuff". -#> +#> \ No newline at end of file From a5ccbc57f65bfa88a8ccf0f9c4c7287f0cd97084 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Tue, 22 Nov 2016 12:42:10 +1100 Subject: [PATCH 21/50] Require Powershell v3 A decent compromise for Powershell version, v3 gives us a few nice to haves like ordered objects and better handling of object counts (i.e. no more casting to arrays to get a count for a single object). --- vCheck.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vCheck.ps1 b/vCheck.ps1 index c04fd15f..e66f9a76 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -30,7 +30,7 @@ .NOTES File Name : vCheck.ps1 Author : Alan Renouf - @alanrenouf - Version : 6.23 + Version : 6.24 Thanks to all who have commented on my blog to help improve this project all beta testers and previous contributors to this script. @@ -54,6 +54,7 @@ .PARAMETER job This parameter lets you specify an xml config file for this invokation #> +#Requires -Version 3.0 [CmdletBinding()] param ( [Switch]$config, @@ -1088,4 +1089,4 @@ if (-not $GUIConfig) { } #endregion output -} \ No newline at end of file +} From 6368be1e52fc655799d8bc49f3f8a9b043834664 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 24 Nov 2016 15:09:20 +1100 Subject: [PATCH 22/50] Move Plugins.xml Since we don't update it regularly anyway... will eventually automate the update on commits. --- vCheckUtils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vCheckUtils.ps1 b/vCheckUtils.ps1 index 2379c70a..0d88d514 100644 --- a/vCheckUtils.ps1 +++ b/vCheckUtils.ps1 @@ -1,5 +1,5 @@ $global:vCheckPath = $MyInvocation.MyCommand.Definition | Split-Path -$global:pluginXMLURL = "https://raw.github.com/alanrenouf/vCheck-vSphere/master/plugins.xml" +$global:pluginXMLURL = "https://vcheck.report/plugins.xml" $global:pluginURL = "https://raw.github.com/alanrenouf/vCheck-{0}/master/Plugins/{1}/{2}" <# From 754739a0fd1e9a17bf4b5c52df56a9795b37b979 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 24 Nov 2016 15:09:42 +1100 Subject: [PATCH 23/50] Delete plugins.xml --- plugins.xml | 855 ---------------------------------------------------- 1 file changed, 855 deletions(-) delete mode 100644 plugins.xml diff --git a/plugins.xml b/plugins.xml deleted file mode 100644 index d3635d4d..00000000 --- a/plugins.xml +++ /dev/null @@ -1,855 +0,0 @@ - - - Connection settings for vCenter - - - - - 1.5 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 - - - General Information - General details on the infrastructure - Alan Renouf, Frederic Martin - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/00 Initialize/01 General Information.ps1 - - - Checking VI Events - The following errors were logged in the vCenter Events tab, you may wish to investigate these - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/10 vCenter/23 VI Events.ps1 - - - VC Services - The following vCenter Services are not in the required state - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/10 vCenter/41 vCenter Services.ps1 - - - Windows vCenter Error Event Logs - The following errors were found in the vCenter Event Logs, you may wish to check these further - Alan Renouf - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/10 vCenter/42 Windows vCenter Error Event Logs.ps1 - - - Windows vCenter Warning Event Logs - The following warnings were found in the vCenter Event Logs, you may wish to check these further - Alan Renouf - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/10 vCenter/43 Windows vCenter Warning Event Logs.ps1 - - - vCenter Sessions Age - The following displays vCenter sessions that exceed the maximum session age ($MaxvCenterSessionAge Hour(s)). - Rudolf Kleijwegt - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/10 vCenter/47 vCenter Session Age.ps1 - - - vCenter License Report - The following displays licenses registered with this server and usage. - Justin Mercier - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/10 vCenter/82 License Report.ps1 - - - HA configuration issues - The following clusters have HA configuration issues. This will impact your disaster recovery. - John Sneddon - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/10 HA Configuration Issues.ps1 - - - Clusters Without Host Profile attached - The following clusters do not have a host profile attached - John Sneddon - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 - - - HA VMs restarted - The following VMs have been restarted by HA in the last $HAVMresetold days - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/15 HA VMs restarted.ps1 - - - DRS & SDRS Migrations - Multiple DRS Migrations may be an indication of overloaded hosts, check resource levels of the cluster - Alan Renouf, Jonathan Medd - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/17 DRS Migrations.ps1 - - - Cluster Slot Sizes - Slot sizes in the below cluster are less than is specified, this may cause issues with creating new VMs, for more information click here: <a href='http://www.yellow-bricks.com/vmware-high-availability-deepdiv/' target='_blank'>Yellow-Bricks HA Deep Dive</a> - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 - - - Cluster Configuration Issues - The following alarms have been registered against clusters in vCenter - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 - - - Datastore Consistency - Virtual Machines residing on these datastores will not be able to run on all hosts in the cluster - Robert Sexstone - 1.5 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/52 Datastore Consistency.ps1 - - - Clusters with DRS disabled - The following clusters have DRS disabled. This may impact the performance of your cluster. - Robert van den Nieuwendijk - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/55 Clusters with DRS Disabled.ps1 - - - Cluster Node version - Display per cluster nodes version if unique or mismatch - Raphael Schitz, Frederic Martin - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/70 Cluster Node Version.ps1 - - - QuickStats Capacity Planning - The following gives brief capacity information for each cluster based on QuickStats CPU/Mem usage and counting for HA failover requirements - Raphael Schitz, Frederic Martin - 1.4 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/71 Capacity Planning.ps1 - - - s/vMotion Information - s/vMotions and how long they took to migrate between hosts and datastores - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/72 s-vMotion Information.ps1 - - - More RAM than free space on Datastore - The following VMs can't vMotion because they have more RAM than free space on datastore - Olivier TABUT, Bob Cote - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 - - - DRS Rules - Contains all DRS rules defined in this vCenter - {0} - John Sneddon - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/20 Cluster/75 DRS Rules.ps1 - - - Hosts Overcommit state - Overcommitted hosts may cause issues with performance if memory is not issued when needed, this may cause ballooning and swapping - Alan Renouf - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/07 Hosts Overcommit State.ps1 - - - Hosts Dead LUN Path - Dead LUN Paths may cause issues with storage performance or be an indication of loss of redundancy - Alan Renouf, Frederic Martin - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 - - - ESXi Inode Exhaustion - The following hosts have an excessive amount of Inodes in use on the local ESXi filesystem. This can cause hosts to disconnect from vCenter and becoming completely unmanageable even locally, requiring a hard reboot. See <a href=` - Matthias Koehler - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/101 ESXi Inode Usage.ps1 - - - Host Profile Compliance - Failures - John Sneddon - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/105 Host Profile Compliance.ps1 - - - Hosts with Upcoming Certificate Expiration - The following hosts have certificates that will expire soon and will need to be replaced. - - - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 - - - Host Swapfile datastores - The following hosts are in a cluster which is set to store the swap file in the datastore specified by the host but no location has been set on the host - Alan Renouf - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/16 Host Swapfile datastores.ps1 - - - ESXi with Technical Support mode or ESXi Shell enabled - The following ESXi Hosts have Technical support mode or ESXi Shell enabled, this may not be the best security option, see here for more information: <a href='http://www.yellow-bricks.com/2010/03/01/disable-tech-support-on-esxi/' target='_blank'>Yellow-Bricks Disable Tech Support on ESXi</a>. - Alan Renouf - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 - - - ESXi hosts which do not have Lockdown mode enabled - The following ESXi Hosts do not have lockdown enabled, think about using lockdown as an extra security feature. - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 - - - NTP Name and Service - The following hosts do not have the correct NTP settings and may cause issues if the time becomes far apart from the vCenter/Domain or other hosts - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/31 NTP Name and Service.ps1 - - - Host Configuration Issues - The following configuration issues have been registered against Hosts in vCenter - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/35 Host Configuration Issues.ps1 - - - Host Alarms - The following alarms have been registered against hosts in vCenter - Alan Renouf, John Sneddon - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/36 Host Alarms.ps1 - - - VMKernel Warnings - The following VMKernel issues were found, it is suggested all unknown issues are explored on the VMware Knowledge Base. Use the below links to automatically search for the string - Alan Renouf, Frederic Martin - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/44 VMKernel Warnings.ps1 - - - Missing ESX(i) updates and patches - KB - Luc Dekens - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/46 Missing ESX patches.ps1 - - - Syslog Name - The following hosts do not have the correct Syslog settings which may cause issues if ESXi hosts experience issues and logs need to be investigated - Jonathan Medd - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/51 Syslog Name.ps1 - - - Hardware status warnings/errors - Details can be found in the Hardware Status tab - Raphael Schitz - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/53 Hardware status warnings-errors.ps1 - - - Hosts with reboot required - The following hosts require a reboot. - Robert van den Nieuwendijk - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/57 Hosts with reboot required.ps1 - - - Host Build versions in use - The following host builds are in use in this vCenter - Frederic Martin - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/67 Host OS Pivot Table.ps1 - - - Disk Max Total Latency - Check VM per LUN dispatch and esxtop for very high values over $diskmaxtotallatency - Raphael Schitz, Frederic Martin - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/68 Disk Max Total Latency.ps1 - - - Network redundancy lost - The following Hosts have lost network redundancy - Olivier TABUT - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 - - - Hosts with different hostname - The following hosts have a different hostname than their name in the vCenter Server. This might give troubles with HA. - Robert van den Nieuwendijk - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/75 Hosts with Different Hostnames.ps1 - - - Lost Access to Volume - The following hosts have lost access to a volume. This may indicate a problem with your storage solution. - Robert van den Nieuwendijk, Jonathan Medd - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/77 Lost Access to Volume.ps1 - - - Check LUNS have the recommended number of paths - Not enough storage paths can effect storage availability in a FC SAN environment - Craig Smith - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/81 LUN Paths Check.ps1 - - - Hosts not Connected or Alarms Disabled - Shows hosts not in service and those with alarms disabled. - Chris Monahan - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/30 Host/83 Hosts not Connected or Alarms Disabled.ps1 - - - Datastore Information - Datastores which run out of space will cause impact on the virtual machines held on these datastores - Alan Renouf, Jonathan Medd - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/03 Datastore Information.ps1 - - - Datastore Clusters with sDRS Disabled - The following Datastore Clusters either do not have sDRS enabled or it is set to manual - Shawn Masterson - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 - - - sDRS VM Behavior not Default - The following VMs are overriding the Datastore Cluster sDRS automation level - Shawn Masterson - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 - - - Number of VMs per Datastore - The Maximum number of VMs per datastore is 256, the following VMs are above the defined $NumVMsPerDatastore and may cause performance issues - Alan Renouf, Frederic Martin - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 - - - Datastore OverAllocation - The following datastores may be overcommitted, it is strongly suggested you check these - Alan Renouf - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 - - - Datastores with Storage IO Control Disabled - Datastores with Storage I/O Control Disabled can impact the performance of your virtual machines. - Robert van den Nieuwendijk - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/59 Datastores with Storage IO Control Disabled.ps1 - - - Datastores in Maintenance Mode - Datastore held in Maintenance mode will not be hosting any virtual machine, check the below Datastore are in an expected state - Frederic Martin - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 - - - VSAN Datastore Capacity - VSAN Datastore Capacity Report - Modified version from Alan Renouf & Jonathan Medd's Datastore Report - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/990 VSAN Capacity Report.ps1 - - - VSAN Configuration Maximum Disk Group Per Host Report - VSAN hosts approaching - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/991 VSAN Configuration Maximum Disk Group Per Host Report.ps1 - - - VSAN Configuration Maximum Magnetic Disks Per Disk Group Report - VSAN hosts approaching - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/992 VSAN Configuration Maximum Magnetic Disks Per Disk Group Report.ps1 - - - VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report - VSAN hosts approaching - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/993 VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report.ps1 - - - VSAN Configuration Maximum Components Per Host Report - VSAN hosts approaching - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/994 VSAN Configuration Maximum Component Per Host Report.ps1 - - - VSAN Configuration Maximum Hosts Per VSAN Cluster Report - VSAN hosts approaching - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/995 VSAN Configuration Maximum Hosts Per Cluster Report.ps1 - - - VSAN Configuration Maximum VMs Per Host Report - VSAN hosts approaching - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/996 VSAN Configuration Maximum VMs Per Host Report.ps1 - - - VSAN Configuration Maximum VMs Per VSAN Cluster Report - VSAN hosts approaching - William Lam - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/40 Datastore/997 VSAN Configuration Maximum VMs Per Cluster Report.ps1 - - - Checking Standard vSwitch Ports Free - The following standard vSwitches have less than $vSwitchLeft left - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 - - - Checking Distributed vSwitch Port Groups for Ports Free - The following Distributed vSwitch Port Groups have less than $vSwitchLeft left - Kyle Ruddy - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/50 Network/80 DvPG with less than x Ports Free.ps1 - - - vSwitch Security - All security options for standard vSwitches should be set to REJECT. Distributed vSwitches may require <em>ForgedTrasmits</em> in the default portgroup but should be disabled in other VM Network portgroups unless expressly required. - Justin Mercier, Sam McGeown, John Sneddon - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/50 Network/98 vSwitch Security.ps1 - - - Snapshot Information - - - Alan Renouf, Raphael Schitz - 1.4 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/02 Snapshot Information.ps1 - - - Map disk region event - These may occur due to VCB issues, check <a href='http://kb.vmware.com/kb/1007331' target='_blank'>this article</a> for more details - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/04 Map disk region event.ps1 - - - Created or cloned VMs - The following VMs have been created over the last {0} Days - Alan Renouf - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/09 Created or cloned VMs.ps1 - - - Removed VMs - The following VMs have been removed/deleted over the last $($VMsNewRemovedAge) days - Alan Renouf - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/10 Removed VMs.ps1 - - - VMs with CPU or Memory Reservations Configured - The following VMs have a CPU or Memory Reservation configured which may impact the performance of the VM. Note: -1 indicates no reservation - Dan Jellesma - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 - - - VM Logging - The following virtual machines are not configured to rotate logs at $RotateSize bytes and/or to store $KeepOld logs. - Bob Cote - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/102 VM Logging.ps1 - - - CPU/Mem HotPlug - VMs needs to be shutdown to modify CPU/Mem HotPlug in case this settings is disabled. - Eric Lannier - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/103 VMs CPU MEM Add Hot Disabled.ps1 - - - Find Phantom Snapshots - The following VM's have Phantom Snapshots - Mads Fog Albrechtslund - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/106 Find Phantom Snapshots.ps1 - - - VMs with over $vCPU vCPUs - The following VMs have over $vCPU CPU(s) and may impact performance due to CPU scheduling - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/11 VMs with over CPU Count.ps1 - - - VM Tools Not Up to Date - The following VMs are running an older version of Tools than is available on its Host (Max Shown: $VMTMaxReturn Exceptions: $VMTDoNotInclude) - Alan Renouf, Shawn Masterson - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 - - - VMs Ballooning or Swapping - Ballooning and swapping may indicate a lack of memory or a limit on a VM, this may be an indication of not enough memory in a host or a limit held on a VM, <a href='http://www.virtualinsanity.com/index.php/2010/02/19/performance-troubleshooting-vmware-vsphere-memory/' target='_blank'>further information is available here</a>. - Alan Renouf, Frederic Martin - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 - - - Multi-writer - The following VMs have multi-writer parameter. A problem will occur in case of svMotion without reconfiguration of the applications which are using these virtual disks and also change of the VM configuration concerned. More information <a href='http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1034165'>here</a>. - Petar Enchev, Luc Dekens - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/120 Multi-writer.ps1 - - - BusSharingMode - Physical and Virtual - The following VMs have physical and/or virtual bus sharing. A problem will occur in case of svMotion without reconfiguration of the applications which are using these virtual disks and also change of the VM configuration concerned. - Petar Enchev, Luc Dekens - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 - - - Invalid or inaccessible VM - The following VMs are marked as inaccessible or invalid - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 - - - VMs restarted due to Guest OS Error - The following VMs have been restarted by HA in the last $HAVMresetold days - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 - - - Guests with less than $MBFree MB - The following guests have less than $MBFree MB Free, if a guest disk fills up it may cause issues with the guest Operating System - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/19 Guests with less than X MB free.ps1 - - - Checking VM Hardware Version - The following VMs are not at the latest hardware version, you may gain performance enhancements if you convert them to the latest version - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/22 Checking VM Hardware Version.ps1 - - - VMs in inconsistent folders - The following VMs are not stored in folders consistent to their names, this may cause issues when trying to locate them from the datastore manually - Alan Renouf - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/25 VMs in inconsistent folders.ps1 - - - No VM Tools - The following VMs have No VMTools installed, for optimal configuration and performance these should be installed - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/26 No VM Tools.ps1 - - - VM Tools Issues - The following VMs have issues with VMTools, these should be checked and reinstalled if necessary - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/27 VM Tools Issues.ps1 - - - Removable Media Connected - The following VMs have removable media connected (i.e. CD/Floppy), this may cause issues if this machine needs to be migrated to a different host - John Sneddon - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/28 Removable Media Connected.ps1 - - - Single Storage VMs - The following VMs are located on storage which is only accessible by 1 host, these will not be compatible with vMotion and may be disconnected in the event of host failure - Alan Renouf, Frederic Martin - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/30 Single Storage VMs.ps1 - - - VM CPU %RDY - The following VMs have high CPU RDY times, this can cause performance issues for more information please read <a href='http://communities.vmware.com/docs/DOC-7390' target='_blank'>This article</a> - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/32 VM CPU Percent RDY.ps1 - - - VM CPU Usage - The following VMs have high CPU usage and may have rogue guest processes or not enough CPU resource assigned - Alan Renouf, Sam McGeown - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/33 VM CPU Usage.ps1 - - - VM Alarms - The following alarms have been registered against VMs in vCenter - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/37 VM Alarms.ps1 - - - VCB/Veeam/NetBackup Garbage - The following snapshots have been left over from using VCB/Veeam or Netbackup, you may wish to investigate if these are still needed - Alan Renouf, Frederic Martin - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/40 VCB Garbage.ps1 - - - VMs needing snapshot consolidation - The following VMs have snapshots that failed to consolidate. See <a href='http://blogs.vmware.com/vsphere/2011/08/consolidate-snapshots.html' target='_blank'>this article</a> for more details - Luc Dekens, Frederic Martin - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 - - - Find VMs with thick or thin provisioned vmdk - The following VMs have have $diskformat provisioned vmdk(s) - David Chung - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/48 Find VM Disk Format.ps1 - - - VMs with CPU or Memory Limits Configured - The following VMs have a CPU or memory limit configured which may impact the performance of the VM. Note: -1 indicates no limit - Jonathan Medd - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 - - - Virtual machines with incorrect OS configuration - The following virtual machines have an installed OS that is different from the configured OS. This can impact the performance of the virtual machine. - Robert van den Nieuwendijk - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 - - - Virtual machines with less hard disks than partitions - Virtual machines with less hard disks than partitions. Probably they have more than one partition on a hard disk. - Robert van den Nieuwendijk - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 - - - Powered Off VMs - May want to consider deleting VMs that have been powered off for more than 30 days - Adam Schwartzberg - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/60 Powered Off VMs.ps1 - - - VMs by Operating System - The following Operating Systems are in use in this vCenter - Raymond - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/61 Guest OS Pivot table.ps1 - - - Unwanted virtual hardware found - Certain kinds of hardware are unwanted on virtual machines as they may cause unnecessary vMotion constraints. - Frederic Martin - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 - - - VM - Display all VMs with CBT not enabled - List all VMs with CBT status disabled. It's not a good option for backup! - Cyril Epiney - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/620 CBT Status.ps1 - - - Snapshots Oversize - VMware snapshots which are kept for a long period of time may cause issues, filling up datastores and also may impact performance of the virtual machine. - Raphael Schitz, Shawn Masterson - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/64 Snapshots Oversize.ps1 - - - Mis-named virtual machines - The following guest names do not match the name inside of the guest. - Frederic Martin - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/66 Misnamed VM.ps1 - - - VM - is my network connected? - Check if all network cards are connected - Cyril Epiney - 1.2 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/76 VM Network State.ps1 - - - Reset VMs - The following VMs have been reset over the last $($VMsResetAge) days - James Scholefield - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/78 Reset VMs.ps1 - - - VMs in uncontrolled snapshot mode - The following VMs are in snapshot mode, but vCenter isn't aware of it. See http://kb.vmware.com/kb/1002310 - Rick Glover, Matthias Koehler - 1.3 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 - - - Snapshot activity - TaskEvent - Chris Monahan, but is a minor mod of two plugins by Raphael Schitz and Frederic Martin - 1.0 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/60 VM/85 Snapshot Activity.ps1 - - - Site Recovery Manager - RPO Violation Report - This is a customizable report of RPO violations found in the vCenter event log. - Joel Gibson, based on work by Alan Renouf - 0.5 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/70 Misc/108 SRM RPO Violations.ps1 - - - Report on Plugins - - - Phil Randal - 1.1 - vCheck - https://raw.github.com/alanrenouf/vCheck-vCheck/master/Plugins/80 Finish/119 Report on Plugins.ps1 - - - Disconnecting from vCenter - Disconnect plugin - Alan Renouf - 1.1 - vSphere - https://raw.github.com/alanrenouf/vCheck-vSphere/master/Plugins/80 Finish/999 VeryLastPlugin Used to Disconnect.ps1 - - \ No newline at end of file From 887a634f0b95e13d0b5df85a6b2e25c1959658e4 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 24 Nov 2016 15:10:18 +1100 Subject: [PATCH 24/50] Update .gitAttributes --- .gitAttributes | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitAttributes b/.gitAttributes index cc82df9a..a57dfc3a 100644 --- a/.gitAttributes +++ b/.gitAttributes @@ -10,6 +10,5 @@ *.xml text eol=crlf # Ignore plugins.xml in exports -plugins.xml export-ignore .gitAttributes export-ignore .gitIgnore export-ignore From 56d93ca1bfd50d3713d27a487c31e1ac5cc5fdc2 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Mon, 28 Nov 2016 09:28:32 +1100 Subject: [PATCH 25/50] Add handling for PowerCLI Modules Merge PR #508 --- .../00 Connection Plugin for vCenter.ps1 | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index fb0610fb..9bfdb9be 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -1,6 +1,6 @@ $Title = "Connection settings for vCenter" $Author = "Alan Renouf" -$PluginVersion = 1.8 +$PluginVersion = 1.9 $Header = "Connection Settings" $Comments = "Connection Plugin for connecting to vSphere" $Display = "None" @@ -51,11 +51,36 @@ else # Path to credentials file which is automatically created if needed $Credfile = $ScriptPath + "\Windowscreds.xml" -# Adding PowerCLI core snapin, also check if powerCLI module is alsready added -if (!(get-module -name VMware.VimAutomation.Core -erroraction silentlycontinue)) { - if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) { - add-pssnapin VMware.VimAutomation.Core -erroraction silentlycontinue - } +# +# Adding PowerCLI core module/pssnapin +# +# Possibilities: +# 1) PSSnpain (-le 5.8R1) +# 2) Module + PSSnapin (-gt 5.8R1/-lt 6.5R1) +# 3) Module (-ge 6.5R1) + +$pcliCore = 'VMware.VimAutomation.Core' + +$pssnapinPresent = $false +$psmodulePresent = $false + +if(Get-Module -Name $pcliCore -ListAvailable){ + $psmodulePresent = $true + if(!(Get-Module -Name $pcliCore)){ + Import-Module -Name $pcliCore + } +} + +if(Get-PSSnapin -Name $pcliCore -Registered -ErrorAction SilentlyContinue){ + $pssnapinPresent = $true + if(!(Get-PSSnapin -Name $pcliCore -ErrorAction SilentlyContinue)){ + Add-PSSnapin -Name $pcliCore + } +} + +if(!$pssnapinPresent -and !$psmodulePresent){ + Write-Error "Can't find PowerCLI. Is it installed?" + return } $OpenConnection = $global:DefaultVIServers | where { $_.Name -eq $VIServer } From 00bd1064962dbf305a24af6bb76376d10d3f509d Mon Sep 17 00:00:00 2001 From: Sneddo Date: Wed, 30 Nov 2016 15:40:52 +1100 Subject: [PATCH 26/50] Update Plugins to use Get-vCheckSetting --- .../40 Datastore/03 Datastore Information.ps1 | 45 +++--- .../109 Orphaned VMDK File.ps1.disabled | 138 ++++++++---------- ... Datastore Clusters with sDRS Disabled.ps1 | 28 ++-- .../116 sDRS VM Behavior not Default.ps1 | 32 ++-- .../34 Number of VMs per Datastore.ps1 | 24 +-- .../39 Datastore OverAllocation.ps1 | 48 +++--- ...tores with Storage IO Control Disabled.ps1 | 31 ++-- .../69 Datastores in Maintenance mode.ps1 | 20 +-- .../70 Datastores with Alarms Disabled.ps1 | 18 ++- .../84 VMDK consistency.ps1.disabled | 81 +++++----- .../40 Datastore/990 VSAN Capacity Report.ps1 | 40 ++--- ...ion Maximum Disk Group Per Host Report.ps1 | 67 +++++---- ...m Magnetic Disks Per Disk Group Report.ps1 | 66 ++++----- ...sks In All Disk Groups Per Host Report.ps1 | 72 +++++---- ...tion Maximum Component Per Host Report.ps1 | 90 ++++++------ ...ation Maximum Hosts Per Cluster Report.ps1 | 56 ++++--- ...figuration Maximum VMs Per Host Report.ps1 | 62 ++++---- ...uration Maximum VMs Per Cluster Report.ps1 | 56 +++---- ...24 vSwitch with less than x Ports Free.ps1 | 21 +-- .../80 DvPG with less than x Ports Free.ps1 | 42 +++--- Plugins/50 Network/98 vSwitch Security.ps1 | 27 ++-- Plugins/70 Misc/108 SRM RPO Violations.ps1 | 127 +++++++--------- 22 files changed, 587 insertions(+), 604 deletions(-) diff --git a/Plugins/40 Datastore/03 Datastore Information.ps1 b/Plugins/40 Datastore/03 Datastore Information.ps1 index 18cb53fb..e84f302b 100644 --- a/Plugins/40 Datastore/03 Datastore Information.ps1 +++ b/Plugins/40 Datastore/03 Datastore Information.ps1 @@ -1,31 +1,32 @@ +$Title = "Datastore Information" +$Comments = "Datastores which run out of space will cause impact on the virtual machines held on these datastores" +$Display = "Table" +$Author = "Alan Renouf, Jonathan Medd" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # Set the warning threshold for Datastore % Free Space -$DatastoreSpace = 25 +$DatastoreSpace = 15 # Do not report on any Datastores that are defined here (Datastore Free Space Plugin) $DatastoreIgnore = "local" # End of Settings -# ChangeLog -# 1.2 - Added ability to filter out datastores (e.g. local ones) that you are not concerned about for the report -# 1.3 - Added TableFormat for conditional formatting of output table -if ($DatastoreIgnore){ - $OutputDatastores = @($Datastores | Where-Object {$_.Name -notmatch $DatastoreIgnore} | Select-Object Name, Type, @{N="CapacityGB";E={[math]::Round($_.CapacityGB,2)}}, @{N="FreeSpaceGB";E={[math]::Round($_.FreeSpaceGB,2)}}, PercentFree| Sort-Object PercentFree)| Where-Object { $_.PercentFree -lt $DatastoreSpace } -} -else { - $OutputDatastores = @($Datastores | Select-Object Name, Type, @{N="CapacityGB";E={[math]::Round($_.CapacityGB,2)}}, @{N="FreeSpaceGB";E={[math]::Round($_.FreeSpaceGB,2)}}, PercentFree| Sort-Object PercentFree)| Where-Object { $_.PercentFree -lt $DatastoreSpace } -} +# Update settings where there is an override +$DatastoreSpace = Get-vCheckSetting $Title "DatastoreSpace" $DatastoreSpace +$DatastoreIgnore = Get-vCheckSetting $Title "DatastoreIgnore" $DatastoreIgnore -$OutputDatastores +$Datastores | Where-Object {$_.Name -notmatch $DatastoreIgnore} | Select-Object Name, Type, @{N="CapacityGB";E={[math]::Round($_.CapacityGB,2)}}, @{N="FreeSpaceGB";E={[math]::Round($_.FreeSpaceGB,2)}}, PercentFree| Sort-Object PercentFree | Where-Object { $_.PercentFree -lt $DatastoreSpace } -$Title = "Datastore Information" -$Header = "Datastores (Less than $DatastoreSpace% Free) : $(@($OutputDatastores).count)" -$Comments = "Datastores which run out of space will cause impact on the virtual machines held on these datastores" -$Display = "Table" -$Author = "Alan Renouf, Jonathan Medd" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" +$Header = "Datastores (Less than $DatastoreSpace% Free) : [count]" -$TableFormat = @{"PercentFree" = @(@{ "-le 25" = "Row,class|warning"; }, - @{ "-le 15" = "Row,class|critical" }); - "CapacityGB" = @(@{ "-lt 499.75" = "Cell,style|background-color: #FFDDDD"}) - } +$TableFormat = @{"PercentFree" = @(@{ "-le 15" = "Row,class|warning"; }, + @{ "-le 10" = "Row,class|critical" }); + "CapacityGB" = @(@{ "-lt 499.75" = "Cell,style|background-color: #FFDDDD"}) +} + + +# ChangeLog +# 1.2 : Added ability to filter out datastores (e.g. local ones) that you are not concerned about for the report +# 1.3 : Added TableFormat for conditional formatting of output table +# 1.4 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled b/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled index a1669ed4..d4210d7b 100644 --- a/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled +++ b/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled @@ -26,7 +26,13 @@ # Use at your own risk. # ## - +$Title = "Orphaned VMDK File Plugin" +$Header = "Orphaned VMDK Files: [count]" +$Comments = "This plugin can be used to generate a custom report of orphaned VMDK files. Note: This plugin can take quite a while to run, depending on the environment." +$Display = "Table" +$Author = "Joel Gibson et al." +$PluginVersion = 0.2 +$PluginCategory = "vSphere" # Start of Settings # Orphaned Delta File: Exclude datatores by DS name? (regex) @@ -35,92 +41,76 @@ $excludeDatastoreRegex = '^$' $excludeVMPathRegex = '^$' # End of Settings -# Changelog -## 0.1 : Initial version. -## 0.2 : Modified the $excludeDatastoreRegex and $excludeVMPathRegex variable values from "" into '^$' - -# Begin code block obtained from: http://virtuallyjason.blogspot.ca/2013/08/orphaned-vmdk-files.html - -# PowerShell script to discover VMDK files that are not referenced in any VM's VMX file. -# Also detects VMDKs from machines that need snapshot consolidation (from differentials that exist but are not part of the tree). -# Author: HJA van Bokhoven -# Modifications: LucD, Joel Gibson, and Robert van den Nieuwendijk +# Update settings where there is an override +$excludeDatastoreRegex = Get-vCheckSetting $Title "excludeDatastoreRegex" $excludeDatastoreRegex +$excludeVMPathRegex = Get-vCheckSetting $Title "excludeVMPathRegex" $excludeVMPathRegex $report = @() $arrUsedDisks = $FullVM | % {$_.Layout} | % {$_.Disk} | % {$_.DiskFile} -Write-CustomOut "..filtering list to exclude datastores that match this regex pattern: $excludeDatastoreRegex" +#Write-CustomOut "..filtering list to exclude datastores that match this regex pattern: $excludeDatastoreRegex" $arrDS = $storageviews | Sort-Object -property Name | Where {$_.name -notmatch $excludeDatastoreRegex } foreach ($strDatastore in $arrDS) { - Write-CustomOut "..$($strDatastore.Name) Orphaned Disks:" - $ds = Get-Datastore -Name $strDatastore.Name | % {Get-View $_.Id} - $fileQueryFlags = New-Object VMware.Vim.FileQueryFlags - $fileQueryFlags.FileSize = $true - $fileQueryFlags.FileType = $true - $fileQueryFlags.Modification = $true - $searchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec - $searchSpec.details = $fileQueryFlags - $searchSpec.matchPattern = "*.vmdk" - $searchSpec.sortFoldersFirst = $true - $dsBrowser = Get-View $ds.browser - $rootPath = "[" + $ds.Name + "]" - $searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec) - - foreach ($folder in $searchResult) - { - foreach ($fileResult in $folder.File) - { + # Write-CustomOut "..$($strDatastore.Name) Orphaned Disks:" + $ds = Get-Datastore -Name $strDatastore.Name | % {Get-View $_.Id} + $fileQueryFlags = New-Object VMware.Vim.FileQueryFlags + $fileQueryFlags.FileSize = $true + $fileQueryFlags.FileType = $true + $fileQueryFlags.Modification = $true + $searchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec + $searchSpec.details = $fileQueryFlags + $searchSpec.matchPattern = "*.vmdk" + $searchSpec.sortFoldersFirst = $true + $dsBrowser = Get-View $ds.browser + $rootPath = "[" + $ds.Name + "]" + $searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec) + + foreach ($folder in $searchResult) + { + if ($folder.FolderPath -notmatch $excludeVMPathRegex) + { + foreach ($fileResult in $folder.File) + { if ($fileResult.Path) { - $pathAsString = out-string -InputObject $FileResult.Path - if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path))){ - - # Changed Black Tracking creates ctk.vmdk files that are not referenced in the VMX. This prevents them from showing as false positives. - if (-not ($pathAsString.toLower().contains("-ctk.vmdk"))) { - - # Site Recovery Manager creates -000000.vmdk and -000000-delta.vmdk files. This excludes these patterns from being displayed. - if ($pathAsString -notmatch "-[0-9][0-9][0-9][0-9][0-9][0-9]\.vmdk|-[0-9][0-9][0-9][0-9][0-9][0-9]-delta\.vmdk") { - $row = "" | Select DS, Path, File, Size, ModDate - $row.DS = $strDatastore.Name - $row.Path = $folder.FolderPath - $row.File = $fileResult.Path - $row.Size = $fileResult.FileSize - $row.ModDate = $fileResult.Modification - $report += $row - Write-CustomOut "..$($row.Path)$($row.File)" - - } # end of SRM filter - - } # end of CBT filter - - } # end of if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path))) - + $pathAsString = out-string -InputObject $FileResult.Path + if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path))) + { + # Changed Black Tracking creates ctk.vmdk files that are not referenced in the VMX. This prevents them from showing as false positives. + if (-not ($pathAsString.toLower().contains("-ctk.vmdk"))) + { + # Site Recovery Manager creates -000000.vmdk and -000000-delta.vmdk files. This excludes these patterns from being displayed. + if ($pathAsString -notmatch "-[0-9]{6}\.vmdk|-[0-9]{6}-delta\.vmdk") + { + New-Object -TypeName PSObject -Property @{ + "Datastore" = $strDatastore.Name + "Path" = $folder.FolderPath + "File" = $fileResult.Path + "Size" = $fileResult.FileSize + "ModDate" = $fileResult.Modification + } + #Write-CustomOut "..$($row.Path)$($row.File)" + } # end of SRM filter + + } # end of CBT filter + } # end of if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path))) } # end of if ($fileResult.Path) - - } # end of foreach ($fileResult in $folder.File) - - } # end of foreach ($folder in $searchResult) - + } # end of foreach ($fileResult in $folder.File) + } # end of if ($folder.FolderPath -notmatch $excludeVMPathRegex) + } # end of foreach ($folder in $searchResult) } # end of foreach ($strDatastore in $arrDS) # End of code block obtained from: http://virtuallyjason.blogspot.ca/2013/08/orphaned-vmdk-files.html -# remove VMDKs from list that match the regex $excludeVMPathRegex -if ($excludeVMPathRegex -ne "") { - Write-CustomOut "..filtering list to exclude VMs that match this regex pattern: $excludeVMPathRegex" - $Results = $report | where {$_.path -notmatch $excludeVMPathRegex} -} else { - $Results = $report -} +# Changelog +## 0.1 : Initial version. +## 0.2 : Modified the $excludeDatastoreRegex and $excludeVMPathRegex variable values from "" into '^$' +## 1.0 : Added Get-vCheckSetting, removed Write-CustomOut which will break output (need to find a solution to this) -## output list of orphaned VMDK files -$Results +# Begin code block obtained from: http://virtuallyjason.blogspot.ca/2013/08/orphaned-vmdk-files.html -$Title = "Orphaned VMDK File Plugin" -$Header = "Orphaned VMDK Files: $(@($Results).count)" -$Comments = "This plugin can be used to generate a custom report of orphaned VMDK files. Note: This plugin can take quite a while to run, depending on the environment." -$Display = "Table" -$Author = "Joel Gibson et al." -$PluginVersion = 0.2 -$PluginCategory = "vSphere" +# PowerShell script to discover VMDK files that are not referenced in any VM's VMX file. +# Also detects VMDKs from machines that need snapshot consolidation (from differentials that exist but are not part of the tree). +# Author: HJA van Bokhoven +# Modifications: LucD, Joel Gibson, and Robert van den Nieuwendijk \ No newline at end of file diff --git a/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 b/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 index 891bf761..2dc1848f 100644 --- a/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 +++ b/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 @@ -1,20 +1,18 @@ -# Start of Settings -# End of Settings - -# Changelog -## 1.0 : Initial Version - - -$Result = @($DatastoreClustersView | ` - Where {$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled -ne $true -or $_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior -ne "automated"} | ` - Select Name, @{N="sDRS Enabled";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled}}, @{N="sDRS Automation Level";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior}}) -$Result - - $Title = "Datastore Clusters with sDRS Disabled" -$Header = "Datastore Clusters with sDRS disabled or set to manual: $(@($Result).Count)" +$Header = "Datastore Clusters with sDRS disabled or set to manual: [count]" $Comments = "The following Datastore Clusters either do not have sDRS enabled or it is set to manual" $Display = "Table" $Author = "Shawn Masterson" -$PluginVersion = 1.0 +$PluginVersion = 1.1 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$DatastoreClustersView | ` + Where {$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled -ne $true -or $_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior -ne "automated"} | ` + Select Name, @{N="sDRS Enabled";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled}}, @{N="sDRS Automation Level";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior}} + +# Changelog +## 1.0 : Initial Version +## 1.2 : Code refactor \ No newline at end of file diff --git a/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 b/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 index aa0739d0..167ea1e8 100644 --- a/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 +++ b/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 @@ -1,21 +1,23 @@ +$Title = "sDRS VM Behavior not Default" +$Header = "VMs overriding Datastore Cluster automation level: [count]" +$Comments = "The following VMs are overriding the Datastore Cluster sDRS automation level" +$Display = "Table" +$Author = "Shawn Masterson" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings +# Exclude these VMs from report +$ExcludedVMs = "" # End of Settings +# Update settings where there is an override +$ExcludedVMs = Get-vCheckSetting $Title "ExcludedVMs" $ExcludedVMs + +$DatastoreClustersView | Foreach {$_.PodStorageDrsEntry.StorageDrsConfig.VMConfig} | ` + Where {$_.Enabled -eq $false -or $_.Behavior -ne $null} | ` + Select @{N="VM";E={Get-View $_.Vm | Select -ExpandProperty Name}}, Enabled, Behavior,@{N="Datastore Cluster";E={$dc.Name}} | Where { $_.VM -notmatch $ExcludedVMs } # Changelog ## 1.0 : Initial Version - - -$Result = @($DatastoreClustersView | Foreach {$dc = $_;$dc.PodStorageDrsEntry.StorageDrsConfig.VMConfig} | ` - Where {$_.Enabled -eq $false -or $_.Behavior -ne $null} | ` - Select @{N="VM";E={Get-View $_.Vm | Select -ExpandProperty Name}}, Enabled, Behavior,@{N="Datastore Cluster";E={$dc.Name}}) -$Result - - -$Title = "sDRS VM Behavior not Default" -$Header = "VMs overriding Datastore Cluster automation level: $(@($Result).Count)" -$Comments = "The following VMs are overriding the Datastore Cluster sDRS automation level" -$Display = "Table" -$Author = "Shawn Masterson" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +## 1.1 : Code refactor and filtering \ No newline at end of file diff --git a/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 b/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 index 8573014c..9b91fb9d 100644 --- a/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 +++ b/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 @@ -1,3 +1,10 @@ +$Title = "Number of VMs per Datastore" +$Comments = "The Maximum number of VMs per datastore is 256, the following VMs are above the defined $NumVMsPerDatastore and may cause performance issues" +$Display = "Table" +$Author = "Alan Renouf, Frederic Martin" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Max number of VMs per Datastore $NumVMsPerDatastore = 5 @@ -7,14 +14,13 @@ $ExcludedDatastores = "ExcludeMe" # Changelog ## 1.1 : Using managed objects collections in order to avoid using Get-VM cmdlet for performance matter +## 1.2 : ??? +## 1.3 : Add Get-vCheckSetting -$Result = @($StorageViews | Where-Object { $_.Name -notmatch $ExcludedDatastores } | Select Name, @{N="NumVM";E={($_.vm).Count}} | Where { $_.NumVM -gt $NumVMsPerDatastore} | Sort NumVM -Descending) -$Result +# Update settings where there is an override +$NumVMsPerDatastore = Get-vCheckSetting $Title "NumVMsPerDatastore" $NumVMsPerDatastore +$ExcludedDatastores = Get-vCheckSetting $Title "ExcludedDatastores" $ExcludedDatastores -$Title = "Number of VMs per Datastore" -$Header = "Number of VMs per Datastore over $($NumVMsPerDatastore) : $(@($Result).Count)" -$Comments = "The Maximum number of VMs per datastore is 256, the following VMs are above the defined $NumVMsPerDatastore and may cause performance issues" -$Display = "Table" -$Author = "Alan Renouf, Frederic Martin" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +$StorageViews | Where-Object { $_.Name -notmatch $ExcludedDatastores } | Select Name, @{N="NumVM";E={($_.vm).Count}} | Where { $_.NumVM -gt $NumVMsPerDatastore} | Sort NumVM -Descending + +$Header = "Number of VMs per Datastore over $($NumVMsPerDatastore) : [count]" \ No newline at end of file diff --git a/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 b/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 index f3fe8500..9bfb0b36 100644 --- a/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 +++ b/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 @@ -1,33 +1,39 @@ +$Title = "Datastore OverAllocation" +$Comments = "The following datastores may be overcommitted, it is strongly suggested you check these" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # Datastore OverAllocation % $OverAllocation = 50 # Exclude these datastores from report -$ExcludedDatastores = "ExcludeMe" +$ExcludedDatastores = "" # End of Settings +# Update settings where there is an override +$OverAllocation = Get-vCheckSetting $Title "OverAllocation" $OverAllocation +$ExcludedDatastores = Get-vCheckSetting $Title "ExcludedDatastores" $ExcludedDatastores + $filteredstorageviews = $storageviews | Where-Object { $_.Name -notmatch $ExcludedDatastores } -$voverallocation = @() + foreach ($storage in $filteredstorageviews) { - if ($storage.Summary.Uncommitted -gt "0") - { - $Details = "" | Select-Object Datastore, Overallocation - $Details.Datastore = $storage.name - $Details.overallocation = [math]::round(((($storage.Summary.Capacity - $storage.Summary.FreeSpace) + $storage.Summary.Uncommitted)*100)/$storage.Summary.Capacity,0) - if ($Details.overallocation -gt $OverAllocation) - { - $voverallocation += $Details - } - } + if ($storage.Summary.Uncommitted -gt "0") + { + $allocation = [math]::round(((($storage.Summary.Capacity - $storage.Summary.FreeSpace) + $storage.Summary.Uncommitted)*100)/$storage.Summary.Capacity,0) + + if (($allocation-100) -gt $OverAllocation { + New-Object -TypeName PSObject -Property @{ + "Datastore" = $storage.name + "OverAllocation" = $overAllocation } + } + } } -$voverallocation +$Header = ("Datastore OverAllocation Over {0}%: [count]" -f $OverAllocation) -$Title = "Datastore OverAllocation" -$Header = "Datastore OverAllocation Over $OverAllocation%: $(@($voverallocation).Count)" -$Comments = "The following datastores may be overcommitted, it is strongly suggested you check these" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" -# 20150223 monahancj - Added datastore filtering +# Change Log +# 1.3 : 20150223 monahancj - Added datastore filtering +# 1.4 : Added Get-vCheckSetting, fixed logic to report over allocation properly \ No newline at end of file diff --git a/Plugins/40 Datastore/59 Datastores with Storage IO Control Disabled.ps1 b/Plugins/40 Datastore/59 Datastores with Storage IO Control Disabled.ps1 index e5eb4710..cbee715b 100644 --- a/Plugins/40 Datastore/59 Datastores with Storage IO Control Disabled.ps1 +++ b/Plugins/40 Datastore/59 Datastores with Storage IO Control Disabled.ps1 @@ -1,20 +1,23 @@ +$Title = "Datastores with Storage IO Control Disabled" +$Header = "Datastores with Storage I/O Control Disabled : [count]" +$Display = "Table" +$Author = "Robert van den Nieuwendijk" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Do not report on any Datastores that are defined here (Storage IO Control disabled Plugin) $DatastoreIgnore = "local" # End of Settings -$Result = @($Datastores | ` - Where-Object {$_.Name -notmatch $DatastoreIgnore} | ` - Where-Object {-not $_.StorageIOControlEnabled} | ` - Sort-Object -Property Name | ` - Select-Object -Property Name,StorageIOControlEnabled -) -$Result +# Update settings where there is an override +$DatastoreIgnore = Get-vCheckSetting $Title "DatastoreIgnore" $DatastoreIgnore -$Title = "Datastores with Storage IO Control Disabled" -$Header = "Datastores with Storage I/O Control Disabled : $(@($Result).Count) (with user exception $DatastoreIgnore)" -$Comments = "Datastores with Storage I/O Control Disabled can impact the performance of your virtual machines." -$Display = "Table" -$Author = "Robert van den Nieuwendijk" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +$Datastores | Where-Object {$_.Name -notmatch $DatastoreIgnore -and -not $_.StorageIOControlEnabled} | ` + Sort-Object -Property Name | ` + Select-Object -Property Name,StorageIOControlEnabled + +$Comments = ("Datastores with Storage I/O Control Disabled can impact the performance of your virtual machines. Excludes {0}" -f $DatastoreIgnore) + +# Change Log +## 1.3 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 b/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 index 49cad41c..615aab22 100644 --- a/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 +++ b/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 @@ -1,15 +1,17 @@ +$Title = "Datastores in Maintenance Mode" +$Header = "Datastores in Maintenance Mode : [count]" +$Comments = "Datastore held in Maintenance mode will not be hosting any virtual machine, check the below Datastore are in an expected state" +$Display = "Table" +$Author = "Frederic Martin" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings if ($VIVersion -ge 5) { - $MaintDatastores = @($StorageViews | Where {$_.Summary.MaintenanceMode -match "inMaintenance"} | Select Name, @{N="MaintenanceMode";E={$_.Summary.MaintenanceMode}}) - $MaintDatastores + $StorageViews | Where {$_.Summary.MaintenanceMode -match "inMaintenance"} | Select Name, @{N="MaintenanceMode";E={$_.Summary.MaintenanceMode}} } -$Title = "Datastores in Maintenance Mode" -$Header = "Datastores in Maintenance Mode : $(@($MaintDatastores).count)" -$Comments = "Datastore held in Maintenance mode will not be hosting any virtual machine, check the below Datastore are in an expected state" -$Display = "Table" -$Author = "Frederic Martin" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +# Change Log +## 1.2 : Code refactor \ No newline at end of file diff --git a/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 b/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 index ec694457..33748312 100644 --- a/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 +++ b/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 @@ -1,12 +1,16 @@ +$Title = "Datastores with Alarms Disabled" +$Header = "Datastores with Alarms Disabled : [count]" +$Comments = "The datastores will not generate alarms which may highlight problems with the datastore" +$Display = "Table" +$Author = "John Sneddon" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings $Datastores | where {!$_.ExtensionData.AlarmActionsEnabled} | Select Name, @{n='AlarmActionsEnabled'; e={$_.ExtensionData.AlarmActionsEnabled}} -$Title = "Datastores with Alarms Disabled" -$Header = "Datastores with Alarms Disabled" -$Comments = "Datastores with Alarms Disabled" -$Display = "Table" -$Author = "John Sneddon" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Change Log +## 1.0 : Initial version +## 1.1 : Code refactor \ No newline at end of file diff --git a/Plugins/40 Datastore/84 VMDK consistency.ps1.disabled b/Plugins/40 Datastore/84 VMDK consistency.ps1.disabled index 24b63b29..7396fe04 100644 --- a/Plugins/40 Datastore/84 VMDK consistency.ps1.disabled +++ b/Plugins/40 Datastore/84 VMDK consistency.ps1.disabled @@ -1,56 +1,47 @@ -# Start of Settings -# What Datastores do you wish to examine for missing VmDisk Files (wildcard = *) -$DatastoreName = "*" -# End of Settings - $Title = "VMDK consistency" $Header = "VMDK consistency" -$Comments = "This simple plug-in checks if every FLAT-VMDK file found in a folder, has a corresponding VMDK file also present" +$Comments = "This simple plug-in checks if every FLAT-VMDK file found in a folder, has a corresponding VMDK file also present; For more information to fix the problem, please take a look at Recreating a missing virtual machine disk descriptor file (1002511)" $Display = "List" $Author = "Peronnik Beijer" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" -$Url = 'http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002511' +# Start of Settings +# End of Settings + $VMDK_check_out = @() # Main plug-in script -$Datastores = Get-Datastore -Name "$DatastoreName" - foreach ( $Datastore in $Datastores ) { - New-PSDrive -Location (Get-Datastore "$Datastore") -Name "$($Datastore.Name)" -PSProvider VimDatastore -Root "" -EA 0 -Confirm:$false | Out-Null - Set-location "$($Datastore.Name):" -EA 0 | Out-Null - If (!($?)) { - Write-Host "There was an error mounting the datastore as PSDrive, please investigate first, this plugin will now Exit" -ForegroundColor Red -BackgroundColor black - Write-Error $error[0] - Exit } - $folders = Get-Item * -Exclude ".vSphere-HA" | ? { $_.PSIsContainer } | % { $_.Name } - foreach ( $folder in $Folders ) - { - $VmDiskfileCount = 0 - $fileCount = 0 - $vmdks = Get-ChildItem "$folder\*.vmdk" -Exclude "*-ctk.vmdk" - If (!($?)) { - Write-Host "There was an error getting the files from $folder, please investigate first, this plugin will now Exit" -ForegroundColor Red -BackgroundColor black - Write-Error $error[0] - Exit } - foreach ($vmdk in $vmdks) - { - If ($vmdk.itemtype -Like "VmDiskFile") { - $VmDiskfileCount += 1 } - ElseIf ( $vmdk.itemtype -Like "File" ) { - $fileCount += 1 } - } - If ( $VmDiskfileCount -ne $fileCount) { - $InfoMsg = "In the folder : [$Datastore)]/$folder/ are flat-VMDK file(s) found, but not enough corresponding VMDK file(s)! For more information to fix the problem, please take a look at: $Url" - $Out_Obj = $null - $Out_Obj = New-Object -TypeName PSObject - $Out_Obj | Add-Member -MemberType NoteProperty -Name "Info" -Value "$InfoMsg" - $VMDK_check_out += $Out_Obj } - } - Set-location "C:" -EA 0 | Out-Null - Remove-PSDrive "$($Datastore.Name):" -Force -EA 0 | Out-Null -} - -$VMDK_check_out + New-PSDrive -Location (Get-Datastore "$Datastore") -Name "$($Datastore.Name)" -PSProvider VimDatastore -Root "" -EA 0 -Confirm:$false | Out-Null + Set-location "$($Datastore.Name):" -EA 0 | Out-Null + If (!($?)) { + Write-Error $error[0] + Exit + } + $folders = Get-Item * -Exclude ".vSphere-HA" | ? { $_.PSIsContainer } | % { $_.Name } + foreach ( $folder in $Folders ) + { + $VmDiskfileCount = 0 + $fileCount = 0 + $vmdks = Get-ChildItem "$folder\*.vmdk" -Exclude "*-ctk.vmdk" + If (!($?)) { + Write-Host "There was an error getting the files from $folder, please investigate first, this plugin will now Exit" -ForegroundColor Red -BackgroundColor black + Write-Error $error[0] + Exit + } + foreach ($vmdk in $vmdks) + { + If ($vmdk.itemtype -Like "VmDiskFile") { $VmDiskfileCount += 1 } + ElseIf ( $vmdk.itemtype -Like "File" ) { $fileCount += 1 } + } + If ( $VmDiskfileCount -ne $fileCount) { + New-Object -TypeName PSObject -Property @{ + "Info" = ("In the folder : [{0}]/$folder/ are flat-VMDK file(s) found, but not enough corresponding VMDK file(s)! " -f $Datastore.Name) + } + } + } + Set-location "C:" -EA 0 | Out-Null + Remove-PSDrive "$($Datastore.Name):" -Force -EA 0 | Out-Null +} \ No newline at end of file diff --git a/Plugins/40 Datastore/990 VSAN Capacity Report.ps1 b/Plugins/40 Datastore/990 VSAN Capacity Report.ps1 index 756886ba..e77575f0 100644 --- a/Plugins/40 Datastore/990 VSAN Capacity Report.ps1 +++ b/Plugins/40 Datastore/990 VSAN Capacity Report.ps1 @@ -1,24 +1,30 @@ +$Title = "VSAN Datastore Capacity" +$Comments = "VSAN Datastore Capacity Report - Modified version from Alan Renouf & Jonathan Medd's Datastore Report" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # Set the warning threshold for VSAN Datastore % Free Space -$DatastoreSpace = 85 +$DatastoreSpace = 15 # End of Settings -$OutputDatastores = @($Datastores | Where-Object {$_.Type -match 'vsan'} | Select-Object Name, Type, -@{N="CapacityGB";E={[math]::Round($_.CapacityGB,2)}}, -@{N="ProvisionedGB";E={([math]::Round($_.CapacityGB,2) - [math]::Round($_.FreeSpaceGB,2))}}, -@{N="FreeSpaceGB";E={[math]::Round($_.FreeSpaceGB,2)}}, PercentFree| Sort-Object PercentFree)| Where-Object { $_.PercentFree -lt $DatastoreSpace } +# Update settings where there is an override +$DatastoreSpace = Get-vCheckSetting $Title "DatastoreSpace" $DatastoreSpace -$OutputDatastores +$Datastores | Where-Object {$_.Type -match 'vsan'} | Select-Object Name, Type, + @{N="CapacityGB";E={[math]::Round($_.CapacityGB,2)}}, + @{N="ProvisionedGB";E={([math]::Round($_.CapacityGB,2) - [math]::Round($_.FreeSpaceGB,2))}}, + @{N="FreeSpaceGB";E={[math]::Round($_.FreeSpaceGB,2)}}, PercentFree| Sort-Object PercentFree| Where-Object { $_.PercentFree -lt $DatastoreSpace } -$Title = "VSAN Datastore Capacity" -$Header = "VSAN Datastores (Less than $DatastoreSpace% Free) : $(@($OutputDatastores).count)" -$Comments = "VSAN Datastore Capacity Report - Modified version from Alan Renouf & Jonathan Medd's Datastore Report" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +$Header = "VSAN Datastores (Less than $DatastoreSpace% Free) : [count]" -$TableFormat = @{"PercentFree" = @(@{ "-le 25" = "Row,class|warning"; }, - @{ "-le 15" = "Row,class|critical" }); - "CapacityGB" = @(@{ "-lt 499.75" = "Cell,style|background-color: #FFDDDD"}) - } +$TableFormat = @{"PercentFree" = @(@{ "-le 15" = "Row,class|warning"; }, + @{ "-le 10" = "Row,class|critical" }); + "CapacityGB" = @(@{ "-lt 499.75" = "Cell,style|background-color: #FFDDDD"}) + } + +# Change Log +## 1.0 : Initial version +## 1.1 : Code refactor \ No newline at end of file diff --git a/Plugins/40 Datastore/991 VSAN Configuration Maximum Disk Group Per Host Report.ps1 b/Plugins/40 Datastore/991 VSAN Configuration Maximum Disk Group Per Host Report.ps1 index d939df5a..a405b1ed 100644 --- a/Plugins/40 Datastore/991 VSAN Configuration Maximum Disk Group Per Host Report.ps1 +++ b/Plugins/40 Datastore/991 VSAN Configuration Maximum Disk Group Per Host Report.ps1 @@ -1,44 +1,43 @@ +$Title = "VSAN Configuration Maximum Disk Group Per Host Report" +$Header = "VSAN Configuration Maximum - Disk Group Per Host" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings -# Enable VSAN Config Max Disk Group Per Host Reporting? -$vsanConfigMaxReport = $true # Percentage threshold to warn? -$warning = 80 +$vsanWarningThreshold = 80 # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Fix indentation + using global $clusviews -$vsanMaxConfigInfo = @() +# Update settings where there is an override +$vsanWarningThreshold = Get-vCheckSetting $Title "vsanWarningThreshold" $vsanWarningThreshold + +# This config maximum is different for each version of VSAN, 5 for 5.5 $vsanDiskGroupMaximum = 5 -if($vsanConfigMaxReport) { - foreach ($cluster in $clusviews) { - if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { - $vmhosts = $cluster.Host - foreach ($vmhost in $vmhosts | Sort-Object -Property Name) { - $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem - $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem - # Number of DG's per Host - $diskGroups = ($vsanSys.Config.StorageInfo.DiskMapping | Measure-Object).count - $checkValue = [int]($diskGroups/$vsanDiskGroupMaximum * 100) +foreach ($cluster in $clusviews) { + if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { + $vmhosts = $cluster.Host + foreach ($vmhost in $vmhosts | Sort-Object -Property Name) { + $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem + $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem + # Number of DG's per Host + $diskGroups = ($vsanSys.Config.StorageInfo.DiskMapping | Measure-Object).count + $checkValue = [int]($diskGroups/$vsanDiskGroupMaximum * 100) - if($checkValue -gt $warning) { - $Details = "" |Select VMHost, DiskGroupCount - $Details.VMHost = $vmhostView.Name - $Details.DiskGroupCount = $diskGroups - $vsanMaxConfigInfo += $Details - } - } - } - } + if($checkValue -gt $vsanWarningThreshold) { + New-Object -TypeName PSObject -Property @{ + "VMHost" = $vmhostView.Name + "DiskGroupCount" = $diskGroups } + } + } + } } -$vsanMaxConfigInfo +$Comments = "VSAN hosts approaching {0}% limit of {1} Disk Groups per host" -f $vsanWarningThreshold, $vsanDiskGroupMaximum -$Title = "VSAN Configuration Maximum Disk Group Per Host Report" -$Header = "VSAN Configuration Maximum - Disk Group Per Host" -$Comments = "VSAN hosts approaching " + $warning + "% limit of " + $vsanDiskGroupMaximum + " Disk Groups per host" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Release +## 1.1 : Fix indentation + using global $clusviews +## 1.2 : Add Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/40 Datastore/992 VSAN Configuration Maximum Magnetic Disks Per Disk Group Report.ps1 b/Plugins/40 Datastore/992 VSAN Configuration Maximum Magnetic Disks Per Disk Group Report.ps1 index 8920c075..33f350f1 100644 --- a/Plugins/40 Datastore/992 VSAN Configuration Maximum Magnetic Disks Per Disk Group Report.ps1 +++ b/Plugins/40 Datastore/992 VSAN Configuration Maximum Magnetic Disks Per Disk Group Report.ps1 @@ -1,45 +1,43 @@ +$Title = "VSAN Configuration Maximum Magnetic Disks Per Disk Group Report" +$Header = "VSAN Config Max - Magnetic Disks Per Disk Group" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings -# Enable VSAN Config Max Magnetic Disks Per Disk Group Reporting? -$vsanConfigMaxReport = $true # Percentage threshold to warn? -$warning = 50 +$vsanWarningThreshold = 50 # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Fix indentation + using global $clusviews -$vsanMaxConfigInfo = @() +# Update settings where there is an override +$vsanWarningThreshold = Get-vCheckSetting $Title "vsanWarningThreshold" $vsanWarningThreshold + +# This config maximum is different for each version of VSAN, 7 for 5.5 $vsanMDMaximum = 7 -if($vsanConfigMaxReport) { - foreach ($cluster in $clusviews) { - if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { - $vmhosts = $cluster.Host - foreach ($vmhost in $vmhosts | Sort-Object -Property Name) { - $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem - $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem - foreach ($diskMapping in $vsanSys.Config.StorageInfo.DiskMapping) { - $mds = ($diskMapping.NonSsd | Measure-Object).count - $checkValue = [int]($mds/$vsanMDMaximum * 100) +foreach ($cluster in $clusviews) { + if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { + foreach ($vmhost in $cluster.Host | Sort-Object -Property Name) { + $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem + $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem + foreach ($diskMapping in $vsanSys.Config.StorageInfo.DiskMapping) { + $mds = ($diskMapping.NonSsd | Measure-Object).count + $checkValue = [int]($mds/$vsanMDMaximum * 100) - if($checkValue -gt $warning) { - $Details = "" |Select VMHost, MDCount - $Details.VMHost = $vmhostView.Name - $Details.MDCount = $mds - $vsanMaxConfigInfo += $Details - } - } + if($checkValue -gt $vsanWarningThreshold) { + New-Object -TypeName PSObject -Property @{ + "VMHost" = $vmhostView.Name + "MDCount" = $mds } } - } - } + } + } + } } -$vsanMaxConfigInfo +$Comments = ("VSAN hosts approaching {0}% limit of {1} magnetic disks per Disk Group" -f $vsanWarningThreshold, $vsanMDMaximum) -$Title = "VSAN Configuration Maximum Magnetic Disks Per Disk Group Report" -$Header = "VSAN Config Max - Magnetic Disks Per Disk Group" -$Comments = "VSAN hosts approaching " + $warning + "% limit of " + $vsanMDMaximum + " magnetic disks per Disk Group" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Release +## 1.1 : Fix indentation + using global $clusviews +## 1.2 : Add Get-vCheckSetting, code clean up \ No newline at end of file diff --git a/Plugins/40 Datastore/993 VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report.ps1 b/Plugins/40 Datastore/993 VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report.ps1 index acf4893f..6ffa102f 100644 --- a/Plugins/40 Datastore/993 VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report.ps1 +++ b/Plugins/40 Datastore/993 VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report.ps1 @@ -1,47 +1,45 @@ +$Title = "VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report" +$Header = "VSAN Config Max - Total Magnetic Disks In All Disk Groups Per Host" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings -# Enable VSAN Config Max Total Magnetic Disks In All Disk Groups Per Host Reporting? -$vsanConfigMaxReport = $true # Percentage threshold to warn? -$warning = 50 +$vsanWarningThreshold = 50 # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Fix indentation + using global $clusviews -$vsanMaxConfigInfo = @() +# Update settings where there is an override +$vsanWarningThreshold = Get-vCheckSetting $Title "vsanWarningThreshold" $vsanWarningThreshold + +# This config maximum is different for each version of VSAN, 35 for 5.5 $vsanTotalMDMaximum = 35 -if($vsanConfigMaxReport) { - foreach ($cluster in $clusviews) { - if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { - $vmhosts = $cluster.Host - foreach ($vmhost in $vmhosts | Sort-Object -Property Name) { - $totalMDs = 0 - $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem - $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem - foreach ($diskMapping in $vsanSys.Config.StorageInfo.DiskMapping) { - $mds = ($diskMapping.NonSsd | Measure-Object).count - $totalMDs += $mds - } - $checkValue = [int]($totalMDs/$vsanTotalMDMaximum * 100) +foreach ($cluster in $clusviews) { + if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { + foreach ($vmhost in $cluster.Host | Sort-Object -Property Name) { + $totalMDs = 0 + $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem + $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem + foreach ($diskMapping in $vsanSys.Config.StorageInfo.DiskMapping) { + $mds = ($diskMapping.NonSsd | Measure-Object).count + $totalMDs += $mds + } + $checkValue = [int]($totalMDs/$vsanTotalMDMaximum * 100) - if($checkValue -gt $warning) { - $Details = "" |Select VMhost, TotalMDCount - $Details.VMhost = $vmhostView.Name - $Details.TotalMDCount = $mds - $vsanMaxConfigInfo += $Details - } - } - } - } + if($checkValue -gt $vsanWarningThreshold) { + New-Object -TypeName PSObject -Property @{ + "VMhost" = $vmhostView.Name + "TotalMDCount" = $mds } + } + } + } } -$vsanMaxConfigInfo +$Comments = ("VSAN hosts approaching {0}% limit of {1} total magnetic disks in all Disk Groups per host" -f $vsanWarningThreshold, $vsanTotalMDMaximum) -$Title = "VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report" -$Header = "VSAN Config Max - Total Magnetic Disks In All Disk Groups Per Host" -$Comments = "VSAN hosts approaching " + $warning + "% limit of " + $vsanTotalMDMaximum + " total magnetic disks in all Disk Groups per host" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Release +## 1.1 : Fix indentation + using global $clusviews +## 1.2 : Add Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/40 Datastore/994 VSAN Configuration Maximum Component Per Host Report.ps1 b/Plugins/40 Datastore/994 VSAN Configuration Maximum Component Per Host Report.ps1 index f5df754f..2adcb669 100644 --- a/Plugins/40 Datastore/994 VSAN Configuration Maximum Component Per Host Report.ps1 +++ b/Plugins/40 Datastore/994 VSAN Configuration Maximum Component Per Host Report.ps1 @@ -1,56 +1,54 @@ +$Title = "VSAN Configuration Maximum Components Per Host Report" +$Header = "VSAN Config Max - Components Per Host" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings -# Enable VSAN Config Max Components Per Host Reporting? -$vsanConfigMaxReport = $true # Percentage threshold to warn? -$warning = 50 +$vsanWarningThreshold = 50 # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Fix indentation + using global $clusviews -$vsanMaxConfigInfo = @() +# Update settings where there is an override +$vsanWarningThreshold = Get-vCheckSetting $Title "vsanWarningThreshold" $vsanWarningThreshold + +# This config maximum is different for each version of VSAN, 3000 for 5.5 $vsanComponentMaximum = 3000 -if($vsanConfigMaxReport) { - foreach ($cluster in $clusviews) { - if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { - $vmhosts = $cluster.Host - foreach ($vmhost in $vmhosts | Sort-Object -Property Name) { - $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem,ConfigManager.VsanInternalSystem - $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem - $vsanIntSys = Get-View -Id $vmhostView.ConfigManager.VsanInternalSystem - - $vsanProps = @("lsom_objects_count","owner") - $results = $vsanIntSys.QueryPhysicalVsanDisks($vsanProps) - $vsanStatus = $vsanSys.QueryHostStatus() - - $componentCount = 0 - $json = $results | ConvertFrom-Json - foreach ($line in $json | Get-Member) { - # ensure component is owned by ESXi host - if($vsanStatus.NodeUuid -eq $json.$($line.Name).owner) { - $componentCount += $json.$($line.Name).lsom_objects_count - } - } - $checkValue = [int]($componentCount/$vsanComponentMaximum * 100) - - if($checkValue -gt $warning) { - $Details = "" |Select VMHost, ComponentCount - $Details.VMHost = $vmhostView.Name - $Details.ComponentCount = $componentCount - $vsanMaxConfigInfo += $Details - } +foreach ($cluster in $clusviews) { + if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { + foreach ($vmhost in ($cluster.Host) | Sort-Object -Property Name) { + $vmhostView = Get-View $vmhost -Property Name,ConfigManager.VsanSystem,ConfigManager.VsanInternalSystem + $vsanSys = Get-View -Id $vmhostView.ConfigManager.VsanSystem + $vsanIntSys = Get-View -Id $vmhostView.ConfigManager.VsanInternalSystem + + $vsanProps = @("lsom_objects_count","owner") + $results = $vsanIntSys.QueryPhysicalVsanDisks($vsanProps) + $vsanStatus = $vsanSys.QueryHostStatus() + + $componentCount = 0 + $json = $results | ConvertFrom-Json + foreach ($line in $json | Get-Member) { + # ensure component is owned by ESXi host + if($vsanStatus.NodeUuid -eq $json.$($line.Name).owner) { + $componentCount += $json.$($line.Name).lsom_objects_count } - } - } + } + $checkValue = [int]($componentCount/$vsanComponentMaximum * 100) + + if($checkValue -gt $vsanWarningThreshold) { + New-Object -TypeName PSObject -Property @{ + "VMHost" = $vmhostView.Name + "ComponentCount" = $componentCount } + } + } + } } -$vsanMaxConfigInfo +$Comments = ("VSAN hosts approaching {0}% limit of {1} components per host. For more information please refer to Cormac Hogan's article Understanding Objects and Components" -f $vsanWarningThreshold, $vsanComponentMaximum ) -$Title = "VSAN Configuration Maximum Components Per Host Report" -$Header = "VSAN Config Max - Components Per Host" -$Comments = "VSAN hosts approaching " + $warning + "% limit of " + $vsanComponentMaximum + " components per host. For more information please refer to Cormac Hogan's article Understanding Objects and Components" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Release +## 1.1 : Fix indentation + using global $clusviews +## 1.2 : Add Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/40 Datastore/995 VSAN Configuration Maximum Hosts Per Cluster Report.ps1 b/Plugins/40 Datastore/995 VSAN Configuration Maximum Hosts Per Cluster Report.ps1 index a3018ff4..2dc0e51e 100644 --- a/Plugins/40 Datastore/995 VSAN Configuration Maximum Hosts Per Cluster Report.ps1 +++ b/Plugins/40 Datastore/995 VSAN Configuration Maximum Hosts Per Cluster Report.ps1 @@ -1,39 +1,37 @@ +$Title = "VSAN Configuration Maximum Hosts Per VSAN Cluster Report" +$Header = "VSAN Config Max - Hosts Per VSAN Cluster" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings -# Enable VSAN Config Max Hosts Per VSAN Cluster Reporting? -$vsanConfigMaxReport = $true # Percentage threshold to warn? -$warning = 45 +$vsanWarningThreshold = 45 # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Fix indentation + using global $clusviews -$vsanMaxConfigInfo = @() +# Update settings where there is an override +$vsanWarningThreshold = Get-vCheckSetting $Title "vsanWarningThreshold" $vsanWarningThreshold + +# This config maximum is different for each version of VSAN, 32 for 5.5 $vsanTotalHostMaximum = 32 -if($vsanConfigMaxReport) { - foreach ($cluster in $clusviews) { - if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { - $vmhosts = $cluster.Host - $totalHosts = ($vmhosts | Measure-Object).count - $checkValue = [int]($totalHosts/$vsanTotalHostMaximum * 100) +foreach ($cluster in $clusviews) { + if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { + $totalHosts = ($cluster.Host | Measure-Object).count + $checkValue = [int]($totalHosts/$vsanTotalHostMaximum * 100) - if($checkValue -gt $warning) { - $Details = "" |Select Cluster, TotalHostCount - $Details.Cluster = $cluster.Name - $Details.TotalHostCount = $totalHosts - $vsanMaxConfigInfo += $Details - } - } - } + if($checkValue -gt $vsanWarningThreshold) { + New-Object -TypeName PSObject -Property @{ + "Cluster" = $cluster.Name + "TotalHostCount" = $totalHosts } + } + } } -$vsanMaxConfigInfo +$Comments = ("VSAN hosts approaching {0}% limit of {1} hosts per VSAN Cluster. For more information about enabling 16+ VSAN Host per VSAN Cluster please refer to William Lam's article Required ESXi advanced setting to support 16+ node VSAN Cluster" -f $vsanWarningThreshold, $vsanTotalHostMaximum) -$Title = "VSAN Configuration Maximum Hosts Per VSAN Cluster Report" -$Header = "VSAN Config Max - Hosts Per VSAN Cluster" -$Comments = "VSAN hosts approaching " + $warning + "% limit of " + $vsanTotalHostMaximum + " hosts per VSAN Cluster. For more information about enabling 16+ VSAN Host per VSAN Cluster please refer to William Lam's article Required ESXi advanced setting to support 16+ node VSAN Cluster" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Release +## 1.1 : Fix indentation + using global $clusviews +## 1.2 : Add Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/40 Datastore/996 VSAN Configuration Maximum VMs Per Host Report.ps1 b/Plugins/40 Datastore/996 VSAN Configuration Maximum VMs Per Host Report.ps1 index 3eff393d..d628ec83 100644 --- a/Plugins/40 Datastore/996 VSAN Configuration Maximum VMs Per Host Report.ps1 +++ b/Plugins/40 Datastore/996 VSAN Configuration Maximum VMs Per Host Report.ps1 @@ -1,42 +1,40 @@ +$Title = "VSAN Configuration Maximum VMs Per Host Report" +$Header = "VSAN Config Max - VMs Per Host" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings -# Enable VSAN Config Max VMs Per Host Reporting? -$vsanConfigMaxReport = $true # Percentage threshold to warn? -$warning = 50 +$vsanWarningThreshold = 50 # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Fix indentation + using global $clusviews -$vsanMaxConfigInfo = @() +# Update settings where there is an override +$vsanWarningThreshold = Get-vCheckSetting $Title "vsanWarningThreshold" $vsanWarningThreshold + +# This config maximum is different for each version of VSAN, 100 for 5.5 $vsanTotalVMsHostMaximum = 100 -if($vsanConfigMaxReport) { - foreach ($cluster in $clusviews) { - if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { - $vmhosts = $cluster.Host - foreach ($vmhost in $vmhosts | Sort-Object -Property Name) { - $vmhostView = Get-View $vmhost -Property Name,Vm - $totalVMs = ($vmhostView.Vm | Measure-Object).count - $checkValue = [int]($totalVMs/$vsanTotalVMsHostMaximum * 100) +foreach ($cluster in $clusviews) { + if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { + foreach ($vmhost in $cluster.Host | Sort-Object -Property Name) { + $vmhostView = Get-View $vmhost -Property Name,Vm + $totalVMs = ($vmhostView.Vm | Measure-Object).count + $checkValue = [int]($totalVMs/$vsanTotalVMsHostMaximum * 100) - if($checkValue -gt $warning) { - $Details = "" |Select VMHost, VMCount - $Details.VMHost = $vmhostView.Name - $Details.VMCount = $totalVMs - $vsanMaxConfigInfo += $Details - } - } - } - } + if($checkValue -gt $vsanWarningThreshold) { + New-Object -TypeName PSObject -Property @{ + "VMHost" = $vmhostView.Name + "VMCount" = $totalVMs } + } + } + } } -$vsanMaxConfigInfo +$Comments = ("VSAN hosts approaching {0}% limit of {1} VMs per host" -f $vsanWarningThreshold, $vsanTotalVMsHostMaximum) -$Title = "VSAN Configuration Maximum VMs Per Host Report" -$Header = "VSAN Config Max - VMs Per Host" -$Comments = "VSAN hosts approaching " + $warning + "% limit of " + $vsanTotalVMsHostMaximum + " VMs per host" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Release +## 1.1 : Fix indentation + using global $clusviews +## 1.2 : Add Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/40 Datastore/997 VSAN Configuration Maximum VMs Per Cluster Report.ps1 b/Plugins/40 Datastore/997 VSAN Configuration Maximum VMs Per Cluster Report.ps1 index c142d6d2..fe663d97 100644 --- a/Plugins/40 Datastore/997 VSAN Configuration Maximum VMs Per Cluster Report.ps1 +++ b/Plugins/40 Datastore/997 VSAN Configuration Maximum VMs Per Cluster Report.ps1 @@ -1,37 +1,37 @@ +$Title = "VSAN Configuration Maximum VMs Per VSAN Cluster Report" +$Header = "VSAN Config Max - VMs Per VSAN Cluster" +$Display = "Table" +$Author = "William Lam" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings -# Enable VSAN Config Max VMs Per VSAN Cluster Reporting? -$vsanConfigMaxReport = $true # Percentage threshold to warn? -$warning = 50 +$vsanWarningThreshold = 50 # End of Settings -# Changelog -## 1.0 : Initial Release -$vsanMaxConfigInfo = @() +# Update settings where there is an override +$vsanWarningThreshold = Get-vCheckSetting $Title "vsanWarningThreshold" $vsanWarningThreshold + +# This config maximum is different for each version of VSAN, 3200 for 5.5 $vsanTotalVMsPerClusterMaximum = 3200 -if($vsanConfigMaxReport) { - foreach ($cluster in $clusviews) { - if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { - $totalVMs = (Get-View -ViewType VirtualMachine -SearchRoot $cluster.MoRef -Property Name).Count - $checkValue = [int]($totalVMs/$vsanTotalVMsPerClusterMaximum * 100) - - if($checkValue -gt $warning) { - $Details = "" |Select Cluster, TotalVMCount - $Details.Cluster = $cluster.Name - $Details.TotalVMCount = $totalVMs - $vsanMaxConfigInfo += $Details - } - } - } +foreach ($cluster in $clusviews) { + if($cluster.ConfigurationEx.VsanConfigInfo.Enabled) { + $totalVMs = (Get-View -ViewType VirtualMachine -SearchRoot $cluster.MoRef -Property Name).Count + $checkValue = [int]($totalVMs/$vsanTotalVMsPerClusterMaximum * 100) + + if($checkValue -gt $vsanWarningThreshold) { + New-Object -TypeName PSObject -Property @{ + "Cluster" = $cluster.Name + "TotalVMCount" = $totalVMs } + } + } } -$vsanMaxConfigInfo -$Title = "VSAN Configuration Maximum VMs Per VSAN Cluster Report" -$Header = "VSAN Config Max - VMs Per VSAN Cluster" -$Comments = "VSAN hosts approaching " + $warning + "% limit of " + $vsanTotalVMsPerClusterMaximum + " VMs per VSAN Cluster" -$Display = "Table" -$Author = "William Lam" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +$Comments = ("VSAN hosts approaching {0}% limit of {1} VMs per VSAN Cluster" -f $vsanWarningThreshold, $vsanTotalVMsPerClusterMaximum) + +# Changelog +## 1.0 : Initial Release +## 1.1 : Add Get-vCheckSetting and code refactor \ No newline at end of file diff --git a/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 b/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 index 7e2b58f3..4af48f90 100644 --- a/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 +++ b/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 @@ -1,15 +1,18 @@ +$Title = "Checking Standard vSwitch Ports Free" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # vSwitch Port Left $vSwitchLeft = 5 # End of Settings -$Result = $VMH | Get-VirtualSwitch -Standard | Sort NumPortsAvailable | Where {$_.NumPortsAvailable -lt $($vSwitchLeft)} | Select VMHost, Name, NumPortsAvailable -$Result +# Update settings where there is an override +$vSwitchLeft = Get-vCheckSetting $Title "vSwitchLeft" $vSwitchLeft -$Title = "Checking Standard vSwitch Ports Free" -$Header = "Standard vSwitch with less than $vSwitchLeft Port(s) Free: $(@($Result).Count)" -$Comments = "The following standard vSwitches have less than $vSwitchLeft left" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$VMH | Get-VirtualSwitch -Standard | Sort NumPortsAvailable | Where {$_.NumPortsAvailable -lt $($vSwitchLeft)} | Select VMHost, Name, NumPortsAvailable + +$Header = "Standard vSwitch with less than $vSwitchLeft Port(s) Free: [count]" +$Comments = "The following standard vSwitches have less than $vSwitchLeft left" \ No newline at end of file diff --git a/Plugins/50 Network/80 DvPG with less than x Ports Free.ps1 b/Plugins/50 Network/80 DvPG with less than x Ports Free.ps1 index c4f2f733..b5677b43 100644 --- a/Plugins/50 Network/80 DvPG with less than x Ports Free.ps1 +++ b/Plugins/50 Network/80 DvPG with less than x Ports Free.ps1 @@ -1,39 +1,33 @@ +$Title = "Checking Distributed vSwitch Port Groups for Ports Free" +$Display = "Table" +$Author = "Kyle Ruddy" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Distributed vSwitch PortGroup Ports Left $DvSwitchLeft = 10 # End of Settings +# Update settings where there is an override +$DvSwitchLeft = Get-vCheckSetting $Title "DvSwitchLeft" $DvSwitchLeft + if ((Get-PSSnapin VMware.VimAutomation.Vds -ErrorAction SilentlyContinue) -or (Get-Module VMware.VimAutomation.Vds -ErrorAction SilentlyContinue)) -{ - if ($vdspg = Get-VDSwitch | Sort-Object -Property Name | Get-VDPortgroup) +{ + if ($vdspg = Get-VDSwitch | Sort-Object -Property Name | Get-VDPortgroup) { - $ImpactedDVS = @() - Foreach ($PG in $vdspg | Where-Object {-not $_.IsUplink -and $_.PortBinding -ne 'Ephemeral' -and -not ($_.PortBinding -eq 'Static' -and $_.ExtensionData.Config.AutoExpand)} ) { - $NumPorts = $PG.NumPorts - $NumVMs = ($PG.ExtensionData.VM).Count - $OpenPorts = $NumPorts - $NumVMs - - If ($OpenPorts -lt $DvSwitchLeft) + If (($PG.NumPorts -($PG.ExtensionData.VM).Count) -lt $DvSwitchLeft) { - $myObj = "" | select vDSwitch,Name,OpenPorts - $myObj.vDSwitch = $PG.VDSwitch - $myObj.Name = $PG.Name - $myObj.OpenPorts = $OpenPorts - - $ImpactedDVS += $myObj + New-Object -TypeName PSObject -Property @{ + "vDSwitch" = $PG.VDSwitch + "Name" = $PG.Name + OpenPorts = ($PG.NumPorts -($PG.ExtensionData.VM).Count) } } } - - $ImpactedDVS } } -$Title = "Checking Distributed vSwitch Port Groups for Ports Free" -$Header = "Distributed vSwitch Port Groups with less than $vSwitchLeft Port(s) Free: $(@($ImpactedDVS).Count)" -$Comments = "The following Distributed vSwitch Port Groups have less than $vSwitchLeft left" -$Display = "Table" -$Author = "Kyle Ruddy" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +$Header = "Distributed vSwitch Port Groups with less than $vSwitchLeft Port(s) Free: [count]" +$Comments = "The following Distributed vSwitch Port Groups have less than $vSwitchLeft left" \ No newline at end of file diff --git a/Plugins/50 Network/98 vSwitch Security.ps1 b/Plugins/50 Network/98 vSwitch Security.ps1 index 73d4ef90..0f1a1478 100644 --- a/Plugins/50 Network/98 vSwitch Security.ps1 +++ b/Plugins/50 Network/98 vSwitch Security.ps1 @@ -1,3 +1,11 @@ +$Title = "vSwitch Security" +$Header = "vSwitch and portgroup security settings" +$Comments = "All security options for standard vSwitches should be set to REJECT. Distributed vSwitches may require ForgedTrasmits in the default portgroup but should be disabled in other VM Network portgroups unless expressly required." +$Display = "Table" +$Author = "Justin Mercier, Sam McGeown, John Sneddon" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Enable Checking of vSwitch security settings? $vSwitchSecurityCheck = $true @@ -13,6 +21,13 @@ $MacChangesPolicy = $true ## 1.0 : Initial Release ## 1.1 : Re-written for performance improvements ## 1.2 : Added version check (Issue #71) +## 1.3 add Get-vCheckSetting + +# Update settings where there is an override +$vSwitchSecurityCheck = Get-vCheckSetting $Title "vSwitchSecurityCheck" $vSwitchSecurityCheck +$AllowPromiscuousPolicy = Get-vCheckSetting $Title "AllowPromiscuousPolicy" $AllowPromiscuousPolicy +$ForgedTransmitsPolicy = Get-vCheckSetting $Title "ForgedTransmitsPolicy" $ForgedTransmitsPolicy +$MacChangesPolicy = Get-vCheckSetting $Title "MacChangesPolicy" $MacChangesPolicy # Check Power CLI version. Build must be at least 1012425 (5.1 Release 2) to contain Get-VDPortGroup cmdlet $VersionOK = $false @@ -77,7 +92,7 @@ if ($VersionOK) { $Output.AllowPromiscuous = $_.ExtensionData.Spec.Policy.Security.AllowPromiscuous -and ($portgroup.Spec.Policy.Security.MacChanges -eq $null) $Output.ForgedTransmits = $_.ExtensionData.Spec.Policy.Security.ForgedTransmits -and ($portgroup.Spec.Policy.Security.MacChanges -eq $null) $Output.MacChanges = $_.Spec.ExtensionData.Policy.Security.MacChanges -and ($portgroup.Spec.Policy.Security.MacChanges -eq $null) - $results += $Output + $results += $Output } } @@ -86,12 +101,4 @@ if ($VersionOK) { else { Write-Warning "PowerCLi version installed is lower than 5.1 Release 2" New-Object PSObject -Property @{"Message"="PowerCLi version installed is lower than 5.1 Release 2, please update to use this plugin"} -} - -$Title = "vSwitch Security" -$Header = "vSwitch and portgroup security settings" -$Comments = "All security options for standard vSwitches should be set to REJECT. Distributed vSwitches may require ForgedTrasmits in the default portgroup but should be disabled in other VM Network portgroups unless expressly required." -$Display = "Table" -$Author = "Justin Mercier, Sam McGeown, John Sneddon" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +} \ No newline at end of file diff --git a/Plugins/70 Misc/108 SRM RPO Violations.ps1 b/Plugins/70 Misc/108 SRM RPO Violations.ps1 index dbf20bca..5cbc8f88 100644 --- a/Plugins/70 Misc/108 SRM RPO Violations.ps1 +++ b/Plugins/70 Misc/108 SRM RPO Violations.ps1 @@ -18,7 +18,15 @@ # Use at your own risk. # ## - + +$Title = "Site Recovery Manager - RPO Violation Report" +$Header = "Site Recovery Manager - RPO Violations: [count]" +$Comments = "This is a customizable report of RPO violations found in the vCenter event log." +$Display = "Table" +$Author = "Joel Gibson, based on work by Alan Renouf" +$PluginVersion = 0.7 +$PluginCategory = "vSphere" + # Start of Settings # SRM RPO Violations: Set the number of minutes an RPO has exceeded to report on $RPOviolationMins = 240 @@ -27,7 +35,12 @@ $VMNameRegex = "" # SRM RPO Violations: Report on unresolved RPO violations only? $ActiveViolationsOnly = $true # End of Settings - + +# Update settings where there is an override +$RPOviolationMins = Get-vCheckSetting $Title "RPOviolationMins" $RPOviolationMins +$VMNameRegex = Get-vCheckSetting $Title "VMNameRegex" $VMNameRegex +$ActiveViolationsOnly = Get-vCheckSetting $Title "ActiveViolationsOnly" $ActiveViolationsOnly + # Changelog ## 0.1 : Initial version. ## 0.2 : Minor tweaks. Removed two unnecessary configurable variables. Utilized existing $MaxSampleVIEvent variable. @@ -35,81 +48,49 @@ $ActiveViolationsOnly = $true ## 0.4 : Fixed a bug/typo while filtering results by duration of RPO violation. ($RPOviolationMin should have been $RPOviolationMins) ## 0.5 : Fixed a bug where filtering results by duration of RPO violation was not working. ## 0.6 : Change to Get-VIEventPlus, removed MaxSampleVIEvent variable. +## 0.7 : Update to Get-vCheckSetting, layout changes ## Begin code block obtained from: http://www.virtu-al.net/2013/06/14/reporting-on-rpo-violations-from-vsphere-replication/ # modified by Joel Gibson -$VMs = $VM | Where { $_.name -match $VMNameRegex } - -$Results = @() -Foreach ($RPOvm in $VMs) { - - $Events = Get-VIEventPlus -Entity $RPOvm - $RPOEvents = $Events | where { $_.EventTypeID -match "rpo" } | Where { $_.Vm.Name -eq $RPOvm.Name } | Select EventTypeId, CreatedTime, FullFormattedMessage, @{Name="VMName";Expression={$_.Vm.Name}} | Sort CreatedTime - if ($RPOEvents) { - $Count = 0 +Foreach ($RPOvm in ($VMs | Where { $_.name -match $VMNameRegex })) { + $RPOEvents = Get-VIEventPlus -Entity $RPOvm | where { $_.EventTypeID -match "rpo" } | Where { $_.Vm.Name -eq $RPOvm.Name } | Select EventTypeId, CreatedTime, FullFormattedMessage, @{Name="VMName";Expression={$_.Vm.Name}} | Sort CreatedTime + if ($RPOEvents) { + $Count = 0 - do { - $details = "" | Select VMName, ViolationStart, ViolationEnd, Mins - if ($RPOEvents[$count].EventTypeID -match "Violated") { - If (-not $details.Start) { - $Details.VMName = $RPOEvents[$Count].VMName - $Details.ViolationStart = $RPOEvents[$Count].CreatedTime - Do { - $Count++ - } until (($RPOEvents[$Count].EventTypeID -match "Restored") -or ($Count -gt $RPOEvents.Count)) - if ($RPOEvents[$count].EventTypeID -match "Restored") { - $details.ViolationEnd = $RPOEvents[$Count].CreatedTime - $Time = $details.ViolationEnd - $details.ViolationStart - $details.Mins = $Time.TotalMinutes - - } Else { - $details.ViolationEnd = "No End Date" - $Time = $(Get-Date) - $details.ViolationStart - $details.Mins = $Time.TotalMinutes - - } - } - } - $Results += $details - $Count++ - } until ($count -gt $RPOEvents.Count) - } -} -## End of code block obtained from: http://www.virtu-al.net/2013/06/14/reporting-on-rpo-violations-from-vsphere-replication/. - -## filter the results based on the number of minutes an RPO has been exceeded by -$Results = $Results | Where { $_.Mins -gt $RPOviolationMins} - -## format the number of minutes for the RPO violation -Foreach ($event in $Results) { - if ($event.ViolationEnd -eq "No End Date") { - $EventDurationTime = $(Get-Date) - $event.ViolationStart - - } else { - $EventDurationTime = $event.ViolationEnd - $event.ViolationStart - - } - - $event.Mins = "{0:N2}" -f $EventDurationTime.TotalMinutes + do { + $details = "" | Select VMName, ViolationStart, ViolationEnd, Mins + if ($RPOEvents[$count].EventTypeID -match "Violated") { + If (-not $details.Start) { + $Details.VMName = $RPOEvents[$Count].VMName + $Details.ViolationStart = $RPOEvents[$Count].CreatedTime + Do { + $Count++ + } until (($RPOEvents[$Count].EventTypeID -match "Restored") -or ($Count -gt $RPOEvents.Count)) + if ($RPOEvents[$count].EventTypeID -match "Restored") { + $details.ViolationEnd = $RPOEvents[$Count].CreatedTime + $Time = $details.ViolationEnd - $details.ViolationStart + + } Else { + $details.ViolationEnd = "No End Date" + $Time = $(Get-Date) - $details.ViolationStart + + } + $details.Mins = ("{0:N2}" -f $Time.TotalMinutes) + } + } + ## filter the results based on the number of minutes an RPO has been exceeded by + ## filter the results based on unresolved violations, if desired + if ($details.Mins -gt $RPOviolationMins) + { + if ((-not $ActiveViolationsOnly) -or ($ActiveViolationsOnly -and $details.ViolationEnd -eq "No End Date")) + { + $details + } + } + $Count++ + } until ($count -gt $RPOEvents.Count) + } } - -## filter the results based on unresolved violations, if desired -if ($ActiveViolationsOnly) { - - ## filter results based on open violations - $Results = $Results | Where { $_.ViolationEnd -eq "No End Date" } - - } - -## output VMs that have exceeded their RPO by $RPOviolationMins, based on defined criteria -$Results - -$Title = "Site Recovery Manager - RPO Violation Report" -$Header = "Site Recovery Manager - RPO Violations: $(@($Results).count)" -$Comments = "This is a customizable report of RPO violations found in the vCenter event log." -$Display = "Table" -$Author = "Joel Gibson, based on work by Alan Renouf" -$PluginVersion = 0.6 -$PluginCategory = "vSphere" +## End of code block obtained from: http://www.virtu-al.net/2013/06/14/reporting-on-rpo-violations-from-vsphere-replication/. \ No newline at end of file From 22ff17c43c5e25c0ecc9fb79cb02d9f91cb6360f Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 1 Dec 2016 14:45:17 +1100 Subject: [PATCH 27/50] Create 125 VMs with Isolated Configuration Files.ps1 Pull Request #443. --- ... VMs with Isolated Configuration Files.ps1 | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 diff --git a/Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 b/Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 new file mode 100644 index 00000000..cbf3362f --- /dev/null +++ b/Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 @@ -0,0 +1,32 @@ +$Title = "VMs with configuration files (*.vmx, etc) isolated from their disks" +$Header = "VMs with configuration files (*.vmx, etc) isolated from their disks : [count]" +$Comments = "The following VMs have their configuration files (*.vmx, etc) stored in a different datastore than their disks" +$Display = "Table" +$Author = "Kristofor Hines" +$PluginVersion = 1.0 +$PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$isolatedVMXs = @() +Foreach ($CHKVM in $FullVM) +{ + $vmxDatastore = (($CHKVM.Summary.Config.VmPathName).Split(']')[0].TrimStart('[')) + $vmdkDatastores = @() + $CHKVM.Config.Hardware.Device | % + { + If ($_.Backing.Filename -ne $null) + { + $vmdkDatastores += ($_.Backing.Filename).Split(']')[0].TrimStart('[') + } + } + + If ( -not ($vmdkDatastores.Contains($vmxDatastore))) + { + New-Object -TypeName PSObject -Property @{ + "VM" = $CHKVM.Name + "VmxDatastore" = $vmxDatastore + "VmdkDatastores" = ($vmdkDatastores -join ", ") } + } +} From a1465e3bc9cba409d6c740ca1f8d241264a9dc7a Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 1 Dec 2016 15:01:07 +1100 Subject: [PATCH 28/50] Stray Bracket in $header --- Plugins/30 Host/07 Hosts Overcommit State.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/30 Host/07 Hosts Overcommit State.ps1 b/Plugins/30 Host/07 Hosts Overcommit State.ps1 index 650d3a4c..4175d298 100644 --- a/Plugins/30 Host/07 Hosts Overcommit State.ps1 +++ b/Plugins/30 Host/07 Hosts Overcommit State.ps1 @@ -1,5 +1,5 @@ $Title = "Hosts Overcommit state" -$Header = "Hosts overcommitting memory: [count]]" +$Header = "Hosts overcommitting memory: [count]" $Comments = "Overcommitted hosts may cause issues with performance if memory is not issued when needed, this may cause ballooning and swapping" $Display = "Table" $Author = "Alan Renouf" @@ -57,4 +57,4 @@ Foreach ($VMHost in $VMH) { } Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $lang.Complete -Completed -$OverCommit | Select Host, "TotalMem$Units", "TotalAssignedMem$Units", "TotalUsed$Units", "OverCommit$Units" \ No newline at end of file +$OverCommit | Select Host, "TotalMem$Units", "TotalAssignedMem$Units", "TotalUsed$Units", "OverCommit$Units" From 0e8f787448c1b8ba9a0fb97838369d4a2082b659 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Tue, 6 Dec 2016 14:35:47 +1100 Subject: [PATCH 29/50] Add Alarm definitions to init plugin --- Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index 9bfdb9be..fd0667ab 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -1,6 +1,6 @@ $Title = "Connection settings for vCenter" $Author = "Alan Renouf" -$PluginVersion = 1.9 +$PluginVersion = 1.10 $Header = "Connection Settings" $Comments = "Connection Plugin for connecting to vSphere" $Display = "None" @@ -33,6 +33,7 @@ $pLang = DATA { collectDCluster = Collecting Detailed Cluster Objects collectDDatastore = Collecting Detailed Datastore Objects collectDDatastoreCluster = Collecting Detailed Datastore Cluster Objects + collectAlarms = Collecting Alarm Definitions '@ } # Override the default (en) if it exists in lang directory @@ -161,6 +162,8 @@ Write-CustomOut $pLang.collectDCluster $clusviews = Get-View -ViewType ClusterComputeResource Write-CustomOut $pLang.collectDDatastore $storageviews = Get-View -ViewType Datastore +Write-CustomOut $pLang.collectAlarms +$valarms = $alarmMgr.GetAlarm($null) | select value, @{N="name";E={(Get-View -Id $_).Info.Name}} # Find out which version of the API we are connecting to $VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars(0) From 887128c3f8a6be1553d56a12f6f5bdbcbee262f6 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Tue, 6 Dec 2016 14:36:22 +1100 Subject: [PATCH 30/50] Remove $valarms Moved to init plugin --- Plugins/30 Host/36 Host Alarms.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Plugins/30 Host/36 Host Alarms.ps1 b/Plugins/30 Host/36 Host Alarms.ps1 index 8921af91..a8885ba4 100644 --- a/Plugins/30 Host/36 Host Alarms.ps1 +++ b/Plugins/30 Host/36 Host Alarms.ps1 @@ -3,14 +3,12 @@ $Header = "Host(s) Alarm(s): [count]" $Comments = "The following alarms have been registered against hosts in vCenter" $Display = "Table" $Author = "Alan Renouf, John Sneddon" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" # Start of Settings # End of Settings -$valarms = $alarmMgr.GetAlarm($null) | select value, @{N="name";E={(Get-View -Id $_).Info.Name}} - foreach ($HostsView in ($HostsViews | Where {$_.TriggeredAlarmState} | Sort-Object Name)){ Foreach ($hostsTriggeredAlarm in $HostsView.TriggeredAlarmState){ New-Object PSObject -Property @{ From f537af46d568192d645750eedf6cde85c92a255f Mon Sep 17 00:00:00 2001 From: Sneddo Date: Wed, 7 Dec 2016 09:04:06 +1100 Subject: [PATCH 31/50] Fix version detection for PowerCLI 6.5 Issue #514 --- Plugins/50 Network/98 vSwitch Security.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/50 Network/98 vSwitch Security.ps1 b/Plugins/50 Network/98 vSwitch Security.ps1 index 0f1a1478..fc4e7625 100644 --- a/Plugins/50 Network/98 vSwitch Security.ps1 +++ b/Plugins/50 Network/98 vSwitch Security.ps1 @@ -3,7 +3,7 @@ $Header = "vSwitch and portgroup security settings" $Comments = "All security options for standard vSwitches should be set to REJECT. Distributed vSwitches may require ForgedTrasmits in the default portgroup but should be disabled in other VM Network portgroups unless expressly required." $Display = "Table" $Author = "Justin Mercier, Sam McGeown, John Sneddon" -$PluginVersion = 1.3 +$PluginVersion = 1.4 $PluginCategory = "vSphere" # Start of Settings @@ -31,7 +31,7 @@ $MacChangesPolicy = Get-vCheckSetting $Title "MacChangesPolicy" $MacChangesPolic # Check Power CLI version. Build must be at least 1012425 (5.1 Release 2) to contain Get-VDPortGroup cmdlet $VersionOK = $false -if (((Get-PowerCLIVersion) -match "VMware vSphere PowerCLI (.*) build ([0-9]+)")) { +if (((Get-PowerCLIVersion) -match "VMware (vSphere )?PowerCLI (.*) build ([0-9]+)")) { if ([int]($Matches[2]) -ge 1012425) { $VersionOK = $true if ([int]($Matches[2]) -ge 2548067) { @@ -101,4 +101,4 @@ if ($VersionOK) { else { Write-Warning "PowerCLi version installed is lower than 5.1 Release 2" New-Object PSObject -Property @{"Message"="PowerCLi version installed is lower than 5.1 Release 2, please update to use this plugin"} -} \ No newline at end of file +} From 6dbdaecf5d4a536d2261fc549da98489e14653bb Mon Sep 17 00:00:00 2001 From: Sneddo Date: Wed, 7 Dec 2016 09:05:07 +1100 Subject: [PATCH 32/50] Updated changelog Forgot in last commit --- Plugins/50 Network/98 vSwitch Security.ps1 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Plugins/50 Network/98 vSwitch Security.ps1 b/Plugins/50 Network/98 vSwitch Security.ps1 index fc4e7625..b542e099 100644 --- a/Plugins/50 Network/98 vSwitch Security.ps1 +++ b/Plugins/50 Network/98 vSwitch Security.ps1 @@ -17,12 +17,6 @@ $ForgedTransmitsPolicy = $true $MacChangesPolicy = $true # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Re-written for performance improvements -## 1.2 : Added version check (Issue #71) -## 1.3 add Get-vCheckSetting - # Update settings where there is an override $vSwitchSecurityCheck = Get-vCheckSetting $Title "vSwitchSecurityCheck" $vSwitchSecurityCheck $AllowPromiscuousPolicy = Get-vCheckSetting $Title "AllowPromiscuousPolicy" $AllowPromiscuousPolicy @@ -102,3 +96,10 @@ else { Write-Warning "PowerCLi version installed is lower than 5.1 Release 2" New-Object PSObject -Property @{"Message"="PowerCLi version installed is lower than 5.1 Release 2, please update to use this plugin"} } + +# Changelog +## 1.0 : Initial Release +## 1.1 : Re-written for performance improvements +## 1.2 : Added version check (Issue #71) +## 1.3 : Add Get-vCheckSetting +## 1.4 : Fix Version checking for PowerCLI 6.5 - vSphere is no longer in the product name (Issue #514) From 7c14729551c2e4c94b8676e6f38a4a35575b50d8 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Fri, 9 Dec 2016 09:15:19 +1100 Subject: [PATCH 33/50] Missing parentheses --- Plugins/40 Datastore/39 Datastore OverAllocation.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 b/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 index 9bfb0b36..75c1257d 100644 --- a/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 +++ b/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 @@ -24,7 +24,7 @@ foreach ($storage in $filteredstorageviews) { $allocation = [math]::round(((($storage.Summary.Capacity - $storage.Summary.FreeSpace) + $storage.Summary.Uncommitted)*100)/$storage.Summary.Capacity,0) - if (($allocation-100) -gt $OverAllocation { + if (($allocation-100) -gt $OverAllocation) { New-Object -TypeName PSObject -Property @{ "Datastore" = $storage.name "OverAllocation" = $overAllocation } @@ -36,4 +36,4 @@ $Header = ("Datastore OverAllocation Over {0}%: [count]" -f $OverAllocation) # Change Log # 1.3 : 20150223 monahancj - Added datastore filtering -# 1.4 : Added Get-vCheckSetting, fixed logic to report over allocation properly \ No newline at end of file +# 1.4 : Added Get-vCheckSetting, fixed logic to report over allocation properly From 65c4c93989cdf16504f3bf0c19eddf41433ef46a Mon Sep 17 00:00:00 2001 From: Sneddo Date: Fri, 9 Dec 2016 11:46:00 +1100 Subject: [PATCH 34/50] Fix blank report from being emailed Issue #512 --- vCheck.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vCheck.ps1 b/vCheck.ps1 index e66f9a76..4cfc43c5 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -1012,6 +1012,10 @@ if (-not $GUIConfig) { $pr | Add-Member -Type NoteProperty -Name pluginID -Value "plugin-$p" $p++ } + if ($pr.Details -ne $null) + { + $emptyReport = $false + } } # Run Style replacement From 896ea5a53f0721b15d7bfe2288db1582792364c5 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 15 Dec 2016 15:17:36 +1100 Subject: [PATCH 35/50] Adding Get-vCehck settings and bug fixes --- .../00 Connection Plugin for vCenter.ps1 | 583 +++++++++--------- .../42 Windows vCenter Event Logs.ps1 | 44 ++ .../20 Cluster/10 HA Configuration Issues.ps1 | 3 +- Plugins/20 Cluster/15 HA VMs restarted.ps1 | 6 +- Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 | 21 +- .../20 Cluster/72 s-vMotion Information.ps1 | 3 +- Plugins/30 Host/31 NTP Name and Service.ps1 | 2 +- .../53 Hardware status warnings-errors.ps1 | 16 +- .../34 Number of VMs per Datastore.ps1 | 13 +- .../39 Datastore OverAllocation.ps1 | 2 +- Plugins/50 Network/98 vSwitch Security.ps1 | 14 +- Plugins/60 VM/02 Snapshot Information.ps1 | 107 ++-- Plugins/60 VM/04 Map disk region event.ps1 | 24 +- Plugins/60 VM/09 Created or cloned VMs.ps1 | 19 +- Plugins/60 VM/10 Removed VMs.ps1 | 23 +- ...00 VMs with CPU or Memory Reservations.ps1 | 24 +- Plugins/60 VM/102 VM Logging.ps1 | 45 +- Plugins/60 VM/106 Find Phantom Snapshots.ps1 | 53 +- Plugins/60 VM/11 VMs with over CPU Count.ps1 | 24 +- Plugins/60 VM/114 VM Tools Not Up to Date.ps1 | 33 +- .../60 VM/12 VMs Swapping or Ballooning.ps1 | 22 +- Plugins/60 VM/120 Multi-writer.ps1 | 24 +- ... BusSharingMode - Physical and Virtual.ps1 | 25 +- Plugins/60 VM/122 NonPersistent Disks.ps1 | 43 +- ... VMs with Isolated Configuration Files.ps1 | 4 +- .../60 VM/13 Invalid or inaccessible VMs.ps1 | 12 +- ...14 VMs restarted due to Guest OS Error.ps1 | 29 +- .../19 Guests with less than X MB free.ps1 | 52 +- .../60 VM/200 VMs on ephemeral portgroup.ps1 | 12 +- .../60 VM/201 VMs Hot Add Configuration.ps1 | 21 +- Plugins/60 VM/202 VMs MMU Configuration.ps1 | 18 +- .../60 VM/22 Checking VM Hardware Version.ps1 | 25 +- .../60 VM/25 VMs in inconsistent folders.ps1 | 39 +- Plugins/60 VM/26 No VM Tools.ps1 | 25 +- Plugins/60 VM/27 VM Tools Issues.ps1 | 25 +- .../60 VM/28 Removable Media Connected.ps1 | 26 +- Plugins/60 VM/30 Single Storage VMs.ps1 | 23 +- Plugins/60 VM/32 VM CPU Percent RDY.ps1 | 58 +- Plugins/60 VM/33 VM CPU Usage.ps1 | 26 +- Plugins/60 VM/37 VM Alarms.ps1 | 41 +- Plugins/60 VM/40 VCB Garbage.ps1 | 16 +- .../45 VMs needing snapshot consolidation.ps1 | 19 +- Plugins/60 VM/48 Find VM Disk Format.ps1 | 15 +- ...s with CPU or Memory Limits Configured.ps1 | 15 +- ...chines with incorrect OS Configuration.ps1 | 33 +- ...s with less hard disks than partitions.ps1 | 30 +- Plugins/60 VM/60 Powered Off VMs.ps1 | 33 +- Plugins/60 VM/61 Guest OS Pivot table.ps1 | 24 +- .../60 VM/62 Unwanted Virtual Hardware.ps1 | 36 +- Plugins/60 VM/620 CBT Status.ps1 | 25 +- Plugins/60 VM/64 Snapshots Oversize.ps1 | 66 +- Plugins/60 VM/66 Misnamed VM.ps1 | 7 +- Plugins/60 VM/76 VM Network State.ps1 | 40 +- Plugins/60 VM/78 Reset VMs.ps1 | 24 +- ...Find VMs in Uncontrolled Snapshot Mode.ps1 | 18 +- Plugins/60 VM/85 Snapshot Activity.ps1 | 22 +- .../999 VeryLastPlugin Used to Disconnect.ps1 | 4 +- 57 files changed, 1109 insertions(+), 927 deletions(-) create mode 100644 Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index 9bfdb9be..7087dfd0 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -1,290 +1,293 @@ -$Title = "Connection settings for vCenter" -$Author = "Alan Renouf" -$PluginVersion = 1.9 -$Header = "Connection Settings" -$Comments = "Connection Plugin for connecting to vSphere" -$Display = "None" -$PluginCategory = "vSphere" - -# Start of Settings -# Please Specify the address (and optional port) of the vCenter server to connect to [servername(:port)] -$Server = "192.168.0.0" -# End of Settings - -# Update settings where there is an override -$Server = Get-vCheckSetting $Title "Server" $Server - -# Setup plugin-specific language table -$pLang = DATA { - ConvertFrom-StringData @' - connReuse = Re-using connection to VI Server - connOpen = Connecting to VI Server - connError = Unable to connect to vCenter, please ensure you have altered the vCenter server address correctly. To specify a username and password edit the connection string in the file $GlobalVariables - custAttr = Adding Custom properties - collectVM = Collecting VM Objects - collectHost = Collecting VM Host Objects - collectCluster = Collecting Cluster Objects - collectDatastore = Collecting Datastore Objects - collectDVM = Collecting Detailed VM Objects - collectTemplate = Collecting Template Objects - collectDVIO = Collecting Detailed VI Objects - collectAlarm = Collecting Detailed Alarm Objects - collectDHost = Collecting Detailed VMHost Objects - collectDCluster = Collecting Detailed Cluster Objects - collectDDatastore = Collecting Detailed Datastore Objects - collectDDatastoreCluster = Collecting Detailed Datastore Cluster Objects -'@ -} -# Override the default (en) if it exists in lang directory -Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLang -ErrorAction SilentlyContinue - -# Find the VI Server and port from the global settings file -$VIServer = ($Server -Split ":")[0] -if (($server -split ":")[1]) { - $port = ($server -split ":")[1] -} -else -{ - $port = 443 -} - -# Path to credentials file which is automatically created if needed -$Credfile = $ScriptPath + "\Windowscreds.xml" - -# -# Adding PowerCLI core module/pssnapin -# -# Possibilities: -# 1) PSSnpain (-le 5.8R1) -# 2) Module + PSSnapin (-gt 5.8R1/-lt 6.5R1) -# 3) Module (-ge 6.5R1) - -$pcliCore = 'VMware.VimAutomation.Core' - -$pssnapinPresent = $false -$psmodulePresent = $false - -if(Get-Module -Name $pcliCore -ListAvailable){ - $psmodulePresent = $true - if(!(Get-Module -Name $pcliCore)){ - Import-Module -Name $pcliCore - } -} - -if(Get-PSSnapin -Name $pcliCore -Registered -ErrorAction SilentlyContinue){ - $pssnapinPresent = $true - if(!(Get-PSSnapin -Name $pcliCore -ErrorAction SilentlyContinue)){ - Add-PSSnapin -Name $pcliCore - } -} - -if(!$pssnapinPresent -and !$psmodulePresent){ - Write-Error "Can't find PowerCLI. Is it installed?" - return -} - -$OpenConnection = $global:DefaultVIServers | where { $_.Name -eq $VIServer } -if($OpenConnection.IsConnected) { - Write-CustomOut ( "{0}: {1}" -f $pLang.connReuse, $Server ) - $VIConnection = $OpenConnection -} else { - Write-CustomOut ( "{0}: {1}" -f $pLang.connOpen, $Server ) - $VIConnection = Connect-VIServer -Server $VIServer -Port $Port -} - -if (-not $VIConnection.IsConnected) { - Write-Error $pLang.connError -} - -Write-CustomOut $pLang.custAttr - -function Get-VMLastPoweredOffDate { - param([Parameter(Mandatory=$true,ValueFromPipeline=$true)] - [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm) - process { - $Report = "" | Select-Object -Property Name,LastPoweredOffDate - $Report.Name = $_.Name - $Report.LastPoweredOffDate = (Get-VIEventPlus -Entity $vm | ` - Where-Object { $_.Gettype().Name -eq "VmPoweredOffEvent" } | ` - Select-Object -First 1).CreatedTime - $Report - } -} - -function Get-VMLastPoweredOnDate { - param([Parameter(Mandatory=$true,ValueFromPipeline=$true)] - [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm) - - process { - $Report = "" | Select-Object -Property Name,LastPoweredOnDate - $Report.Name = $_.Name - $Report.LastPoweredOnDate = (Get-VIEventPlus -Entity $vm | ` - Where-Object { $_.Gettype().Name -match "VmPoweredOnEvent" } | ` - Select-Object -First 1).CreatedTime - $Report - } -} - -New-VIProperty -Name LastPoweredOffDate -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOffDate -vm $Args[0]).LastPoweredOffDate} | Out-Null -New-VIProperty -Name LastPoweredOnDate -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOnDate -vm $Args[0]).LastPoweredOnDate} | Out-Null - -New-VIProperty -Name PercentFree -ObjectType Datastore -Value { - param($ds) - [math]::Round(((100 * ($ds.FreeSpaceMB)) / ($ds.CapacityMB)),2) -} -Force | Out-Null - -New-VIProperty -Name "HWVersion" -ObjectType VirtualMachine -Value { - param($vm) - - $vm.ExtensionData.Config.Version.Substring(4) -} -BasedOnExtensionProperty "Config.Version" -Force | Out-Null - -Write-CustomOut $pLang.collectVM -$VM = Get-VM | Sort Name -Write-CustomOut $pLang.collectHost -$VMH = Get-VMHost | Sort Name -Write-CustomOut $pLang.collectCluster -$Clusters = Get-Cluster | Sort Name -Write-CustomOut $pLang.collectDatastore -$Datastores = Get-Datastore | Sort Name -Write-CustomOut $pLang.collectDVM -$FullVM = Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} -Write-CustomOut $pLang.collectTemplate -$VMTmpl = Get-Template -Write-CustomOut $pLang.collectDVIO -$ServiceInstance = get-view ServiceInstance -Write-CustomOut $pLang.collectAlarm -$alarmMgr = get-view $ServiceInstance.Content.alarmManager -Write-CustomOut $pLang.collectDHost -$HostsViews = Get-View -ViewType hostsystem -Write-CustomOut $pLang.collectDCluster -$clusviews = Get-View -ViewType ClusterComputeResource -Write-CustomOut $pLang.collectDDatastore -$storageviews = Get-View -ViewType Datastore - -# Find out which version of the API we are connecting to -$VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars(0) - -# Check to see if its a VCSA or not -if ($ServiceInstance.Client.ServiceContent.About.OsType -eq "linux-x64"){ $VCSA = $true } - -# Check for vSphere -If ($VIVersion -ge 4){ - $vSphere = $true -} - -if ($VIVersion -ge 5) { - Write-CustomOut $pLang.collectDDatastoreCluster - $DatastoreClustersView = Get-View -viewtype StoragePod -} - -<# -.SYNOPSIS Returns vSphere events -.DESCRIPTION The function will return vSphere events. With - the available parameters, the execution time can be - improved, compered to the original Get-VIEvent cmdlet. -.NOTES Author: Luc Dekens -.PARAMETER Entity - When specified the function returns events for the - specific vSphere entity. By default events for all - vSphere entities are returned. -.PARAMETER EventType - This parameter limits the returned events to those - specified on this parameter. -.PARAMETER Start - The start date of the events to retrieve -.PARAMETER Finish - The end date of the events to retrieve. -.PARAMETER Recurse - A switch indicating if the events for the children of - the Entity will also be returned -.PARAMETER User - The list of usernames for which events will be returned -.PARAMETER System - A switch that allows the selection of all system events. -.PARAMETER ScheduledTask - The name of a scheduled task for which the events - will be returned -.PARAMETER FullMessage - A switch indicating if the full message shall be compiled. - This switch can improve the execution speed if the full - message is not needed. -.PARAMETER UseUTC - A switch indicating if the event shoukld remain in UTC or - local time. -.EXAMPLE - PS> Get-VIEventPlus -Entity $vm -.EXAMPLE - PS> Get-VIEventPlus -Entity $cluster -Recurse:$true -#> -function Get-VIEventPlus { - - param( - [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, - [string[]]$EventType, - [DateTime]$Start, - [DateTime]$Finish = (Get-Date), - [switch]$Recurse, - [string[]]$User, - [Switch]$System, - [string]$ScheduledTask, - [switch]$FullMessage = $false, - [switch]$UseUTC = $false - ) - - process { - $eventnumber = 100 - $events = @() - $eventMgr = Get-View EventManager - $eventFilter = New-Object VMware.Vim.EventFilterSpec - $eventFilter.disableFullMessage = ! $FullMessage - $eventFilter.entity = New-Object VMware.Vim.EventFilterSpecByEntity - $eventFilter.entity.recursion = &{if($Recurse){"all"}else{"self"}} - $eventFilter.eventTypeId = $EventType - if($Start -or $Finish){ - $eventFilter.time = New-Object VMware.Vim.EventFilterSpecByTime - if($Start){ - $eventFilter.time.beginTime = $Start - } - if($Finish){ - $eventFilter.time.endTime = $Finish - } - } - if($User -or $System){ - $eventFilter.UserName = New-Object VMware.Vim.EventFilterSpecByUsername - if($User){ - $eventFilter.UserName.userList = $User - } - if($System){ - $eventFilter.UserName.systemUser = $System - } - } - if($ScheduledTask){ - $si = Get-View ServiceInstance - $schTskMgr = Get-View $si.Content.ScheduledTaskManager - $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | - where {$_.Info.Name -match $ScheduledTask} | - Select -First 1 | - Select -ExpandProperty MoRef - } - if(!$Entity){ - $Entity = @(Get-Folder -NoRecursion) - } - $entity | %{ - $eventFilter.entity.entity = $_.ExtensionData.MoRef - $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter)) - $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) - while($eventsBuffer){ - $events += $eventsBuffer - $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) - } - $eventCollector.DestroyCollector() - } - if (-not $UseUTC) - { - $events | % { $_.createdTime = $_.createdTime.ToLocalTime() } - } - - $events - } -} +$Title = "Connection settings for vCenter" +$Author = "Alan Renouf" +$PluginVersion = 1.10 +$Header = "Connection Settings" +$Comments = "Connection Plugin for connecting to vSphere" +$Display = "None" +$PluginCategory = "vSphere" + +# Start of Settings +# Please Specify the address (and optional port) of the vCenter server to connect to [servername(:port)] +$Server = "MHCLAVC01" +# End of Settings + +# Update settings where there is an override +$Server = Get-vCheckSetting $Title "Server" $Server + +# Setup plugin-specific language table +$pLang = DATA { + ConvertFrom-StringData @' + connReuse = Re-using connection to VI Server + connOpen = Connecting to VI Server + connError = Unable to connect to vCenter, please ensure you have altered the vCenter server address correctly. To specify a username and password edit the connection string in the file $GlobalVariables + custAttr = Adding Custom properties + collectVM = Collecting VM Objects + collectHost = Collecting VM Host Objects + collectCluster = Collecting Cluster Objects + collectDatastore = Collecting Datastore Objects + collectDVM = Collecting Detailed VM Objects + collectTemplate = Collecting Template Objects + collectDVIO = Collecting Detailed VI Objects + collectAlarm = Collecting Detailed Alarm Objects + collectDHost = Collecting Detailed VMHost Objects + collectDCluster = Collecting Detailed Cluster Objects + collectDDatastore = Collecting Detailed Datastore Objects + collectDDatastoreCluster = Collecting Detailed Datastore Cluster Objects + collectAlarms = Collecting Alarm Definitions +'@ +} +# Override the default (en) if it exists in lang directory +Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLang -ErrorAction SilentlyContinue + +# Find the VI Server and port from the global settings file +$VIServer = ($Server -Split ":")[0] +if (($server -split ":")[1]) { + $port = ($server -split ":")[1] +} +else +{ + $port = 443 +} + +# Path to credentials file which is automatically created if needed +$Credfile = $ScriptPath + "\Windowscreds.xml" + +# +# Adding PowerCLI core module/pssnapin +# +# Possibilities: +# 1) PSSnpain (-le 5.8R1) +# 2) Module + PSSnapin (-gt 5.8R1/-lt 6.5R1) +# 3) Module (-ge 6.5R1) + +$pcliCore = 'VMware.VimAutomation.Core' + +$pssnapinPresent = $false +$psmodulePresent = $false + +if(Get-Module -Name $pcliCore -ListAvailable){ + $psmodulePresent = $true + if(!(Get-Module -Name $pcliCore)){ + Import-Module -Name $pcliCore + } +} + +if(Get-PSSnapin -Name $pcliCore -Registered -ErrorAction SilentlyContinue){ + $pssnapinPresent = $true + if(!(Get-PSSnapin -Name $pcliCore -ErrorAction SilentlyContinue)){ + Add-PSSnapin -Name $pcliCore + } +} + +if(!$pssnapinPresent -and !$psmodulePresent){ + Write-Error "Can't find PowerCLI. Is it installed?" + return +} + +$OpenConnection = $global:DefaultVIServers | where { $_.Name -eq $VIServer } +if($OpenConnection.IsConnected) { + Write-CustomOut ( "{0}: {1}" -f $pLang.connReuse, $Server ) + $VIConnection = $OpenConnection +} else { + Write-CustomOut ( "{0}: {1}" -f $pLang.connOpen, $Server ) + $VIConnection = Connect-VIServer -Server $VIServer -Port $Port +} + +if (-not $VIConnection.IsConnected) { + Write-Error $pLang.connError +} + +Write-CustomOut $pLang.custAttr + +function Get-VMLastPoweredOffDate { + param([Parameter(Mandatory=$true,ValueFromPipeline=$true)] + [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm) + process { + $Report = "" | Select-Object -Property Name,LastPoweredOffDate + $Report.Name = $_.Name + $Report.LastPoweredOffDate = (Get-VIEventPlus -Entity $vm | ` + Where-Object { $_.Gettype().Name -eq "VmPoweredOffEvent" } | ` + Select-Object -First 1).CreatedTime + $Report + } +} + +function Get-VMLastPoweredOnDate { + param([Parameter(Mandatory=$true,ValueFromPipeline=$true)] + [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm) + + process { + $Report = "" | Select-Object -Property Name,LastPoweredOnDate + $Report.Name = $_.Name + $Report.LastPoweredOnDate = (Get-VIEventPlus -Entity $vm | ` + Where-Object { $_.Gettype().Name -match "VmPoweredOnEvent" } | ` + Select-Object -First 1).CreatedTime + $Report + } +} + +New-VIProperty -Name LastPoweredOffDate -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOffDate -vm $Args[0]).LastPoweredOffDate} | Out-Null +New-VIProperty -Name LastPoweredOnDate -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOnDate -vm $Args[0]).LastPoweredOnDate} | Out-Null + +New-VIProperty -Name PercentFree -ObjectType Datastore -Value { + param($ds) + [math]::Round(((100 * ($ds.FreeSpaceMB)) / ($ds.CapacityMB)),2) +} -Force | Out-Null + +New-VIProperty -Name "HWVersion" -ObjectType VirtualMachine -Value { + param($vm) + + $vm.ExtensionData.Config.Version.Substring(4) +} -BasedOnExtensionProperty "Config.Version" -Force | Out-Null + +Write-CustomOut $pLang.collectVM +$VM = Get-VM | Sort Name +Write-CustomOut $pLang.collectHost +$VMH = Get-VMHost | Sort Name +Write-CustomOut $pLang.collectCluster +$Clusters = Get-Cluster | Sort Name +Write-CustomOut $pLang.collectDatastore +$Datastores = Get-Datastore | Sort Name +Write-CustomOut $pLang.collectDVM +$FullVM = Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} +Write-CustomOut $pLang.collectTemplate +$VMTmpl = Get-Template +Write-CustomOut $pLang.collectDVIO +$ServiceInstance = get-view ServiceInstance +Write-CustomOut $pLang.collectAlarm +$alarmMgr = get-view $ServiceInstance.Content.alarmManager +Write-CustomOut $pLang.collectDHost +$HostsViews = Get-View -ViewType hostsystem +Write-CustomOut $pLang.collectDCluster +$clusviews = Get-View -ViewType ClusterComputeResource +Write-CustomOut $pLang.collectDDatastore +$storageviews = Get-View -ViewType Datastore +Write-CustomOut $pLang.collectAlarms +$valarms = $alarmMgr.GetAlarm($null) | select value, @{N="name";E={(Get-View -Id $_).Info.Name}} + +# Find out which version of the API we are connecting to +$VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars(0) + +# Check to see if its a VCSA or not +if ($ServiceInstance.Client.ServiceContent.About.OsType -eq "linux-x64"){ $VCSA = $true } + +# Check for vSphere +If ($VIVersion -ge 4){ + $vSphere = $true +} + +if ($VIVersion -ge 5) { + Write-CustomOut $pLang.collectDDatastoreCluster + $DatastoreClustersView = Get-View -viewtype StoragePod +} + +<# +.SYNOPSIS Returns vSphere events +.DESCRIPTION The function will return vSphere events. With + the available parameters, the execution time can be + improved, compered to the original Get-VIEvent cmdlet. +.NOTES Author: Luc Dekens +.PARAMETER Entity + When specified the function returns events for the + specific vSphere entity. By default events for all + vSphere entities are returned. +.PARAMETER EventType + This parameter limits the returned events to those + specified on this parameter. +.PARAMETER Start + The start date of the events to retrieve +.PARAMETER Finish + The end date of the events to retrieve. +.PARAMETER Recurse + A switch indicating if the events for the children of + the Entity will also be returned +.PARAMETER User + The list of usernames for which events will be returned +.PARAMETER System + A switch that allows the selection of all system events. +.PARAMETER ScheduledTask + The name of a scheduled task for which the events + will be returned +.PARAMETER FullMessage + A switch indicating if the full message shall be compiled. + This switch can improve the execution speed if the full + message is not needed. +.PARAMETER UseUTC + A switch indicating if the event shoukld remain in UTC or + local time. +.EXAMPLE + PS> Get-VIEventPlus -Entity $vm +.EXAMPLE + PS> Get-VIEventPlus -Entity $cluster -Recurse:$true +#> +function Get-VIEventPlus { + + param( + [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, + [string[]]$EventType, + [DateTime]$Start, + [DateTime]$Finish = (Get-Date), + [switch]$Recurse, + [string[]]$User, + [Switch]$System, + [string]$ScheduledTask, + [switch]$FullMessage = $false, + [switch]$UseUTC = $false + ) + + process { + $eventnumber = 100 + $events = @() + $eventMgr = Get-View EventManager + $eventFilter = New-Object VMware.Vim.EventFilterSpec + $eventFilter.disableFullMessage = ! $FullMessage + $eventFilter.entity = New-Object VMware.Vim.EventFilterSpecByEntity + $eventFilter.entity.recursion = &{if($Recurse){"all"}else{"self"}} + $eventFilter.eventTypeId = $EventType + if($Start -or $Finish){ + $eventFilter.time = New-Object VMware.Vim.EventFilterSpecByTime + if($Start){ + $eventFilter.time.beginTime = $Start + } + if($Finish){ + $eventFilter.time.endTime = $Finish + } + } + if($User -or $System){ + $eventFilter.UserName = New-Object VMware.Vim.EventFilterSpecByUsername + if($User){ + $eventFilter.UserName.userList = $User + } + if($System){ + $eventFilter.UserName.systemUser = $System + } + } + if($ScheduledTask){ + $si = Get-View ServiceInstance + $schTskMgr = Get-View $si.Content.ScheduledTaskManager + $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | + where {$_.Info.Name -match $ScheduledTask} | + Select -First 1 | + Select -ExpandProperty MoRef + } + if(!$Entity){ + $Entity = @(Get-Folder -NoRecursion) + } + $entity | %{ + $eventFilter.entity.entity = $_.ExtensionData.MoRef + $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter)) + $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) + while($eventsBuffer){ + $events += $eventsBuffer + $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) + } + $eventCollector.DestroyCollector() + } + if (-not $UseUTC) + { + $events | % { $_.createdTime = $_.createdTime.ToLocalTime() } + } + + $events + } +} \ No newline at end of file diff --git a/Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 b/Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 new file mode 100644 index 00000000..6ddd141f --- /dev/null +++ b/Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 @@ -0,0 +1,44 @@ +$Title = "Windows vCenter Error Event Logs" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + +# Start of Settings +# 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 +# End of Settings + +# Update settings where there is an override +$VCEventAge = Get-vCheckSetting $Title "VCEventAge" $VCEventAge +$VCEvntlgAge = Get-vCheckSetting $Title "VCEvntlgAge" $VCEvntlgAge + +if (! $VCSA){ + $ConvDate = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-$VCEvntlgAge)) + If (Test-Path $Credfile) { + $LoadedCredentials = Import-Clixml $Credfile + $creds = New-Object System.Management.Automation.PsCredential($LoadedCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString)) + $WMI = @(Get-WmiObject -cred $creds -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + } Else { + $WMI = @(Get-WmiObject -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + if ($Error[0].Exception.Message -match "Access is denied.") { + # Access Denied Error found so asking to store windows credentials in a file for future use + Write-Host "Current windows credentials do not allow for access to WMI on the host $VIServer, please enter Administrator credentials for this check to work, these will be stored in an encrypted file: $credfile" + $Credential = Get-Credential + $Pass = $credential.Password | ConvertFrom-SecureString + $Username = $Credential.UserName + $Store = "" | Select Username, Password + $Store.Username = $Username + $Store.Password = $Pass + $Store | Export-Clixml $credfile + $WMI = @(Get-WmiObject -cred $Credential -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + } + } + + $WMI +} + +$Header = "Event Logs - Errors: [count]" +$Comments = ("The following errors were found in the vCenter Event Logs in the past {0} days, you may wish to check these further" -f $VCEvntlgAge) \ No newline at end of file diff --git a/Plugins/20 Cluster/10 HA Configuration Issues.ps1 b/Plugins/20 Cluster/10 HA Configuration Issues.ps1 index 392e6d66..4481059a 100644 --- a/Plugins/20 Cluster/10 HA Configuration Issues.ps1 +++ b/Plugins/20 Cluster/10 HA Configuration Issues.ps1 @@ -47,8 +47,7 @@ $HAIssues += $clusviews | where {$_.Name -notmatch $ClustersDoNotInclude -and ( # Clusters with admission Control Disabled $HAIssues += $Clusters | Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and $_.HAAdmissionControlEnabled -ne $ClusterHAAdmissionControlShouldBeEnabled } | Select-Object @{Name="Cluster";Expression={$_.Name}},@{Name="Configuration Issue";Expression={$pLang.HAACDisabled}} - - + # Sort and return $HAIssues | Sort-Object Cluster diff --git a/Plugins/20 Cluster/15 HA VMs restarted.ps1 b/Plugins/20 Cluster/15 HA VMs restarted.ps1 index 081fe32a..bc0b1651 100644 --- a/Plugins/20 Cluster/15 HA VMs restarted.ps1 +++ b/Plugins/20 Cluster/15 HA VMs restarted.ps1 @@ -1,5 +1,4 @@ $Title = "HA VMs restarted" -$Comments = "The following VMs have been restarted by HA in the last $HAVMresetold days" $Display = "Table" $Author = "Alan Renouf" $PluginVersion = 1.3 @@ -13,6 +12,7 @@ $HAVMrestartold = 5 # Update settings where there is an override $HAVMrestartold = Get-vCheckSetting $Title "HAVMrestartold" $HAVMrestartold -@(Get-VIEventPlus -EventType "com.vmware.vc.ha.VmRestartedByHAEvent" -Start ($Date).AddDays(-$HAVMrestartold) | Select-Object CreatedTime, FullFormattedMessage | Sort-Object CreatedTime -Descending) +Get-VIEventPlus -EventType "com.vmware.vc.ha.VmRestartedByHAEvent" -Start ($Date).AddDays(-$HAVMrestartold) | Select-Object CreatedTime, FullFormattedMessage | Sort-Object CreatedTime -Descending -$Header = ("HA: VM restart (Last {0} Day(s)) : [count]" -f $HAVMrestartold) \ No newline at end of file +$Header = ("HA: VM restart (Last {0} Day(s)) : [count]" -f $HAVMrestartold) +$Comments = ("The following VMs have been restarted by HA in the last {0} days" -f $HAVMresetold) \ No newline at end of file diff --git a/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 b/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 index 423977aa..cfc01816 100644 --- a/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 +++ b/Plugins/20 Cluster/18 Cluster Slot Sizes.ps1 @@ -7,7 +7,7 @@ $PluginVersion = 1.2 $PluginCategory = "vSphere" # Start of Settings -# Number of slots available in a cluster +# Minimum number of slots available in a cluster $numslots = 10 # End of Settings @@ -15,22 +15,19 @@ $numslots = 10 $numslots = Get-vCheckSetting $Title "numslots" $numslots If ($vSphere){ - $SlotInfo = @() Foreach ($Cluster in ($Clusters)){ If ($Cluster.ExtensionData.Configuration.DasConfig.Enabled -eq $true -and $Cluster.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.getType() -eq [VMware.Vim.ClusterFailoverLevelAdmissionControlPolicy]){ $SlotDetails = $Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() - $Details = [PSCustomObject] @{ - Cluster = $Cluster.Name - TotalSlots = $SlotDetails.TotalSlots - UsedSlots = $SlotDetails.UsedSlots - AvailableSlots = $SlotDetails.UnreservedSlots + if ($SlotDetails.UnreservedSlots -lt $numslots) { + [PSCustomObject] @{ + Cluster = $Cluster.Name + TotalSlots = $SlotDetails.TotalSlots + UsedSlots = $SlotDetails.UsedSlots + AvailableSlots = $SlotDetails.UnreservedSlots + } } - $SlotInfo += $Details } } - $SlotCHK = @($SlotInfo | Where { $_.AvailableSlots -lt $numslots}) -} - -$SlotCHK \ No newline at end of file +} \ No newline at end of file diff --git a/Plugins/20 Cluster/72 s-vMotion Information.ps1 b/Plugins/20 Cluster/72 s-vMotion Information.ps1 index 2b581b47..f1d70e15 100644 --- a/Plugins/20 Cluster/72 s-vMotion Information.ps1 +++ b/Plugins/20 Cluster/72 s-vMotion Information.ps1 @@ -1,5 +1,4 @@ $Title = "s/vMotion Information" -$Header = "s/vMotion Information (Over $vMotionAge Days Old) : $(@($Motions).count)" $Comments = "s/vMotions and how long they took to migrate between hosts and datastores" $Display = "Table" $Author = "Alan Renouf" @@ -59,4 +58,6 @@ if (-not $IncludevMotions) { $Motions = $Motions | Where { $_.Type -ne "vMotion" if (-not $IncludeSvMotions) { $Motions = $Motions | Where { $_.Type -ne "SvMotion" }} $Motions +$Header = ("s/vMotion Information (Over {0} Days Old): [count]" -f $vMotionAge) + Remove-Variable Motions, EventFilterSpec, vmotions \ No newline at end of file diff --git a/Plugins/30 Host/31 NTP Name and Service.ps1 b/Plugins/30 Host/31 NTP Name and Service.ps1 index be2233a4..b5e2aeb3 100644 --- a/Plugins/30 Host/31 NTP Name and Service.ps1 +++ b/Plugins/30 Host/31 NTP Name and Service.ps1 @@ -11,4 +11,4 @@ $PluginCategory = "vSphere" $ntpserver = "pool.ntp.org,pool2.ntp.org" # End of Settings -@($VMH | Where {$_.Connectionstate -ne "Disconnected"} | Select Name, @{N="NTPServer";E={($_ | Get-VMHostNtpServer) -join ","}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver}) \ No newline at end of file +$VMH | Where {$_.Connectionstate -ne "Disconnected"} | Select Name, @{N="NTPServer";E={($_ | Get-VMHostNtpServer) -join ","}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver} \ No newline at end of file diff --git a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 index 5d72c362..a89402e4 100644 --- a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 +++ b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 @@ -19,20 +19,20 @@ foreach ($HostsView in ($HostsViews|?{$_.runtime.connectionstate -eq "Connected" if ($HWStatusDetails) { foreach ($HWStatusDetail in $HWStatusDetails) { New-Object PSObject -Property @{ - $Details.Cluster = $HostsView | %{(Get-View $_.Parent).Name} - $Details.Host = $HostsView.name - $Details.Sensor = $HWStatusDetail.sensor - $Details.Status = $HWStatusDetail.status + Cluster = ($HostsView | %{(Get-View $_.Parent).Name}) + Host = $HostsView.name + Sensor = $HWStatusDetail.sensor + Status = $HWStatusDetail.status } } } if ($HealthStatusDetails) { foreach ($HealthStatusDetail in $HealthStatusDetails) { New-Object PSObject -Property @{ - $Details.Cluster = $HostsView | %{(Get-View $_.Parent).Name} - $Details.Host = $HostsView.name - $Details.Sensor = $HealthStatusDetail.sensor - $Details.Status = $HealthStatusDetail.status + Cluster = ($HostsView | %{(Get-View $_.Parent).Name}) + Host = $HostsView.name + Sensor = $HealthStatusDetail.sensor + Status = $HealthStatusDetail.status } } } diff --git a/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 b/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 index 9b91fb9d..3e91b9a8 100644 --- a/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 +++ b/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 @@ -12,15 +12,16 @@ $NumVMsPerDatastore = 5 $ExcludedDatastores = "ExcludeMe" # End of Settings -# Changelog -## 1.1 : Using managed objects collections in order to avoid using Get-VM cmdlet for performance matter -## 1.2 : ??? -## 1.3 : Add Get-vCheckSetting - # Update settings where there is an override $NumVMsPerDatastore = Get-vCheckSetting $Title "NumVMsPerDatastore" $NumVMsPerDatastore $ExcludedDatastores = Get-vCheckSetting $Title "ExcludedDatastores" $ExcludedDatastores $StorageViews | Where-Object { $_.Name -notmatch $ExcludedDatastores } | Select Name, @{N="NumVM";E={($_.vm).Count}} | Where { $_.NumVM -gt $NumVMsPerDatastore} | Sort NumVM -Descending -$Header = "Number of VMs per Datastore over $($NumVMsPerDatastore) : [count]" \ No newline at end of file +$Header = "Number of VMs per Datastore over $($NumVMsPerDatastore) : [count]" + + +# Changelog +## 1.1 : Using managed objects collections in order to avoid using Get-VM cmdlet for performance matter +## 1.2 : ??? +## 1.3 : Add Get-vCheckSetting diff --git a/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 b/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 index 9bfb0b36..317975c0 100644 --- a/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 +++ b/Plugins/40 Datastore/39 Datastore OverAllocation.ps1 @@ -24,7 +24,7 @@ foreach ($storage in $filteredstorageviews) { $allocation = [math]::round(((($storage.Summary.Capacity - $storage.Summary.FreeSpace) + $storage.Summary.Uncommitted)*100)/$storage.Summary.Capacity,0) - if (($allocation-100) -gt $OverAllocation { + if (($allocation-100) -gt $OverAllocation) { New-Object -TypeName PSObject -Property @{ "Datastore" = $storage.name "OverAllocation" = $overAllocation } diff --git a/Plugins/50 Network/98 vSwitch Security.ps1 b/Plugins/50 Network/98 vSwitch Security.ps1 index 0f1a1478..5bd6290e 100644 --- a/Plugins/50 Network/98 vSwitch Security.ps1 +++ b/Plugins/50 Network/98 vSwitch Security.ps1 @@ -17,12 +17,6 @@ $ForgedTransmitsPolicy = $true $MacChangesPolicy = $true # End of Settings -# Changelog -## 1.0 : Initial Release -## 1.1 : Re-written for performance improvements -## 1.2 : Added version check (Issue #71) -## 1.3 add Get-vCheckSetting - # Update settings where there is an override $vSwitchSecurityCheck = Get-vCheckSetting $Title "vSwitchSecurityCheck" $vSwitchSecurityCheck $AllowPromiscuousPolicy = Get-vCheckSetting $Title "AllowPromiscuousPolicy" $AllowPromiscuousPolicy @@ -101,4 +95,10 @@ if ($VersionOK) { else { Write-Warning "PowerCLi version installed is lower than 5.1 Release 2" New-Object PSObject -Property @{"Message"="PowerCLi version installed is lower than 5.1 Release 2, please update to use this plugin"} -} \ No newline at end of file +} + +# Changelog +## 1.0 : Initial Release +## 1.1 : Re-written for performance improvements +## 1.2 : Added version check (Issue #71) +## 1.3 add Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/02 Snapshot Information.ps1 b/Plugins/60 VM/02 Snapshot Information.ps1 index 4515d4f6..a0b23eff 100644 --- a/Plugins/60 VM/02 Snapshot Information.ps1 +++ b/Plugins/60 VM/02 Snapshot Information.ps1 @@ -9,9 +9,7 @@ $excludeDesc = "ExcludeMe" $excludeCreator = "ExcludeMe" # End of Settings -# Changelog -## 1.3 : Cleanup - Fixed Creator - Changed Size to GB -## 1.4 : Decode URL-encoded snapshot name (i.e. the %xx caharacters) + Add-Type -AssemblyName System.Web @@ -60,62 +58,65 @@ function Get-SnapshotTree{ } function Get-SnapshotExtra ($snap){ - $guestName = $snap.VM # The name of the guest - $tasknumber = 999 # Window size of the Task collector - $taskMgr = Get-View TaskManager - - # Create hash table. Each entry is a create snapshot task - $report = @{} - - $filter = New-Object VMware.Vim.TaskFilterSpec - $filter.Time = New-Object VMware.Vim.TaskFilterSpecByTime - $filter.Time.beginTime = (($snap.Created).AddDays(-$SnapshotAge)) - $filter.Time.timeType = "startedTime" - # Added filter to only view for the selected VM entity. Massive speed up. - # Entity name check could be removed in line 91. - $filter.Entity = New-Object VMware.Vim.TaskFilterSpecByEntity - $filter.Entity.Entity = $snap.VM.ExtensionData.MoRef - - $collectionImpl = Get-View ($taskMgr.CreateCollectorForTasks($filter)) - - $dummy = $collectionImpl.RewindCollector - $collection = $collectionImpl.ReadNextTasks($tasknumber) - while($collection -ne $null){ - $collection | where {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $guestName} | %{ - $row = New-Object PsObject - $row | Add-Member -MemberType NoteProperty -Name User -Value $_.Reason.UserName - $vm = Get-View $_.Entity - if($vm -ne $null){ - $snapshot = Get-SnapshotTree $vm.Snapshot.RootSnapshotList $_.Result - if($snapshot -ne $null){ - $key = $_.EntityName + "&" + ($snapshot.CreateTime.ToString()) - $report[$key] = $row - } - } - } - $collection = $collectionImpl.ReadNextTasks($tasknumber) - } - $collectionImpl.DestroyCollector() - - # Get the guest's snapshots and add the user - $snapshotsExtra = $snap | % { - $key = $_.vm.Name + "&" + ($_.Created.ToUniversalTime().ToString()) - $str = $report | Out-String - if($report.ContainsKey($key)){ - $_ | Add-Member -MemberType NoteProperty -Name Creator -Value $report[$key].User - } - $_ - } - $snapshotsExtra + $guestName = $snap.VM # The name of the guest + $tasknumber = 999 # Window size of the Task collector + $taskMgr = Get-View TaskManager + + # Create hash table. Each entry is a create snapshot task + $report = @{} + + $filter = New-Object VMware.Vim.TaskFilterSpec + $filter.Time = New-Object VMware.Vim.TaskFilterSpecByTime + $filter.Time.beginTime = (($snap.Created).AddDays(-$SnapshotAge)) + $filter.Time.timeType = "startedTime" + # Added filter to only view for the selected VM entity. Massive speed up. + # Entity name check could be removed in line 91. + $filter.Entity = New-Object VMware.Vim.TaskFilterSpecByEntity + $filter.Entity.Entity = $snap.VM.ExtensionData.MoRef + + $collectionImpl = Get-View ($taskMgr.CreateCollectorForTasks($filter)) + + $dummy = $collectionImpl.RewindCollector + $collection = $collectionImpl.ReadNextTasks($tasknumber) + while($collection -ne $null){ + $collection | where {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $guestName} | %{ + $row = New-Object PsObject + $row | Add-Member -MemberType NoteProperty -Name User -Value $_.Reason.UserName + $vm = Get-View $_.Entity + if($vm -ne $null){ + $snapshot = Get-SnapshotTree $vm.Snapshot.RootSnapshotList $_.Result + if($snapshot -ne $null){ + $key = $_.EntityName + "&" + ($snapshot.CreateTime.ToString()) + $report[$key] = $row + } + } + } + $collection = $collectionImpl.ReadNextTasks($tasknumber) + } + $collectionImpl.DestroyCollector() + + # Get the guest's snapshots and add the user + $snapshotsExtra = $snap | % { + $key = $_.vm.Name + "&" + ($_.Created.ToUniversalTime().ToString()) + $str = $report | Out-String + if($report.ContainsKey($key)){ + $_ | Add-Member -MemberType NoteProperty -Name Creator -Value $report[$key].User + } + $_ + } + $snapshotsExtra } -$Snapshots = @($VM | Get-Snapshot | Where {$_.Created -lt (($Date).AddDays(-$SnapshotAge))} | Get-SnapshotSummary | Where {$_.SnapName -notmatch $excludeName -and $_.Description -notmatch $excludeDesc -and $_.Creator -notmatch $excludeCreator}) -$Snapshots +$VM | Get-Snapshot | Where {$_.Created -lt (($Date).AddDays(-$SnapshotAge))} | Get-SnapshotSummary | Where {$_.SnapName -notmatch $excludeName -and $_.Description -notmatch $excludeDesc -and $_.Creator -notmatch $excludeCreator} $Title = "Snapshot Information" -$Header = "Snapshots (Over $SnapshotAge Days Old) : $(@($snapshots).count)" +$Header = "Snapshots (Over $SnapshotAge Days Old): [count]" $Comments = "VMware snapshots which are kept for a long period of time may cause issues, filling up datastores and also may impact performance of the virtual machine." $Display = "Table" $Author = "Alan Renouf, Raphael Schitz" $PluginVersion = 1.5 $PluginCategory = "vSphere" + +# Changelog +## 1.3 : Cleanup - Fixed Creator - Changed Size to GB +## 1.4 : Decode URL-encoded snapshot name (i.e. the %xx caharacters) diff --git a/Plugins/60 VM/04 Map disk region event.ps1 b/Plugins/60 VM/04 Map disk region event.ps1 index 30e21e27..5974b3f9 100644 --- a/Plugins/60 VM/04 Map disk region event.ps1 +++ b/Plugins/60 VM/04 Map disk region event.ps1 @@ -1,13 +1,21 @@ -# Start of Settings -# End of Settings - -$MapDiskRegionEvents = @($VIEvent | Where {$_.FullFormattedMessage -match "Map disk region"} | Foreach {$_.vm}|select name |Sort-Object -unique) -$MapDiskRegionEvents - $Title = "Map disk region event" -$Header = "Map disk region event (Last $VMsNewRemovedAge Day(s)) : $(@($MapDiskRegionEvents).count)" $Comments = "These may occur due to VCB issues, check this article for more details" $Display = "Table" $Author = "Alan Renouf" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# Set the number of days to show Map disk region event for +$eventAge = 5 +# End of Settings + +# Update settings where there is an override +$eventAge = Get-vCheckSetting $Title "eventAge" $eventAge + +Get-VIEventPlus -Start ($Date).AddDays(-$eventAge) -Type Info | Where {$_.FullFormattedMessage -match "Map disk region"} | Foreach {$_.vm}|select name |Sort-Object -unique + +$Header = ("Map disk region event (Last {0} Day(s)): [count]" -f $eventAge) + +# Change Log +## 1.2 : Added Get-vCheckSetting and Get-VIEventPlus \ No newline at end of file diff --git a/Plugins/60 VM/09 Created or cloned VMs.ps1 b/Plugins/60 VM/09 Created or cloned VMs.ps1 index 28231b0d..ca8701f4 100644 --- a/Plugins/60 VM/09 Created or cloned VMs.ps1 +++ b/Plugins/60 VM/09 Created or cloned VMs.ps1 @@ -1,14 +1,21 @@ +$Title = "Created or cloned VMs" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days to show VMs created for $VMsNewRemovedAge = 5 # End of Settings -@(Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent") | Select createdTime, UserName, fullFormattedMessage) +# Update settings where there is an override +$VMsNewRemovedAge = Get-vCheckSetting $Title "VMsNewRemovedAge" $VMsNewRemovedAge + +Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent") | Select createdTime, UserName, fullFormattedMessage -$Title = "Created or cloned VMs" $Header = ("VMs Created or Cloned (Last {0} Day(s)): [count])" -f $VMsNewRemovedAge) $Comments = ("The following VMs have been created over the last {0} Days" -f $VMsNewRemovedAge) -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" + +# Change Log +## 1.3 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/10 Removed VMs.ps1 b/Plugins/60 VM/10 Removed VMs.ps1 index e076d378..d44c30f4 100644 --- a/Plugins/60 VM/10 Removed VMs.ps1 +++ b/Plugins/60 VM/10 Removed VMs.ps1 @@ -1,14 +1,21 @@ +$Title = "Removed VMs" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days to show VMs removed for $VMsNewRemovedAge = 5 # End of Settings -@(Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType "VmRemovedEvent" | Select @{Name="VMName";Expression={$_.vm.name}}, CreatedTime, UserName, fullFormattedMessage) +# Update settings where there is an override +$VMsNewRemovedAge = Get-vCheckSetting $Title "VMsNewRemovedAge" $VMsNewRemovedAge -$Title = "Removed VMs" -$Header = "VMs Removed (Last $VMsNewRemovedAge Day(s)) : [count]" -$Comments = "The following VMs have been removed/deleted over the last $($VMsNewRemovedAge) days" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" +Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType "VmRemovedEvent" | Select @{Name="VMName";Expression={$_.vm.name}}, CreatedTime, UserName, fullFormattedMessage + +$Header = ("VMs Removed (Last {0} Day(s)): [count]" -f $VMsNewRemovedAge) +$Comments = "The following VMs have been removed/deleted over the last {0} days" -f $VMsNewRemovedAge + +# Change Log +## 1.4 Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 b/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 index de489a45..33daeeec 100644 --- a/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 +++ b/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 @@ -1,13 +1,21 @@ -# Start of Settings -# VMs with CPU or Memory Reservations, do not report on any VMs who are defined here -$MCRDoNotInclude = "VM1_*|VM2_*" -# End of Settings -@($FullVM | Where {$_.Name -notmatch $MCRDoNotInclude} | Where {$_.config.cpuallocation.Reservation -ne "0" -or $_.config.memoryallocation.Reservation -ne "0"} | Select Name, @{Name="CPUReservationMhz";E={$_.config.cpuallocation.Reservation}}, @{Name="MemReservationMB";E={$_.config.memoryallocation.Reservation}}) - $Title = "VMs with CPU or Memory Reservations Configured" -$Header = "VMs with CPU or Memory Reservations Configured" +$Header = "VMs with CPU or Memory Reservations Configured: [count]" $Comments = "The following VMs have a CPU or Memory Reservation configured which may impact the performance of the VM. Note: -1 indicates no reservation" $Display = "Table" $Author = "Dan Jellesma" -$PluginVersion = 1.0 +$PluginVersion = 1.1 $PluginCategory = "vSphere" + +# Start of Settings +# Do not report on any VMs who are defined here +$MCRDoNotInclude = "" +# End of Settings + +# Update settings where there is an override +$MCRDoNotInclude = Get-vCheckSetting $Title "MCRDoNotInclude" $MCRDoNotInclude + +$FullVM | Where {$_.Name -notmatch $MCRDoNotInclude -and ($_.config.cpuallocation.Reservation -ne "0" -or $_.config.memoryallocation.Reservation -ne "0")} | Select Name, @{Name="CPUReservationMhz";E={$_.config.cpuallocation.Reservation}}, @{Name="MemReservationMB";E={$_.config.memoryallocation.Reservation}} + +# Change Log +## 1.0 : Initial Release +## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/102 VM Logging.ps1 b/Plugins/60 VM/102 VM Logging.ps1 index 96dc2548..3defe322 100644 --- a/Plugins/60 VM/102 VM Logging.ps1 +++ b/Plugins/60 VM/102 VM Logging.ps1 @@ -1,3 +1,10 @@ +$Title = "VM Logging" +$Header = "VMs with improper logging settings: [count]" +$Display = "Table" +$Author = "Bob Cote" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # The number of logs to keep for each VM $KeepOld = 10 @@ -5,23 +12,25 @@ $KeepOld = 10 $RotateSize = 1000000 # End of Settings -$logInfo = @() -Foreach($Machine in $VM) { - $Details = "" | Select Name, KeepOld, RotateSize - $Details.Name = $Machine.Name - $Details.KeepOld = $Machine.ExtensionData.Config.ExtraConfig | Where {$_.Key -eq "log.keepold"} | Select -ExpandProperty Value - $Details.RotateSize = $Machine.ExtensionData.Config.ExtraConfig | Where {$_.Key -eq "log.rotatesize"} | Select -ExpandProperty Value - If ($Details.KeepOld -Or $Details.RotateSize) { - $logInfo += $Details - } +# Update settings where there is an override +$KeepOld = Get-vCheckSetting $Title "KeepOld" $KeepOld +$RotateSize = Get-vCheckSetting $Title "RotateSize" $RotateSize + +$VM | Foreach { + $VMKeepOld = $_.ExtensionData.Config.ExtraConfig | Where {$_.Key -eq "log.keepold"} | Select -ExpandProperty Value + $VMRotateSize = $_.ExtensionData.Config.ExtraConfig | Where {$_.Key -eq "log.rotatesize"} | Select -ExpandProperty Value + + If ($VMKeepOld -ne $KeepOld -Or $VMRotateSize -ne $RotateSize) { + New-Object -TypeName PSObject -Property @{ + Name = $_.Name + KeepOld = $VMKeepOld + RotateSize = $VMRotateSize + } + } } -$Result = @($logInfo | Where {$_.KeepOld -ne $KeepOld -or $_.RotateSize -ne $RotateSize} | Sort Name) -$Result -$Title = "VM Logging" -$Header = "VMs with improper logging settings: $(@($Result).Count)" -$Comments = "The following virtual machines are not configured to rotate logs at $RotateSize bytes and/or to store $KeepOld logs." -$Display = "Table" -$Author = "Bob Cote" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +$Comments = ("The following virtual machines are not configured to rotate logs at $RotateSize bytes and/or to store {0} logs." -f $KeepOld) + +# Change Log +## 1.0 : Initial Release +## 1.1 : Added Get-vCheckSetting, code refactor \ No newline at end of file diff --git a/Plugins/60 VM/106 Find Phantom Snapshots.ps1 b/Plugins/60 VM/106 Find Phantom Snapshots.ps1 index fc377887..07a4b0e6 100644 --- a/Plugins/60 VM/106 Find Phantom Snapshots.ps1 +++ b/Plugins/60 VM/106 Find Phantom Snapshots.ps1 @@ -1,41 +1,28 @@ +$Title = "Find Phantom Snapshots" +$Header = "VM's with Phantom Snapshots: [count]" +$Comments = "The following VM's have Phantom Snapshots" +$Display = "Table" +$Author = "Mads Fog Albrechtslund" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings $OutputPhantomSnapshots = @() ForEach ($theVM in $VM){ - # Inventory of VM HardDisks - $theVMdisks = $theVM | Get-HardDisk - - - ForEach ($theVMdisk in $theVMdisks){ - - - # Find VM's where active VMDK is a Delta VMDK - if ($theVMdisk.Filename -match "-\d{6}.vmdk"){ - - # Find VM's which don't have normal Snapshots registered - if (!(Get-Snapshot $theVM)) -{ - $Details = New-object PSObject - - $Details | Add-Member -Name "VM Name" -Value $theVM.name -Membertype NoteProperty - - $Details | Add-Member -Name "VMDK Path" -Value $theVMdisk.Filename -Membertype NoteProperty - - $OutputPhantomSnapshots += $Details - - } - } - } + ForEach ($theVMdisk in ($theVM | Get-HardDisk | Where {$_.Filename -match "-\d{6}.vmdk"})){ + # Find VM's which don't have normal Snapshots registered + if (!(Get-Snapshot $theVM)) + { + New-Object -TypeName PSObject -Property @{ + "VM Name" = $theVM.name + "VMDK Path" = $theVMdisk.Filename + } + } + } } -$OutputPhantomSnapshots - -$Title = "Find Phantom Snapshots" -$Header = "VM's with Phantom Snapshots : $(@($OutputPhantomSnapshots).count)" -$Comments = "The following VM's have Phantom Snapshots" -$Display = "Table" -$Author = "Mads Fog Albrechtslund" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +# Change Log +## 1.2 : Code refactor \ No newline at end of file diff --git a/Plugins/60 VM/11 VMs with over CPU Count.ps1 b/Plugins/60 VM/11 VMs with over CPU Count.ps1 index 46161728..ece26d45 100644 --- a/Plugins/60 VM/11 VMs with over CPU Count.ps1 +++ b/Plugins/60 VM/11 VMs with over CPU Count.ps1 @@ -1,15 +1,21 @@ +$Title = "VMs with over CPU Count" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Define the maximum amount of vCPUs your VMs are allowed $vCPU = 2 # End of Settings -$OverCPU = @($VM | Where {$_.NumCPU -gt $vCPU} | Select Name, PowerState, NumCPU) -$OverCPU +# Update settings where there is an override +$vCPU = Get-vCheckSetting $Title "vCPU" $vCPU -$Title = "VMs with over $vCPU vCPUs" -$Header = "VMs with over $vCPU vCPUs: $(@($OverCPU).count)" -$Comments = "The following VMs have over $vCPU CPU(s) and may impact performance due to CPU scheduling" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$VM | Where {$_.NumCPU -gt $vCPU} | Select Name, PowerState, NumCPU + +$Header = ("VMs with over {0} vCPUs: [count]" -f $vCPU) +$Comments = ("The following VMs have over {0} CPU(s) and may impact performance due to CPU scheduling" -f $vCPU) + +# Changelog +## 1.2 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 b/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 index bbcb4fc7..e2daad98 100644 --- a/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 +++ b/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 @@ -1,25 +1,26 @@ +$Title = "VM Tools Not Up to Date" +$Header = "VM Tools Not Up to Date: [count]" +$Display = "Table" +$Author = "Alan Renouf, Shawn Masterson" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # Do not report on any VMs who are defined here (regex) -$VMTDoNotInclude = "VM1_*|VM2_*" +$VMTDoNotInclude = "" # Maximum number of VMs shown $VMTMaxReturn = 30 # End of Settings +# Update settings where there is an override +$VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude +$VMTMaxReturn = Get-vCheckSetting $Title "VMTMaxReturn" $VMTMaxReturn -# Changelog -## 1.0 : Initial Version - +$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude -and ($_.Runtime.Powerstate -eq "poweredOn" -And $_.Guest.toolsStatus -eq "toolsOld")} | ` + Select Name, @{N="Version";E={$_.Guest.ToolsVersion}}, @{N="Status";E={$_.Guest.ToolsStatus}} | Sort Name | Select -First $VMTMaxReturn -$Result = @($FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | Where {$_.Runtime.Powerstate -eq "poweredOn" -And $_.Guest.toolsStatus -eq "toolsOld"} | ` - Select Name, @{N="Version";E={$_.Guest.ToolsVersion}}, @{N="Status";E={$_.Guest.ToolsStatus}}) -$Return = $Result | Sort Name | Select -First $VMTMaxReturn -$Return +$Comments = ("The following VMs are running an older version of Tools than is available on its Host (Max Shown: {0} Exceptions: {1})" -f $VMTMaxReturn, $VMTDoNotInclude) - -$Title = "VM Tools Not Up to Date" -$Header = "VM Tools Not Up to Date: $(@($Result).Count)" -$Comments = "The following VMs are running an older version of Tools than is available on its Host (Max Shown: $VMTMaxReturn Exceptions: $VMTDoNotInclude)" -$Display = "Table" -$Author = "Alan Renouf, Shawn Masterson" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Version +## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 b/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 index d14a1ce9..bf8c10b3 100644 --- a/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 +++ b/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 @@ -1,16 +1,16 @@ -# Start of Settings -# End of Settings - -# Changelog -## 1.1 : Using quick stats property in order to avoid using Get-Stat cmdlet for performance matter - -$bs = $FullVM | Where {$_.runtime.PowerState -eq "PoweredOn" }| Select Name, @{N="SwapMB";E={$_.Summary.QuickStats.SwappedMemory}}, @{N="MemBalloonMB";E={$_.Summary.QuickStats.BalloonedMemory}} | Where { ($_.MemBalloonMB -gt 0) -Or ($_.SwapMB -gt 0)} -$bs - $Title = "VMs Ballooning or Swapping" -$Header = "VMs Ballooning or Swapping : $(@($bs).count)" +$Header = "VMs Ballooning or Swapping: [count]" $Comments = "Ballooning and swapping may indicate a lack of memory or a limit on a VM, this may be an indication of not enough memory in a host or a limit held on a VM, further information is available here." $Display = "Table" $Author = "Alan Renouf, Frederic Martin" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$FullVM | Where {$_.runtime.PowerState -eq "PoweredOn" -and ($_.Summary.QuickStats.SwappedMemory -gt 0 -or $_.Summary.QuickStats.BalloonedMemory -gt 0)} | Select Name, @{N="SwapMB";E={$_.Summary.QuickStats.SwappedMemory}}, @{N="MemBalloonMB";E={$_.Summary.QuickStats.BalloonedMemory}} + +# Changelog +## 1.1 : Using quick stats property in order to avoid using Get-Stat cmdlet for performance matter +## 1.2 : Updated where clause to filter first \ No newline at end of file diff --git a/Plugins/60 VM/120 Multi-writer.ps1 b/Plugins/60 VM/120 Multi-writer.ps1 index ca0661f6..b888b064 100644 --- a/Plugins/60 VM/120 Multi-writer.ps1 +++ b/Plugins/60 VM/120 Multi-writer.ps1 @@ -1,22 +1,20 @@ +$Title = "Multi-writer" +$Header = "VMs with Multi-writer parameter: [count]" +$Comments = "The following VMs have multi-writer parameter. A problem will occur in case of svMotion without reconfiguration of the applications which are using these virtual disks and also change of the VM configuration concerned. More information here." +$Display = "Table" +$Author = "Petar Enchev, Luc Dekens" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings -# Changelog -## 1.0 : Initial Version -## 1.1 : Change $VM variable to prevent clobbering - # Multi-writer parameter - ForEach ($mwvm in $FullVM){ $mwvm.Config.ExtraConfig | Where {$_.Key -like "scsi*sharing"} | Select @{N="VM";E={$mwvm.Name}},Key,Value } - -$Title = "Multi-writer" -$Header = "[count] VMs with Multi-writer parameter" -$Comments = "The following VMs have multi-writer parameter. A problem will occur in case of svMotion without reconfiguration of the applications which are using these virtual disks and also change of the VM configuration concerned. More information here." -$Display = "Table" -$Author = "Petar Enchev, Luc Dekens" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Version +## 1.1 : Change $VM variable to prevent clobbering \ No newline at end of file diff --git a/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 b/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 index 2b886c40..b192bb38 100644 --- a/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 +++ b/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 @@ -1,24 +1,23 @@ +$Title = "BusSharingMode - Physical and Virtual" +$Header = "BusSharingMode - Physical and Virtual: [count]" +$Comments = "The following VMs have physical and/or virtual bus sharing. A problem will occur in case of svMotion without reconfiguration of the applications which are using these virtual disks and also change of the VM configuration concerned." +$Display = "Table" +$Author = "Petar Enchev, Luc Dekens" +$PluginVersion = 1.0 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings -# Changelog -## 1.0 : Initial Version - # BusSharingMode - Physical and Virtual -$Result = @(ForEach ($vm in $FullVM){ +ForEach ($vm in $FullVM){ $scsi = $vm.Config.Hardware.Device | where {$_ -is [VMware.Vim.VirtualSCSIController] -and ($_.SharedBus -eq "physicalSharing" -or $_.SharedBus -eq "virtualSharing")} if ($scsi){ $scsi | Select @{N="VM";E={$vm.Name}}, @{N="Controller";E={$_.DeviceInfo.Label}}, @{N="BusSharingMode";E={$_.SharedBus}} } -}) -$Result +} -$Title = "BusSharingMode - Physical and Virtual" -$Header = "BusSharingMode - Physical and Virtual: $(@($Result).Count)" -$Comments = "The following VMs have physical and/or virtual bus sharing. A problem will occur in case of svMotion without reconfiguration of the applications which are using these virtual disks and also change of the VM configuration concerned." -$Display = "Table" -$Author = "Petar Enchev, Luc Dekens" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +# Changelog +## 1.0 : Initial Version \ No newline at end of file diff --git a/Plugins/60 VM/122 NonPersistent Disks.ps1 b/Plugins/60 VM/122 NonPersistent Disks.ps1 index 3a4963e7..e5f2466a 100644 --- a/Plugins/60 VM/122 NonPersistent Disks.ps1 +++ b/Plugins/60 VM/122 NonPersistent Disks.ps1 @@ -1,28 +1,31 @@ +$Title = "NonPersistent Disks" +$Header = "NonPersistent Disks: [count]" +$Comments = "The following server VMs have disks in NonPersistent mode (excludes all desktop VMs). A problem will occur in case of svMotion without reconfiguration of these virtual disks." +$Display = "Table" +$Author = "Petar Enchev, Luc Dekens" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings -# Exclude all desktop virtual machines +# Exclude all virtual machines from report $NPExcludeVM = "^DV-|^MLB-" # End of Settings -# Changelog -## 1.0 : Initial Version +# Update settings where there is an override +$NPExcludeVM = Get-vCheckSetting $Title "NPExcludeVM" $NPExcludeVM # NonPersistent Disks $diskModes = [VMware.Vim.VirtualDiskMode]::independent_nonpersistent,[VMware.Vim.VirtualDiskMode]::nonpersistent -$Result = @(ForEach($vm in $FullVM | Where {$_.Name -notmatch $NPExcludeVM}){ - $vm.Config.Hardware.Device | - Where {$_ -is [VMware.Vim.VirtualDisk] -and $diskModes -contains $_.Backing.DiskMode} | - Select @{N="VM";E={$vm.Name}}, - @{N="Disk";E={$_.DeviceInfo.Label}}, - @{N="Mode";E={$_.Backing.DiskMode}}, - @{N="CapacityGB";E={$_.capacityInKB/1MB}}, - @{N="Filename";E={$_.Backing.FileName}} -}) -$Result +ForEach($npvm in $FullVM | Where {$_.Name -notmatch $NPExcludeVM}){ + $npvm.Config.Hardware.Device | + Where {$_ -is [VMware.Vim.VirtualDisk] -and $diskModes -contains $_.Backing.DiskMode} | + Select @{N="VM";E={$npvm.Name}}, + @{N="Disk";E={$_.DeviceInfo.Label}}, + @{N="Mode";E={$_.Backing.DiskMode}}, + @{N="CapacityGB";E={$_.capacityInKB/1MB}}, + @{N="Filename";E={$_.Backing.FileName}} +} -$Title = "NonPersistent Disks" -$Header = "NonPersistent Disks: $(@($Result).Count)" -$Comments = "The following server VMs have disks in NonPersistent mode (excludes all desktop VMs). A problem will occur in case of svMotion without reconfiguration of these virtual disks." -$Display = "Table" -$Author = "Petar Enchev, Luc Dekens" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" \ No newline at end of file +# Changelog +## 1.0 : Initial Version +## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 b/Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 index cbf3362f..8a0086a7 100644 --- a/Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 +++ b/Plugins/60 VM/125 VMs with Isolated Configuration Files.ps1 @@ -9,13 +9,11 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$isolatedVMXs = @() Foreach ($CHKVM in $FullVM) { $vmxDatastore = (($CHKVM.Summary.Config.VmPathName).Split(']')[0].TrimStart('[')) $vmdkDatastores = @() - $CHKVM.Config.Hardware.Device | % - { + $CHKVM.Config.Hardware.Device | % { If ($_.Backing.Filename -ne $null) { $vmdkDatastores += ($_.Backing.Filename).Split(']')[0].TrimStart('[') diff --git a/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 b/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 index eb18a5a3..12ede159 100644 --- a/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 +++ b/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 @@ -1,9 +1,3 @@ -# Start of Settings -# End of Settings - -$FullVM | Where {$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"} | Sort Name | ` - Select Name, @{Name="ConnectionState";e={$_.Runtime.ConnectionState}}, @{Name="PowerState";e={$_.Runtime.PowerState}}, @{Name="IP_Address";e={$_.Guest.IpAddress}} - $Title = "Invalid or inaccessible VM" $Header = "VM invalid or inaccessible: [count]" $Comments = "The following VMs are marked as inaccessible or invalid" @@ -11,3 +5,9 @@ $Display = "Table" $Author = "Alan Renouf" $PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$FullVM | Where {$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"} | Sort Name | ` + Select Name, @{Name="ConnectionState";e={$_.Runtime.ConnectionState}}, @{Name="PowerState";e={$_.Runtime.PowerState}}, @{Name="IP_Address";e={$_.Guest.IpAddress}} \ No newline at end of file diff --git a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 index fc54760e..4bfb5d30 100644 --- a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 +++ b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 @@ -1,20 +1,21 @@ +$Title = "VMs restarted due to Guest OS Error" +$Header = "HA: VM restarted due to Guest OS Error: [count]" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # HA VM reset day(s) number due to Guest OS error $HAVMresetold = 5 # End of Settings -$EventFilterSpec = New-Object VMware.Vim.EventFilterSpec -$EventFilterSpec.Category = "info" -$EventFilterSpec.Time = New-Object VMware.Vim.EventFilterSpecByTime -$EventFilterSpec.Time.beginTime = (get-date).adddays(-$HAVMresetold) -$EventFilterSpec.eventTypeId = "TaskEvent" -$HAVMresetlist = @((get-view (get-view ServiceInstance -Property Content.EventManager).Content.EventManager).QueryEvents($EventFilterSpec) | ?{$_.FullFormattedMessage -match "reset due to a guest OS error"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending) -$HAVMresetlist +# Update settings where there is an override +$HAVMresetold = Get-vCheckSetting $Title "HAVMresetold" $HAVMresetold -$Title = "VMs restarted due to Guest OS Error" -$Header = "HA: VM restarted due to Guest OS Error (Last $HAVMresetold Day(s)) : $(@($HAVMresetlist).count)" -$Comments = "The following VMs have been restarted by HA in the last $HAVMresetold days" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +Get-VIEventPlus -Start ($Date).AddDays(-$HAVMresetold) -Type Info | ?{$_.FullFormattedMessage -match "reset due to a guest OS error"} |select CreatedTime,FullFormattedMessage | sort CreatedTime -Descending + +$Comments = ("The following VMs have been restarted by HA in the last {0} days" -f $HAVMresetold) + +# Change Log +## 1.3 : Add Get-vCheckSetting and switch to Get-VIEventPlus \ No newline at end of file diff --git a/Plugins/60 VM/19 Guests with less than X MB free.ps1 b/Plugins/60 VM/19 Guests with less than X MB free.ps1 index 717010d7..36a3f580 100644 --- a/Plugins/60 VM/19 Guests with less than X MB free.ps1 +++ b/Plugins/60 VM/19 Guests with less than X MB free.ps1 @@ -1,3 +1,9 @@ +$Title = "Guests with less than X MB free" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # VM Disk space left, set the amount you would like to report on MBFree $MBFree = 1024 @@ -5,31 +11,27 @@ $MBFree = 1024 $MBDiskMinSize = 1024 # End of Settings +# Update settings where there is an override +$MBFree = Get-vCheckSetting $Title "MBFree" $MBFree +$MBDiskMinSize = Get-vCheckSetting $Title "MBDiskMinSize" $MBDiskMinSize + $MyCollection = @() -$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq "poweredOn" -And ($_.Guest.toolsStatus -ne "toolsNotInstalled" -And $_.Guest.ToolsStatus -ne "toolsNotRunning")} -$SortedVMs = $AllVMs | Select *, @{N="NumDisks";E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks -ForEach ($VMdsk in $SortedVMs){ - $Details = New-object PSObject - $DiskNum = 0 - $Details | Add-Member -Name Name -Value $VMdsk.name -Membertype NoteProperty - Foreach ($disk in $VMdsk.Guest.Disk){ - if ((([math]::Round($disk.Capacity / 1MB)) -gt $MBDiskMinSize) -and (([math]::Round($disk.FreeSpace / 1MB)) -lt $MBFree)){ - $Details | Add-Member -Name "Disk$($DiskNum)path" -MemberType NoteProperty -Value $Disk.DiskPath - $Details | Add-Member -Name "Disk$($DiskNum)Capacity(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.Capacity/ 1MB)) - $Details | Add-Member -Name "Disk$($DiskNum)FreeSpace(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB)) - $DiskNum++ - } - } - if ($DiskNum -gt 0){ - $MyCollection += $Details - } +$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq "poweredOn" -And ($_.Guest.toolsStatus -ne "toolsNotInstalled" -And $_.Guest.ToolsStatus -ne "toolsNotRunning")} | Select *, @{N="NumDisks";E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks +ForEach ($VMdsk in $AllVMs){ + Foreach ($disk in $VMdsk.Guest.Disk){ + if ((([math]::Round($disk.Capacity / 1MB)) -gt $MBDiskMinSize) -and (([math]::Round($disk.FreeSpace / 1MB)) -lt $MBFree)){ + New-Object -TypeName PSObject -Property ([ordered]@{ + "Name" = $VMdsk.name + "Path" = $Disk.DiskPath + "Capacity (MB)" = ([math]::Round($disk.Capacity/ 1MB)) + "Free Space (MB)" =([math]::Round($disk.FreeSpace / 1MB)) + }) + } + } } -$MyCollection -$Title = "Guests with less than $MBFree MB" -$Header = "VMs with less than $MBFree MB : $(@($MyCollection).count)" -$Comments = "The following guests have less than $MBFree MB Free, if a guest disk fills up it may cause issues with the guest Operating System" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$Header = "VMs with less than $MBFree MB : [count]" +$Comments = ("The following guests have less than {0} MB Free, if a guest disk fills up it may cause issues with the guest Operating System" -f $MBFree) + +# Change Log +## 1.3 : Added Get-vCheckSetting, code refactor \ No newline at end of file diff --git a/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 b/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 index 4a9af812..9eef25d4 100644 --- a/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 +++ b/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 @@ -1,9 +1,3 @@ -# Start of Settings -# End of Settings - -$EphemeralPG = Get-VDSwitch | Get-VDPortgroup | where {$_.PortBinding -eq "Ephemeral"} -@($VM | Get-NetworkAdapter | where {$_.NetworkName -contains $EphemeralPG} | Select @{Name="VMName"; Expression={$_.parent}}, @{Name="Portgroup"; Expression={$_.NetworkName}}) - $Title = "VMs on Ephemeral Portgroup" $Header = "VMs on Ephemeral Portgroup: [count]" $Comments = "" @@ -11,3 +5,9 @@ $Display = "Table" $Author = "Tim Williams" $PluginVersion = 1.0 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$EphemeralPG = Get-VDSwitch | Get-VDPortgroup | where {$_.PortBinding -eq "Ephemeral"} +$VM | Get-NetworkAdapter | where {$_.NetworkName -contains $EphemeralPG} | Select @{Name="VMName"; Expression={$_.parent}}, @{Name="Portgroup"; Expression={$_.NetworkName}} \ No newline at end of file diff --git a/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 b/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 index 65a714e0..df158a0f 100644 --- a/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 +++ b/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 @@ -1,3 +1,10 @@ +$Title = "VMs Memory/CPU Hot Add configuration" +$Header = "VMs Memory/CPU Hot Add configuration" +$Display = "Table" +$Author = "Marc Bouchard" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Should CPU hot plug be enabled $CPUHotAdd = $true @@ -5,17 +12,17 @@ $CPUHotAdd = $true $MEMHotAdd = $true # End of Settings -@($VMs | Select-Object Name, @{N="CPU Hot Plug Enabled"; E={$_.ExtensionData.config.CpuHotAddEnabled}}, @{N="Memory Hot Add Enabled"; E={$_.ExtensionData.config.MemoryHotAddEnabled}}) | Where {$_."CPU Hot Plug Enabled" -ne $CPUHotAdd -or $_."Memory Hot Add Enabled" -ne $MEMHotAdd} +# Update settings where there is an override +$CPUHotAdd = Get-vCheckSetting $Title "CPUHotAdd" $CPUHotAdd +$MEMHotAdd = Get-vCheckSetting $Title "MEMHotAdd" $MEMHotAdd + +$VMs | Select-Object Name, @{N="CPU Hot Plug Enabled"; E={$_.ExtensionData.config.CpuHotAddEnabled}}, @{N="Memory Hot Add Enabled"; E={$_.ExtensionData.config.MemoryHotAddEnabled}} | Where {$_."CPU Hot Plug Enabled" -ne $CPUHotAdd -or $_."Memory Hot Add Enabled" -ne $MEMHotAdd} # Create variables with unexpected values, for use in the plugin comment $CPUNotExpected = if ($CPUHotAdd) { "disabled" } else { "enabled" } $MEMNotExpected = if ($MEMHotAdd) { "disabled" } else { "enabled" } -$Title = "VMs Memory/CPU Hot Add configuration" -$Header = "VMs Memory/CPU Hot Add configuration" $Comments = ("The following lists all VMs with CPU hot plug {0} or Memory hot add {1}" -f $CPUNotExpected, $MEMNotExpected) -$Display = "Table" -$Author = "Marc Bouchard" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +# Change Log +## 1.2 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/202 VMs MMU Configuration.ps1 b/Plugins/60 VM/202 VMs MMU Configuration.ps1 index 6c830874..e4d2db3c 100644 --- a/Plugins/60 VM/202 VMs MMU Configuration.ps1 +++ b/Plugins/60 VM/202 VMs MMU Configuration.ps1 @@ -1,14 +1,16 @@ -# Start of Settings -# End of Settings - -$CPUMMU = @(Get-VM | Sort -Property Name | Select-Object Name, @{N="Virtual Exec"; E={$_.ExtensionData.Config.Flags.VirtualExecUsage}}, @{N="Virtual MMU"; E={$_.ExtensionData.Config.Flags.VirtualMmuUsage}}) -$CPUMMU - $Title = "Hardware CPU/MMU virtualization configuration" $Header = "Hardware CPU/MMU virtualization configuration" $Comments = "The following lists all VMs and their hardware CPU/MMU virtualization configuration" - $Display = "Table" $Author = "Marc Bouchard" -$PluginVersion = 1.0 +$PluginVersion = 1.1 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$VM | Select-Object Name, @{N="Virtual Exec"; E={$_.ExtensionData.Config.Flags.VirtualExecUsage}}, @{N="Virtual MMU"; E={$_.ExtensionData.Config.Flags.VirtualMmuUsage}} + +# Change Log +## 1.0 : Initial release +## 1.1 : Remove Get-VM \ No newline at end of file diff --git a/Plugins/60 VM/22 Checking VM Hardware Version.ps1 b/Plugins/60 VM/22 Checking VM Hardware Version.ps1 index 6e34dff8..6f5a783f 100644 --- a/Plugins/60 VM/22 Checking VM Hardware Version.ps1 +++ b/Plugins/60 VM/22 Checking VM Hardware Version.ps1 @@ -1,16 +1,23 @@ +$Title = "Checking VM Hardware Version" +$Header = "VMs with old hardware: [count]" +$Comments = "The following VMs are not at the latest hardware version, you may gain performance enhancements if you convert them to the latest version" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Hardware Version to check for at least $HWVers = 8 -#Adding filter for dsvas, vShield appliances or any other vms that will remain on a lower HW version +# Adding filter for dsvas, vShield appliances or any other vms that will remain on a lower HW version $vmIgnore = "vShield*|dsva*" # End of Settings -@($VM | Where-Object {$_.Name -notmatch $vmIgnore} | Select-Object Name, HWVersion | Where-Object {[INT]($_.HWVersion)-lt $HWVers}) +# Update settings where there is an override +$HWVers = Get-vCheckSetting $Title "HWVers" $HWVers +$vmIgnore = Get-vCheckSetting $Title "vmIgnore" $vmIgnore -$Title = "Checking VM Hardware Version" -$Header = "VMs with old hardware: [count]" -$Comments = "The following VMs are not at the latest hardware version, you may gain performance enhancements if you convert them to the latest version" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +$VM | Where-Object {$_.Name -notmatch $vmIgnore -and [INT]($_.HWVersion)-lt $HWVers} | Select-Object Name, HWVersion + +# Change Log +## 1.3 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/25 VMs in inconsistent folders.ps1 b/Plugins/60 VM/25 VMs in inconsistent folders.ps1 index c8aece76..10936599 100644 --- a/Plugins/60 VM/25 VMs in inconsistent folders.ps1 +++ b/Plugins/60 VM/25 VMs in inconsistent folders.ps1 @@ -1,25 +1,30 @@ +$Title = "VMs in inconsistent folders" +$Header = "VMs in Inconsistent folders: [count]" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Specify which Datastore(s) to filter from report $DatastoreIgnore = "local" # End of Settings -$VMFolder = @() +# Update settings where there is an override +$DatastoreIgnore = Get-vCheckSetting $Title "DatastoreIgnore" $DatastoreIgnore + Foreach ($CHKVM in $FullVM){ - $Details = "" |Select-Object VM,Path - $Folder = ((($CHKVM.Summary.Config.VmPathName).Split(']')[1]).Split('/'))[0].TrimStart(' ') - $Path = ($CHKVM.Summary.Config.VmPathName).Split('/')[0] - If (($CHKVM.Name-ne $Folder) -and ($Path -notmatch $DatastoreIgnore)){ - $Details.VM= $CHKVM.Name - $Details.Path= $Path - $VMFolder += $Details} + $Folder = ((($CHKVM.Summary.Config.VmPathName).Split(']')[1]).Split('/'))[0].TrimStart(' ') + $Path = ($CHKVM.Summary.Config.VmPathName).Split('/')[0] + If (($CHKVM.Name-ne $Folder) -and ($Path -notmatch $DatastoreIgnore)){ + New-Object -TypeName PSObject -Property @{ + "VM" = $CHKVM.Name + "Path" = $Path } + } } -$VMFolder -$Title = "VMs in inconsistent folders" -$Header = "VMs in Inconsistent folders $(@($VMFolder).Count), excluding those on datastores @($DatastoreIgnore)" -$Comments = "The following VMs are not stored in folders consistent to their names, this may cause issues when trying to locate them from the datastore manually" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" -# Datastore filtering added by monahancj +$Comments = ("The following VMs are not stored in folders consistent to their names (excluding those on datastores {0}), this may cause issues when trying to locate them from the datastore manually" -f $DatastoreIgnore) + +# Change Log +## 1.2 : Datastore filtering added by monahancj +## 1.3 : Added Get-vCheckSetting, code refactor diff --git a/Plugins/60 VM/26 No VM Tools.ps1 b/Plugins/60 VM/26 No VM Tools.ps1 index bd9f377c..5390dfb4 100644 --- a/Plugins/60 VM/26 No VM Tools.ps1 +++ b/Plugins/60 VM/26 No VM Tools.ps1 @@ -1,15 +1,20 @@ -# Start of Settings -# Do not report on any VMs who are defined here (regex) -$VMTDoNotInclude = "VM1_*|VM2_*" -# End of Settings - -$Result = @($FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | Where {$_.Runtime.Powerstate -eq "poweredOn" -And ($_.Guest.toolsStatus -eq "toolsNotInstalled" -Or $_.Guest.ToolsStatus -eq "toolsNotRunning")} | Select Name, @{N="Status";E={$_.Guest.ToolsStatus}}) -$Result - $Title = "No VM Tools" -$Header = "No VM Tools: $(@($Result).Count)" +$Header = "No VM Tools: [count]" $Comments = "The following VMs have No VMTools installed, for optimal configuration and performance these should be installed" $Display = "Table" $Author = "Alan Renouf" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# Do not report on any VMs who are defined here (regex) +$VMTDoNotInclude = "" +# End of Settings + +# Update settings where there is an override +$VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude + +$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude -and $_.Runtime.Powerstate -eq "poweredOn" -And ($_.Guest.toolsStatus -eq "toolsNotInstalled" -Or $_.Guest.ToolsStatus -eq "toolsNotRunning")} | Select Name, @{N="Status";E={$_.Guest.ToolsStatus}} + +# Change Log +## 1.2 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/27 VM Tools Issues.ps1 b/Plugins/60 VM/27 VM Tools Issues.ps1 index 044a6ef9..fa60ec1a 100644 --- a/Plugins/60 VM/27 VM Tools Issues.ps1 +++ b/Plugins/60 VM/27 VM Tools Issues.ps1 @@ -1,15 +1,20 @@ -# Start of Settings -# VM Tools Issues, do not report on any VMs who are defined here -$VMTDoNotInclude = "VM1_*|VM2_*" -# End of Settings - -$Result = $FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | Where {$_.Guest.GuestState -eq "Running" -And ($_.Guest.GuestFullName -eq $NULL -or $_.Guest.IPAddress -eq $NULL -or $_.Guest.HostName -eq $NULL -or $_.Guest.Disk -eq $NULL -or $_.Guest.Net -eq $NULL)} | select Name, @{N="IPAddress";E={$_.Guest.IPAddress[0]}},@{n="OSFullName";E={$_.Guest.GuestFullName}},@{n="HostName";e={$_.guest.hostname}},@{N="NetworkLabel";E={$_.guest.Net[0].Network}} -ErrorAction SilentlyContinue |sort Name -$Result - $Title = "VM Tools Issues" -$Header = "VM Tools Issues: $(@($Result).Count)" +$Header = "VM Tools Issues: [count]" $Comments = "The following VMs have issues with VMTools, these should be checked and reinstalled if necessary" $Display = "Table" $Author = "Alan Renouf" -$PluginVersion = 1.1 +$PluginVersion = 1.2 $PluginCategory = "vSphere" + +# Start of Settings +# VM Tools Issues, do not report on any VMs who are defined here +$VMTDoNotInclude = "" +# End of Settings + +# Update settings where there is an override +$VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude + +$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | Where {$_.Guest.GuestState -eq "Running" -And ($_.Guest.GuestFullName -eq $NULL -or $_.Guest.IPAddress -eq $NULL -or $_.Guest.HostName -eq $NULL -or $_.Guest.Disk -eq $NULL -or $_.Guest.Net -eq $NULL)} | select Name, @{N="IPAddress";E={$_.Guest.IPAddress[0]}},@{n="OSFullName";E={$_.Guest.GuestFullName}},@{n="HostName";e={$_.guest.hostname}},@{N="NetworkLabel";E={$_.guest.Net[0].Network}} -ErrorAction SilentlyContinue |sort Name + +# Change Log +## 1.2 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/28 Removable Media Connected.ps1 b/Plugins/60 VM/28 Removable Media Connected.ps1 index a63e330d..7c023ab4 100644 --- a/Plugins/60 VM/28 Removable Media Connected.ps1 +++ b/Plugins/60 VM/28 Removable Media Connected.ps1 @@ -1,8 +1,19 @@ +$Title = "Removable Media Connected" +$Header = "VMs with Removable Media Connected: [count]" +$Comments = "The following VMs have removable media connected (i.e. CD/Floppy), this may cause issues if this machine needs to be migrated to a different host" +$Display = "Table" +$Author = "Alan Renouf, Frederic Martin" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # VMs with removable media not to report on -$IgnoreVMMedia = "APP*|ETC*" +$IgnoreVMMedia = "" # End of Settings +# Update settings where there is an override +$IgnoreVMMedia = Get-vCheckSetting $Title "IgnoreVMMedia" $IgnoreVMMedia + $FullVM | ?{$_.runtime.powerState -eq "PoweredOn" -And $_.Name -notmatch $IgnoreVMMedia} | % { $VMName = $_.Name; $_.config.hardware.device | ?{($_ -is [VMware.Vim.VirtualFloppy] -or $_ -is [VMware.Vim.VirtualCdrom]) -and $_.Connectable.Connected} | Select @{Name="VMName"; Expression={ $VMName}}, @@ -10,12 +21,7 @@ $FullVM | ?{$_.runtime.powerState -eq "PoweredOn" -And $_.Name -notmatch $Ignore @{Name="Device Name"; Expression={ $_.DeviceInfo.Label}}, @{Name="Device Backing"; Expression={ $_.DeviceInfo.Summary}} } - -$Title = "Removable Media Connected" -$Header = "VMs with Removable Media Connected: [count]" -$Comments = "The following VMs have removable media connected (i.e. CD/Floppy), this may cause issues if this machine needs to be migrated to a different host" -$Display = "Table" -$Author = "John Sneddon" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" -# Based on code submitted by Alan Renouf, Frederic Martin \ No newline at end of file + +# Change Log +## 1.0 : Initial release +## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/30 Single Storage VMs.ps1 b/Plugins/60 VM/30 Single Storage VMs.ps1 index 53317663..4e586206 100644 --- a/Plugins/60 VM/30 Single Storage VMs.ps1 +++ b/Plugins/60 VM/30 Single Storage VMs.ps1 @@ -1,17 +1,22 @@ +$Title = "Single Storage VMs" +$Header = "VMs stored on non shared datastores: [count]" +$Comments = "The following VMs are located on storage which is only accessible by 1 host, these will not be compatible with vMotion and may be disconnected in the event of host failure" +$Display = "Table" +$Author = "Alan Renouf, Frederic Martin" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # Local Stored VMs, do not report on any VMs who are defined here $LVMDoNotInclude = "Template_*|VDI*" # End of Settings +# Update settings where there is an override +$LVMDoNotInclude = Get-vCheckSetting $Title "LVMDoNotInclude" $LVMDoNotInclude + $unSharedDatastore = $storageviews | ?{-Not $_.summary.multiplehostaccess} | Select -Expand Name -$Result = $FullVM | ?{$_.Name -notmatch $LVMDoNotInclude} | ?{$_.Runtime.ConnectionState -notmatch "invalid|orphaned"} | %{$_.layoutex.file} | ?{$_.type -ne "log" -and $_.name -notmatch ".vswp$" -And $unSharedDatastore -contains $_.name.Split(']')[0].Split('[')[1]} | Select Name -$Result +$FullVM | ?{$_.Name -notmatch $LVMDoNotInclude} | ?{$_.Runtime.ConnectionState -notmatch "invalid|orphaned"} | %{$_.layoutex.file} | ?{$_.type -ne "log" -and $_.name -notmatch ".vswp$" -And $unSharedDatastore -contains $_.name.Split(']')[0].Split('[')[1]} | Select Name -$Title = "Single Storage VMs" -$Header = "VMs stored on non shared datastores: $(@($Result).Count)" -$Comments = "The following VMs are located on storage which is only accessible by 1 host, these will not be compatible with vMotion and may be disconnected in the event of host failure" -$Display = "Table" -$Author = "Alan Renouf, Frederic Martin" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" +# Change Log +## 1.4 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/32 VM CPU Percent RDY.ps1 b/Plugins/60 VM/32 VM CPU Percent RDY.ps1 index 28bbcafd..6e866592 100644 --- a/Plugins/60 VM/32 VM CPU Percent RDY.ps1 +++ b/Plugins/60 VM/32 VM CPU Percent RDY.ps1 @@ -1,27 +1,49 @@ +$Title = "VM CPU %RDY" +$Comments = "The following VMs have high CPU RDY times, this can cause performance issues for more information please read This article" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # CPU ready on VMs should not exceed $PercCPUReady = 10.0 # End of Settings +# Setup plugin-specific language table +$pLang = DATA { + ConvertFrom-StringData @' + pluginActivity = Checking VM CPU RDY % +'@ +} + +# Override the default (en) if it exists in lang directory +Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLang -ErrorAction SilentlyContinue -$myCol = @() +# Update settings where there is an override +$PercCPUReady = Get-vCheckSetting $Title "PercCPUReady" $PercCPUReady + +$i=0 ForEach ($v in ($VM | Where {$_.PowerState -eq "PoweredOn"})){ - For ($cpunum = 0; $cpunum -lt $v.NumCpu; $cpunum++){ - $myObj = "" | Select VM, VMHost, CPU, PercReady - $myObj.VM = $v.Name - $myObj.VMHost = $v.VMHost - $myObj.CPU = $cpunum - $myObj.PercReady = [Math]::Round((($v | Get-Stat -ErrorAction SilentlyContinue -Stat Cpu.Ready.Summation -Realtime | Where {$_.Instance -eq $cpunum} | Measure-Object -Property Value -Average).Average)/200,1) - $myCol += $myObj - } + Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $v.Name -PercentComplete ((100*$i)/$VM.Count) + For ($cpunum = 0; $cpunum -lt $v.NumCpu; $cpunum++){ + $PercReady = [Math]::Round((($v | Get-Stat -ErrorAction SilentlyContinue -Stat Cpu.Ready.Summation -Realtime | Where {$_.Instance -eq $cpunum} | Measure-Object -Property Value -Average).Average)/200,1) + + if ($_.PercReady -gt $PercCPUReady) + { + New-Object -TypeName PSObject -Property @{ + VM = $v.Name + VMHost = $v.VMHost + CPU = $cpunum + PercReady = $PercReady + } + } + } + $i++ } -$Result = @($myCol | Where {$_.PercReady -gt $PercCPUReady} | Sort PercReady -Descending) -$Result +Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $lang.Complete -Completed -$Title = "VM CPU %RDY" -$Header = "VM CPU % RDY over $($PercCPUReady): $(@($Result).Count)" -$Comments = "The following VMs have high CPU RDY times, this can cause performance issues for more information please read This article" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +$Header = ("VM CPU % RDY over {0}: [count]" -f $PercCPUReady) + +# Change Log +## 1.2 : Added Get-vCheckSetting, code refactor \ No newline at end of file diff --git a/Plugins/60 VM/33 VM CPU Usage.ps1 b/Plugins/60 VM/33 VM CPU Usage.ps1 index 20f3ca27..f7921b93 100644 --- a/Plugins/60 VM/33 VM CPU Usage.ps1 +++ b/Plugins/60 VM/33 VM CPU Usage.ps1 @@ -1,3 +1,10 @@ +$Title = "VM CPU Usage" +$Comments = "The following VMs have high CPU usage and may have rogue guest processes or not enough CPU resource assigned" +$Display = "Table" +$Author = "Alan Renouf, Sam McGeown" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # VM Not to go over the following amount of CPU $CPUValue = 75 @@ -5,17 +12,14 @@ $CPUValue = 75 $CPUDays = 1 # End of Settings -# ChangeLog -# 1.3 - Performance tweaks (approx 75% faster with IntervalMins than Start/Finish). +# Update settings where there is an override +$CPUValue = Get-vCheckSetting $Title "CPUValue" $CPUValue +$CPUDays = Get-vCheckSetting $Title "CPUDays" $CPUDays -$Result = $VM | Select Name, @{N="AverageCPU";E={[Math]::Round(($_ | Get-Stat -Stat cpu.usage.average -IntervalMins 60 -MaxSamples ($CPUDays*24) -ErrorAction SilentlyContinue | Measure-Object -Property Value -Average).Average)}}, NumCPU, VMHost | Where {$_.AverageCPU -gt $CPUValue} | Sort AverageCPU -Descending +$VM | Select Name, @{N="AverageCPU";E={[Math]::Round(($_ | Get-Stat -Stat cpu.usage.average -IntervalMins 60 -MaxSamples ($CPUDays*24) -ErrorAction SilentlyContinue | Measure-Object -Property Value -Average).Average)}}, NumCPU, VMHost | Where {$_.AverageCPU -gt $CPUValue} | Sort AverageCPU -Descending -$Result +$Header = ("VM(s) CPU above {0}%: [count]" -f $CPUValue) -$Title = "VM CPU Usage" -$Header = "VM(s) CPU above $($CPUValue)% : $(@($Result).Count)" -$Comments = "The following VMs have high CPU usage and may have rogue guest processes or not enough CPU resource assigned" -$Display = "Table" -$Author = "Alan Renouf, Sam McGeown" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" +# ChangeLog +## 1.3 : Performance tweaks (approx 75% faster with IntervalMins than Start/Finish). +## 1.4 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/37 VM Alarms.ps1 b/Plugins/60 VM/37 VM Alarms.ps1 index b66a0ba4..34b54a29 100644 --- a/Plugins/60 VM/37 VM Alarms.ps1 +++ b/Plugins/60 VM/37 VM Alarms.ps1 @@ -1,28 +1,25 @@ +$Title = "VM Alarms" +$Header = "VM Alarm(s): [count]" +$Comments = "The following alarms have been registered against VMs in vCenter" +$Display = "Table" +$Author = "Alan Renouf" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings $vmsalarms = @() -foreach ($VMView in $FullVM){ - if ($VMView.TriggeredAlarmState){ - $VMsTriggeredAlarms = $VMView.TriggeredAlarmState - Foreach ($VMsTriggeredAlarm in $VMsTriggeredAlarms){ - $Details = "" | Select-Object Object, Alarm, Status, Time - $Details.Object = $VMView.name - $Details.Alarm = ($valarms |?{$_.value -eq ($VMsTriggeredAlarm.alarm.value)}).name - $Details.Status = $VMsTriggeredAlarm.OverallStatus - $Details.Time = $VMsTriggeredAlarm.time - $vmsalarms += $Details - } - } +foreach ($VMView in ($FullVM | Where {$_.TriggeredAlarmState})){ + Foreach ($VMsTriggeredAlarm in $VMView.TriggeredAlarmState){ + New-Object -TypeName PSObject -Property @{ + Object = $VMView.name + Alarm = ($valarms |?{$_.value -eq ($VMsTriggeredAlarm.alarm.value)}).name + Status = $VMsTriggeredAlarm.OverallStatus + Time = $VMsTriggeredAlarm.time + } + } } -$vmsalarms | sort Object - -$Title = "VM Alarms" -$Header = "VM(s) Alarm(s): $(@($vmsalarms).Count)" -$Comments = "The following alarms have been registered against VMs in vCenter" -$Display = "Table" -$Author = "Alan Renouf" -$PluginVersion = 1.1 - -$PluginCategory = "vSphere" +# Change Log +## 1.3 : Code refactor \ No newline at end of file diff --git a/Plugins/60 VM/40 VCB Garbage.ps1 b/Plugins/60 VM/40 VCB Garbage.ps1 index e7b5e47e..ec2221f9 100644 --- a/Plugins/60 VM/40 VCB Garbage.ps1 +++ b/Plugins/60 VM/40 VCB Garbage.ps1 @@ -1,13 +1,13 @@ -# Start of Settings -# End of Settings - -$Results = $FullVM | ?{$_.snapshot | %{$_.rootsnapshotlist | ?{$_.name -contains "VCB|Consolidate|veeam|NBU_SNAPSHOT"}}} | Sort Name | Select Name -$Results - $Title = "VCB/Veeam/NetBackup Garbage" -$Header = "VCB/Veeam/Netbackup Garbage: $(@($Results).Count)" +$Header = "VCB/Veeam/Netbackup Garbage: [count]" $Comments = "The following snapshots have been left over from using VCB/Veeam or Netbackup, you may wish to investigate if these are still needed" $Display = "Table" $Author = "Alan Renouf, Frederic Martin" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" + + +# Start of Settings +# End of Settings + +$FullVM | ?{$_.snapshot | %{$_.rootsnapshotlist | ?{$_.name -contains "VCB|Consolidate|veeam|NBU_SNAPSHOT"}}} | Sort Name | Select Name \ No newline at end of file diff --git a/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 b/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 index c5fd9d2f..75959dd5 100644 --- a/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 +++ b/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 @@ -1,15 +1,14 @@ -# Start of Settings -# End of Settings - -$htabHostVersion = @{} -$HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)} -$Consol = $FullVM | ?{$htabHostVersion[$_.runtime.host].Split('.')[0] -ge 5 -and $_.runtime.consolidationNeeded} | Sort-Object -Property Name | Select Name,@{N="Consolidation needed";E={$_.Runtime.consolidationNeeded}} -$Consol - $Title = "VMs needing snapshot consolidation" -$Header = "VMs needing snapshot consolidation $(@($Consol).Count)" +$Header = "VMs needing snapshot consolidation [count]" $Comments = "The following VMs have snapshots that failed to consolidate. See this article for more details" $Display = "Table" $Author = "Luc Dekens, Frederic Martin" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$htabHostVersion = @{} +$HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)} +$FullVM | ?{$htabHostVersion[$_.runtime.host].Split('.')[0] -ge 5 -and $_.runtime.consolidationNeeded} | Sort-Object -Property Name | Select Name,@{N="Consolidation needed";E={$_.Runtime.consolidationNeeded}} \ No newline at end of file diff --git a/Plugins/60 VM/48 Find VM Disk Format.ps1 b/Plugins/60 VM/48 Find VM Disk Format.ps1 index 2959ea7f..54f559c2 100644 --- a/Plugins/60 VM/48 Find VM Disk Format.ps1 +++ b/Plugins/60 VM/48 Find VM Disk Format.ps1 @@ -5,14 +5,19 @@ $diskformat = "thick" $DatastoreIgnore = "local" # End of Settings -$vmdiskformat = $VM | Get-HardDisk | where {($_.storageformat -match $diskformat) -and ($_.Filename -notmatch $DatastoreIgnore)} | select @{N="VM";E={$_.parent.name}}, @{N="DiskName";E={$_.name}}, @{N="Format";E={$_.storageformat}}, @{N="FileName";E={$_.filename}} -$vmdiskformat +# Update settings where there is an override +$diskformat = Get-vCheckSetting $Title "diskformat" $diskformat +$DatastoreIgnore = Get-vCheckSetting $Title "DatastoreIgnore" $DatastoreIgnore + +$VM | Get-HardDisk | where {($_.storageformat -match $diskformat) -and ($_.Filename -notmatch $DatastoreIgnore)} | select @{N="VM";E={$_.parent.name}}, @{N="DiskName";E={$_.name}}, @{N="Format";E={$_.storageformat}}, @{N="FileName";E={$_.filename}} $Title = "Find VMs with thick or thin provisioned vmdk" -$Header = "VMs with $diskformat provisioned vmdk(s): $(@($vmdiskformat).count)" +$Header = "VMs with $diskformat provisioned vmdk(s): [count]" $Comments = "The following VMs have have $diskformat provisioned vmdk(s)" $Display = "Table" $Author = "David Chung" -$PluginVersion = 1.2 - +$PluginVersion = 1.3 $PluginCategory = "vSphere" + +# Change Log +## 1.3 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 b/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 index 1aedc7ff..fb117232 100644 --- a/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 +++ b/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 @@ -1,13 +1,12 @@ -# Start of Settings -# End of Settings -#@($VM | Get-VMResourceConfiguration | Where-Object {$_.CpuLimitMHZ -ne '-1' -or $_.MemLimitMB -ne '-1'} | Select-Object VM,CpuLimitMhz,MemLimitMB) - -@($FullVM | ?{$_.config.cpuallocation.limit -ne "-1" -or $_.config.memoryallocation.limit -ne "-1"} | Select Name, @{Name="CpuLimitMhz";E={$_.config.cpuallocation.limit}}, @{Name="MemLimitMB";E={$_.config.memoryallocation.limit}}) -$PluginCategory = "vSphere" - $Title = "VMs with CPU or Memory Limits Configured" -$Header = "VMs with CPU or Memory Limits Configured" +$Header = "VMs with CPU or Memory Limits Configured: [count]" $Comments = "The following VMs have a CPU or memory limit configured which may impact the performance of the VM. Note: -1 indicates no limit" $Display = "Table" $Author = "Jonathan Medd" $PluginVersion = 1.1 +$PluginCategory = "vSphere" + +# Start of Settings +# End of Settings + +$FullVM | ?{$_.config.cpuallocation.limit -ne "-1" -or $_.config.memoryallocation.limit -ne "-1"} | Select Name, @{Name="CpuLimitMhz";E={$_.config.cpuallocation.limit}}, @{Name="MemLimitMB";E={$_.config.memoryallocation.limit}} \ No newline at end of file diff --git a/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 b/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 index c318ff9a..9e133d72 100644 --- a/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 +++ b/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 @@ -1,21 +1,22 @@ -# Start of Settings -# VMs with incorrect OS Configuration, do not report on any VMs who are defined here -$VMTDoNotInclude = "VM1_*|VM2_*" -# End of Settings - -$Result = @( $FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} |` - Where-Object {$_.Guest.GuestId -and $_.Guest.GuestId -ne $_.Config.GuestId} | ` - Select-Object -Property Name,@{N="GuestId";E={$_.Guest.GuestId}}, - @{N="Installed Guest OS";E={$_.Guest.GuestFullName}}, - @{N="Configured GuestId";E={$_.Config.GuestId}}, - @{N="Configured Guest OS";E={$_.Config.GuestFullName}} -) -$Result - $Title = "Virtual machines with incorrect OS configuration" -$Header = "Virtual machines with incorrect OS configuration : $(@($Result).Count)" +$Header = "Virtual machines with incorrect OS configuration: [count]" $Comments = "The following virtual machines have an installed OS that is different from the configured OS. This can impact the performance of the virtual machine." $Display = "Table" $Author = "Robert van den Nieuwendijk" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" + +# Start of Settings +# VMs with incorrect OS Configuration, do not report on any VMs who are defined here +$VMTDoNotInclude = "VM1_*|VM2_*" +# End of Settings + +# Update settings where there is an override +$VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude + +$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} |` + Where-Object {$_.Guest.GuestId -and $_.Guest.GuestId -ne $_.Config.GuestId} | ` + Select-Object -Property Name,@{N="GuestId";E={$_.Guest.GuestId}}, + @{N="Installed Guest OS";E={$_.Guest.GuestFullName}}, + @{N="Configured GuestId";E={$_.Config.GuestId}}, + @{N="Configured Guest OS";E={$_.Config.GuestFullName}} \ No newline at end of file diff --git a/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 b/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 index f18d75f0..91b5601d 100644 --- a/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 +++ b/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 @@ -1,19 +1,23 @@ +$Title = "Virtual machines with less hard disks than partitions" +$Header = "Virtual machines with less hard disks than partitions: [count]" +$Comments = "Virtual machines with less hard disks than partitions. Probably they have more than one partition on a hard disk." +$Display = "Table" +$Author = "Robert van den Nieuwendijk" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # Do not report on any VMs who are defined here (regex) $VMTDoNotInclude = "VM1_*|VM2_*" # End of Settings -$Result = @($FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | - Where-Object {$_.Config.ManagedBy.ExtensionKey -ne 'com.vmware.vcDr'} | - Select-Object -Property Name,@{N="NrOfHardDisks";E={($_.Layout.Disk|measure).count}},@{N="NrOfGuestDisks";E={($_.Guest.Disk|measure).count}},@{N="GuestFamily";E={$_.Guest.GuestFamily}} | - Where-Object {$_.GuestFamily -eq "windowsGuest" -and $_.NrOfHardDisks -lt $_.NrOfGuestDisks} - ) -$Result +# Update settings where there is an override +$VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude -$Title = "Virtual machines with less hard disks than partitions" -$Header = "Virtual machines with less hard disks than partitions : $(@($Result).count)" -$Comments = "Virtual machines with less hard disks than partitions. Probably they have more than one partition on a hard disk." -$Display = "Table" -$Author = "Robert van den Nieuwendijk" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" +$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | + Where-Object {$_.Config.ManagedBy.ExtensionKey -ne 'com.vmware.vcDr'} | + Select-Object -Property Name,@{N="NrOfHardDisks";E={($_.Layout.Disk|measure).count}},@{N="NrOfGuestDisks";E={($_.Guest.Disk|measure).count}},@{N="GuestFamily";E={$_.Guest.GuestFamily}} | + Where-Object {$_.GuestFamily -eq "windowsGuest" -and $_.NrOfHardDisks -lt $_.NrOfGuestDisks} + +# Change Log +## 1.4 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/60 Powered Off VMs.ps1 b/Plugins/60 VM/60 Powered Off VMs.ps1 index e0b62ddb..66922448 100644 --- a/Plugins/60 VM/60 Powered Off VMs.ps1 +++ b/Plugins/60 VM/60 Powered Off VMs.ps1 @@ -1,18 +1,29 @@ +$Title = "Powered Off VMs" +$Header = "VMs Powered Off - Number of Days" +$Display = "Table" +$Author = "Adam Schwartzberg" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # VMs not to report on $IgnoredVMs = "Windows7*" +# Report VMs powered off over this many days +$PoweredOffDays = 7 # End of Settings -$DecommedVMs = @($VM | - Where-Object {$_.ExtensionData.Config.ManagedBy.ExtensionKey -ne 'com.vmware.vcDr' -and $_.PowerState -eq "PoweredOff" -and $_.Name -notmatch $IgnoredVMs} | +# Update settings where there is an override +$IgnoredVMs = Get-vCheckSetting $Title "IgnoredVMs" $IgnoredVMs +$PoweredOffDays = Get-vCheckSetting $Title "PoweredOffDays" $PoweredOffDays + +$VM | Where-Object {$_.ExtensionData.Config.ManagedBy.ExtensionKey -ne 'com.vmware.vcDr' -and + $_.PowerState -eq "PoweredOff" -and + $_.LastPoweredOffDate -lt $date.AddDays(-$PoweredOffDays) -and + $_.Name -notmatch $IgnoredVMs} | Select-Object -Property Name, LastPoweredOffDate, Folder, Notes | - Sort-Object -Property LastPoweredOffDate) -$DecommedVMs + Sort-Object -Property LastPoweredOffDate -$Title = "Powered Off VMs" -$Header = "VMs Powered Off - Number of Days" -$Comments = "May want to consider deleting VMs that have been powered off for more than 30 days" -$Display = "Table" -$Author = "Adam Schwartzberg" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" +$Comments = ("May want to consider deleting VMs that have been powered off for more than {0} days" -f $PoweredOffDays) + +# Change Log +## 1.4 : Added Get-vCheckSetting, $PoweredOffDays \ No newline at end of file diff --git a/Plugins/60 VM/61 Guest OS Pivot table.ps1 b/Plugins/60 VM/61 Guest OS Pivot table.ps1 index 0c5c6ce4..f1004da5 100644 --- a/Plugins/60 VM/61 Guest OS Pivot table.ps1 +++ b/Plugins/60 VM/61 Guest OS Pivot table.ps1 @@ -1,3 +1,11 @@ +$Title = "VMs by Operating System" +$Header = "VMs by Operating System : [count]" +$Comments = "The following Operating Systems are in use in this vCenter" +$Display = "Table" +$Author = "Raymond" +$Version = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings @@ -30,17 +38,5 @@ foreach ( $gosname in $VMOSversions.Keys | sort) { $myCol += $MyDetails } -$vVMOSversions = $myCol | sort Count -desc -If (($vVMOSversions | Measure-Object).count -gt 0) { - $Header = "VMs by Operating System : $($vVMOSversions.count)" - $vVMOSversions -} -$vVMOSversions = $null - - -$Title = "VMs by Operating System" -$Comments = "The following Operating Systems are in use in this vCenter" -$Display = "Table" -$Author = "Raymond" -$Version = 1.3 -$PluginCategory = "vSphere" +$myCol | sort Count -desc +Remove-Variable VMOSversions \ No newline at end of file diff --git a/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 b/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 index e28bb1f4..cfc8e970 100644 --- a/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 +++ b/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 @@ -1,25 +1,29 @@ +$Title = "Unwanted virtual hardware found" +$Header = "Unwanted virtual hardware found: [count]" +$Comments = "Certain kinds of hardware are unwanted on virtual machines as they may cause unnecessary vMotion constraints." +$Display = "Table" +$Author = "Frederic Martin" +$PluginVersion = 1.2 +$PluginCategory = "vSphere" + # Start of Settings # Find unwanted virtual hardware $unwantedHardware = "VirtualUSBController|VirtualParallelPort|VirtualSerialPort" # End of Settings -#Thanks to @lucd http://communities.vmware.com/message/1546618 -$vUnwantedHw = @() +# Update settings where there is an override +$unwantedHardware = Get-vCheckSetting $Title "unwantedHardware" $unwantedHardware + foreach ($vmguest in $FullVM) { - $vmguest.Config.Hardware.Device | where {$_.GetType().Name -match $unwantedHardware} | %{ - $myObj = "" | select Name,Label - $myObj.Name = $vmguest.name - $myObj.Label = $_.DeviceInfo.Label - $vUnwantedHw += $myObj - } + $vmguest.Config.Hardware.Device | where {$_.GetType().Name -match $unwantedHardware} | %{ + New-Object -TypeName PSObject -Property @{ + Name = $vmguest.name + Label = $_.DeviceInfo.Label + } + } } -$vUnwantedHw | Sort Name +#Thanks to @lucd http://communities.vmware.com/message/1546618 -$Title = "Unwanted virtual hardware found" -$Header = "Unwanted virtual hardware found" -$Comments = "Certain kinds of hardware are unwanted on virtual machines as they may cause unnecessary vMotion constraints." -$Display = "Table" -$Author = "Frederic Martin" -$PluginVersion = 1.1 -$PluginCategory = "vSphere" +# Change Log +## 1.2 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/620 CBT Status.ps1 b/Plugins/60 VM/620 CBT Status.ps1 index 79c489f5..22d08ac5 100644 --- a/Plugins/60 VM/620 CBT Status.ps1 +++ b/Plugins/60 VM/620 CBT Status.ps1 @@ -1,15 +1,20 @@ -# Start of Settings -# End of Settings - -$CBTEnabled = $false - -$VMsCBTStatus = @($FullVm | Where-object {$_.Config.ChangeTrackingEnabled -eq $CBTEnabled} | Select-Object Name, @{Name="Change Block Tracking";Expression={if ($_.Config.ChangeTrackingEnabled) { "enabled" } else { "disabled" }}} | Sort Name) -$VMsCBTStatus - $Title = "VM - Display all VMs with CBT not enabled" -$Header = "VM with CBT disabled : $(@($VMsCBTStatus).Count)" +$Header = "VM with CBT disabled: [count]" $Comments = "List all VMs with CBT status disabled. It's not a good option for backup!" $Display = "Table" $Author = "Cyril Epiney" -$PluginVersion = 1.0 +$PluginVersion = 1.1 $PluginCategory = "vSphere" + +# Start of Settings +# Should CBT be enabled (true/false) +$CBTEnabled = $false +# End of Settings + +# Update settings where there is an override +$CBTEnabled = Get-vCheckSetting $Title "CBTEnabled" $CBTEnabled + +$FullVm | Where-object {$_.Config.ChangeTrackingEnabled -eq $CBTEnabled} | Select-Object Name, @{Name="Change Block Tracking";Expression={if ($_.Config.ChangeTrackingEnabled) { "enabled" } else { "disabled" }}} | Sort Name + +# Change Log +## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/64 Snapshots Oversize.ps1 b/Plugins/60 VM/64 Snapshots Oversize.ps1 index 16166d70..dbb213fd 100644 --- a/Plugins/60 VM/64 Snapshots Oversize.ps1 +++ b/Plugins/60 VM/64 Snapshots Oversize.ps1 @@ -1,45 +1,35 @@ +$Title = "Snapshots Oversize" +$Header = "Snapshots Oversize" +$Comments = "VMware snapshots which are kept for a long period of time may cause issues, filling up datastores and also may impact performance of the virtual machine." +$Display = "Table" +$Author = "Raphael Schitz, Shawn Masterson" +$PluginVersion = 1.4 +$PluginCategory = "vSphere" + # Start of Settings # End of Settings -# Changelog -## 1.3 : Rewritten to cleanup and compare vmdk size to only snapshot size - $snapp = @() -Foreach ($vmg in $VM) { - If ($vmg.ExtensionData.Snapshot) { - $hddsize = 0 - ForEach ($DISK in ($vmg|Get-HardDisk)) { # Loop through VM's harddisks - $hddsize = $hddsize+[math]::round($DISK.CapacityKB/1048576, 0) - } - $snaps = $vmg | Get-Snapshot - $snapsize = 0 - ForEach ($snap in $snaps) { # Loop through VM's snapshots - $snapsize = $snapsize+[math]::round($snap.SizeGB, 0) - } - $oversize = [math]::round((((($snapsize + $hddsize)*100)/$hddsize)-100), 0) - $snappObj = "" | Select VM,vmdkSizeGB,SnapSizeGB,SnapCount,OverSize - $snappObj.VM = $vmg.Name - $snappObj.vmdkSizeGB = $hddsize - $snappObj.SnapSizeGB = $snapsize - $snappObj.SnapCount = $snaps.count - if ($hddsize -eq 0) { - $snappObj.OverSize = "Linked Clone" - } else { - $snappObj.OverSize = $oversize - } - $snapp += $snappObj - } -} - -$snapp | select VM, vmdkSizeGB, SnapSizeGB, SnapCount, @{N="OverSize %";E={$_.OverSize}} | sort "OverSize %" -Descending - +Foreach ($vmg in ($VM | Where {$_.ExtensionData.Snapshot})) { + $hddsize = ($vmg | Get-HardDisk | Measure-Object -sum CapacityGB).sum + $snapInfo = $vmg | Get-Snapshot | Measure-Object -Sum SizeGB + $oversize = [math]::round((((($snapInfo.Sum + $hddsize)*100)/$hddsize)-100), 2) + if ($hddsize -eq 0) { + $overSize = "Linked Clone" + } + + New-Object -TypeName PSObject -Property ([ordered]@{ + VM = $vmg.Name + vmdkSizeGB = [math]::round($hddsize,2) + SnapSizeGB = [math]::round($snapInfo.Sum, 2) + SnapCount = $snapInfo.count + "OverSize %" = $oversize + }) + } +$snapp | select VM, vmdkSizeGB, SnapSizeGB, SnapCount, @{N="OverSize %";E={$_.OverSize}} | sort "OverSize %" -Descending -$Title = "Snapshots Oversize" -$Header = "Snapshots Oversize" -$Comments = "VMware snapshots which are kept for a long period of time may cause issues, filling up datastores and also may impact performance of the virtual machine." -$Display = "Table" -$Author = "Raphael Schitz, Shawn Masterson" -$PluginVersion = 1.3 -$PluginCategory = "vSphere" \ No newline at end of file +# Changelog +## 1.3 : Rewritten to cleanup and compare vmdk size to only snapshot size +## 1.4 : Code refactor \ No newline at end of file diff --git a/Plugins/60 VM/66 Misnamed VM.ps1 b/Plugins/60 VM/66 Misnamed VM.ps1 index feac3b43..6b130b43 100644 --- a/Plugins/60 VM/66 Misnamed VM.ps1 +++ b/Plugins/60 VM/66 Misnamed VM.ps1 @@ -1,9 +1,9 @@ $Title = "Mis-named virtual machines" -$Header = "[count] Mis-named virtual machines" +$Header = "Mis-named virtual machines: [count]" $Comments = "The following guest names do not match the name inside of the guest." $Display = "Table" $Author = "Frederic Martin" -$PluginVersion = 1.2 +$PluginVersion = 1.3 $PluginCategory = "vSphere" # Start of Settings @@ -11,6 +11,9 @@ $PluginCategory = "vSphere" $MNDoNotInclude = "VM1_*|VM2_*" # End of Settings +# Update settings where there is an override +$MNDoNotInclude = Get-vCheckSetting $Title "MNDoNotInclude" $MNDoNotInclude + ($FullVM | Where {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name }) | foreach { $vmguest = $_ diff --git a/Plugins/60 VM/76 VM Network State.ps1 b/Plugins/60 VM/76 VM Network State.ps1 index f98c8f10..b023b749 100644 --- a/Plugins/60 VM/76 VM Network State.ps1 +++ b/Plugins/60 VM/76 VM Network State.ps1 @@ -1,29 +1,33 @@ +$Title = "VM Network State" +$Header = "VMs with NIC disconnected: [count]" +$Comments = "Check if all network cards are connected" +$Display = "Table" +$Author = "Cyril Epiney" +$PluginVersion = 1.3 +$PluginCategory = "vSphere" + # Start of Settings # Only show NICs that are set to Connect at Startup $ShowOnlyStartupNICS = $true # End of Settings +# Update settings where there is an override +$ShowOnlyStartupNICS = Get-vCheckSetting $Title "ShowOnlyStartupNICS" $ShowOnlyStartupNICS + $VMsNetworkNotConnected = @() # Check only on powered on VMs foreach ($myVM in $FullVM | ?{$_.runtime.powerState -eq "PoweredOn"}) { - foreach ($myCard in $myVM.config.hardware.device | ?{$_ -is [VMware.Vim.VirtualEthernetCard]} | ?{-Not $_.connectable.connected}) { - if ($ShowOnlyStartupNICS -and $myCard.connectable.StartConnected) { - # The network card is not connected. Warn user - $vmNetworkNotConnected = "" | Select-Object VM, vmNetworkAdapter, State - $vmNetworkNotConnected.VM = $myVM.Name - $vmNetworkNotConnected.vmNetworkAdapter = $myCard.deviceInfo.label - $vmNetworkNotConnected.State = "Disconnected" - $VMsNetworkNotConnected += $vmNetworkNotConnected + foreach ($myCard in $myVM.config.hardware.device | ?{$_ -is [VMware.Vim.VirtualEthernetCard] -and -Not $_.connectable.connected}) { + if ($ShowOnlyStartupNICS -and $myCard.connectable.StartConnected) { + # The network card is not connected. Warn user + New-Object -TypeName PSObject -Property @{ + VM = $myVM.Name + vmNetworkAdapter = $myCard.deviceInfo.label + State = "Disconnected" + } } - } + } } -$VMsNetworkNotConnected - -$Title = "VM - is my network connected?" -$Header = "VM - is my network connected?" -$Comments = "Check if all network cards are connected" -$Display = "Table" -$Author = "Cyril Epiney" -$PluginVersion = 1.2 -$PluginCategory = "vSphere" +# Change Log +## 1.3 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/78 Reset VMs.ps1 b/Plugins/60 VM/78 Reset VMs.ps1 index 04881737..e842b803 100644 --- a/Plugins/60 VM/78 Reset VMs.ps1 +++ b/Plugins/60 VM/78 Reset VMs.ps1 @@ -1,14 +1,22 @@ +$Title = "Reset VMs" +$Display = "Table" +$Author = "James Scholefield" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days to show reset VMs $VMsResetAge = 1 # End of Settings -@(Get-VIEventPlus -Start ((get-date).adddays(-$VMsResetAge)) -EventType "VmResettingEvent" | Select createdTime, UserName, fullFormattedMessage) +# Update settings where there is an override +$VMsResetAge = Get-vCheckSetting $Title "VMsResetAge" $VMsResetAge -$Title = "Reset VMs" -$Header = "VMs Reset (Last $VMsResetAge Day(s)) : [count]" -$Comments = "The following VMs have been reset over the last $($VMsResetAge) days" -$Display = "Table" -$Author = "James Scholefield" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +Get-VIEventPlus -Start ((get-date).adddays(-$VMsResetAge)) -EventType "VmResettingEvent" | Select createdTime, UserName, fullFormattedMessage + +$Header = ("VMs Reset (Last {0} Day(s)) : [count]" -f $VMsResetAge) +$Comments = ("The following VMs have been reset over the last {0} days" -f $VMsResetAge) + +# Change Log +## 1.0 : Initial release +## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 b/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 index 81789561..7d9b307c 100644 --- a/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 +++ b/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 @@ -20,9 +20,8 @@ $pLang = DATA { # Override the default (en) if it exists in lang directory Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLang -ErrorAction SilentlyContinue -$VMFolder = @() $i=0; -foreach ($eachDS in ($Datastores | Where {$_.Accessible})) { +foreach ($eachDS in ($Datastores | Where {$_.State -eq "Available"})) { Write-Progress -ID 2 -Parent 1 -Activity $pLang.pluginActivity -Status ($pLang.pluginStatus -f $i, $Datastores.count, $eachDS.Name) -PercentComplete ($i*100/$Datastores.count) $eachDS.Name $FilePath = $eachDS.DatastoreBrowserPath + '\*\*delta.vmdk*' @@ -31,7 +30,7 @@ foreach ($eachDS in ($Datastores | Where {$_.Accessible})) { $fileList += Get-ChildItem -Path "$FilePath" | Select Name, FolderPath, FullName $i++ - + foreach ($vmFile in $filelist | sort FolderPath) { $vmFile.FolderPath -match '^\[([^\]]+)\] ([^/]+)' > $null @@ -40,13 +39,12 @@ foreach ($eachDS in ($Datastores | Where {$_.Accessible})) { if (!$eachVM.snapshot) { # Only process VMs without snapshots - $Details = "" | Select-Object VM, Datacenter, Path - $Details.VM = $eachVM.Name - $Details.Datacenter = $eachDS.Datacenter - $Details.Path = $vmFile.FullName - $VMFolder += $Details + New-Object -TypeName PSObject -Property @{ + VM = $eachVM.Name + Datacenter = $eachDS.Datacenter + Path = $vmFile.FullName + } } } } -Write-Progress -ID 1 -Activity $pLang.pluginActivity -Status $pLang.Complete -Completed -$VMFolder | sort VM +Write-Progress -ID 1 -Activity $pLang.pluginActivity -Status $pLang.Complete -Completed \ No newline at end of file diff --git a/Plugins/60 VM/85 Snapshot Activity.ps1 b/Plugins/60 VM/85 Snapshot Activity.ps1 index 9d3ccf70..019209d1 100644 --- a/Plugins/60 VM/85 Snapshot Activity.ps1 +++ b/Plugins/60 VM/85 Snapshot Activity.ps1 @@ -1,3 +1,10 @@ +$Title = "Snapshot activity" +$Header = "Snapshot activity " +$Display = "Table" +$Author = "Chris Monahan, but is a minor mod of two plugins by Raphael Schitz and Frederic Martin" +$PluginVersion = 1.1 +$PluginCategory = "vSphere" + # Start of Settings # Set the number of days to show Snapshots for $VMsNewRemovedAge = 5 @@ -5,15 +12,16 @@ $VMsNewRemovedAge = 5 $snapshotUserException = "s-veeam" # End of Settings +# Update settings where there is an override +$VMsNewRemovedAge = Get-vCheckSetting $Title "VMsNewRemovedAge" $VMsNewRemovedAge +$snapshotUserException = Get-vCheckSetting $Title "snapshotUserException" $snapshotUserException + Get-VIEventPlus -Start ((get-date).adddays(- $VMsNewRemovedAge)) -EventType "TaskEvent" | ? { $_.FullFormattedMessage -match "snapshot" -and $_.userName -notmatch $snapshotUserException } | Select @{ N = "Created Time"; E = { ($_.createdTime).ToLocalTime() } }, @{ N = "User"; E = { $_.userName } }, @{ N = "VM Name"; E = { $_.vm.name } }, @{ N = "Description"; E = { $_.FullFormattedMessage } } | sort "VM Name", "Created Time" -$Title = "Snapshot activity" -$Header = "Snapshot activity (Last $VMsNewRemovedAge Day(s)) (with user exception $snapshotUserException)" -$Comments = "" -$Display = "Table" -$Author = "Chris Monahan, but is a minor mod of two plugins by Raphael Schitz and Frederic Martin" -$PluginVersion = 1.0 -$PluginCategory = "vSphere" +$Comments = ("Last {0} Day(s) with user exception {1}" -f $VMsNewRemovedAge, $snapshotUserException) # This is a consolidation of "65 Snapshot Created.ps1" and "63 Snapshot Removed.ps1", by both Raphael Schitz and Frederic Martin. # Shows snapshot activity by listing any task with the word "snapshot" in it, sorting by VM name then time of task creation. + +# Change Log +## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/80 Finish/999 VeryLastPlugin Used to Disconnect.ps1 b/Plugins/80 Finish/999 VeryLastPlugin Used to Disconnect.ps1 index fd07f9c7..7be15e7c 100644 --- a/Plugins/80 Finish/999 VeryLastPlugin Used to Disconnect.ps1 +++ b/Plugins/80 Finish/999 VeryLastPlugin Used to Disconnect.ps1 @@ -3,9 +3,11 @@ # Everything in this script will run at the end of vCheck If ($VIConnection) { - $VIConnection | Disconnect-VIServer -Confirm:$false + $VIConnection | Disconnect-VIServer -Confirm:$false | Out-Null } +Write-Output "" + $Title = "Disconnecting from vCenter" $Header = "Disconnects from vCenter" $Comments = "Disconnect plugin" From 8552abde5a3d9e609632da3960b5e2b1bf2ff23f Mon Sep 17 00:00:00 2001 From: thebillness Date: Thu, 5 Jan 2017 11:21:53 -0600 Subject: [PATCH 36/50] Create 29 AD Authentication.ps1 Created a new plugin to display Active Directory settings and domain membership status. --- Plugins/30 Host/29 AD Authentication.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Plugins/30 Host/29 AD Authentication.ps1 diff --git a/Plugins/30 Host/29 AD Authentication.ps1 b/Plugins/30 Host/29 AD Authentication.ps1 new file mode 100644 index 00000000..9c2725c6 --- /dev/null +++ b/Plugins/30 Host/29 AD Authentication.ps1 @@ -0,0 +1,12 @@ +# Start of Settings +# End of Settings + +@($VMH | Where-Object {$_.ExtensionData.Summary.Config.Product.Name -eq 'VMware ESXi'} | Select-Object Name,@{Name='Domain';Expression = {($_ | Get-VMHostAuthentication).Domain}},@{Name='MembershipStatus';Expression = {($_ | Get-VMHostAuthentication).DomainMembershipStatus}},@{Name='AdminGroup';Expression = {($_ | Get-AdvancedSetting -Name "Config.HostAgent.plugins.hostsvc.esxAdminsGroup").Value}}) + +$PluginCategory = "vSphere" +$Title = "Active Directory Authentication" +$Header = "Active Directory Authentication" +$Comments = "Active Directory configuration and status for each host." +$Display = "Table" +$Author = "Bill Wall" +$PluginVersion = 1.0 From aa1b0f8e5415748860376c7a1b68eab68610beee Mon Sep 17 00:00:00 2001 From: Bill Wall Date: Fri, 6 Jan 2017 09:19:58 -0600 Subject: [PATCH 37/50] New features for AD Authentication Plugin Added expected AD Domain Name and AD Admin Group settings. Added setting to display all results. By default only displays failed results. Improved performance. Run time cut by 2/3 in test environment. --- Plugins/30 Host/29 AD Authentication.ps1 | 34 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Plugins/30 Host/29 AD Authentication.ps1 b/Plugins/30 Host/29 AD Authentication.ps1 index 9c2725c6..e1257bca 100644 --- a/Plugins/30 Host/29 AD Authentication.ps1 +++ b/Plugins/30 Host/29 AD Authentication.ps1 @@ -1,12 +1,40 @@ # Start of Settings +# Show "OK" results? +$ADDisplayOK = $false +# Expected Domain name +$ADDomainName = "mydomain.local" +# Expected Admin Group +$ADAdminGroup = "ESX Admins" # End of Settings -@($VMH | Where-Object {$_.ExtensionData.Summary.Config.Product.Name -eq 'VMware ESXi'} | Select-Object Name,@{Name='Domain';Expression = {($_ | Get-VMHostAuthentication).Domain}},@{Name='MembershipStatus';Expression = {($_ | Get-VMHostAuthentication).DomainMembershipStatus}},@{Name='AdminGroup';Expression = {($_ | Get-AdvancedSetting -Name "Config.HostAgent.plugins.hostsvc.esxAdminsGroup").Value}}) +#Init arrays +$ADFailedHosts = @() +$ADOKHosts = @() + +ForEach ($ADHost in $VMH) { + # Get authetication settings + $myADAuth = $ADHost | Get-VMHostAuthentication + # Get Admin Group settings + $myADGroup = ($ADHost | Get-AdvancedSetting -Name "Config.HostAgent.plugins.hostsvc.esxAdminsGroup").Value + # Build array item + $myADHost = $ADHost | Select-Object Name,@{Name='Domain';Expression = {$myADAuth.Domain}},@{Name='MembershipStatus';Expression = {$myADAuth.DomainMembershipStatus}},@{Name='AdminGroup';Expression = {$myADGroup}} + # Iterate tests, a single failure constitues a failure for the unit + If ($myADAuth.Domain -ne $ADDomainName) {$ADFailedHosts += $myADHost } #Configured domain does not equal expected + ElseIf ($myADGroup -ne $ADAdminGroup) {$ADFailedHosts += $myADHost} #Configured Admin Group does not equal expected + ElseIf ($myADAuth.DomainMembershipStatus -ne "OK") {$ADFailedHosts += $myADHost} #Domain Memebership is in doubt + Else {$ADOKHosts += $myADHost} #Configuration passed all tests +} + +# If desired, add OK hosts to display after failed hosts +If ($ADDisplayOK) {$ADFailedHosts += $ADOKHosts} + +# Provide output +$ADFailedHosts $PluginCategory = "vSphere" $Title = "Active Directory Authentication" $Header = "Active Directory Authentication" -$Comments = "Active Directory configuration and status for each host." +$Comments = "Active Directory configuration and status for each host. (Domain: $ADDomainName, Admin Group: $ADAdminGroup, Display all results: $ADDisplayOK)" $Display = "Table" $Author = "Bill Wall" -$PluginVersion = 1.0 +$PluginVersion = 1.1 From 606e111b539938f6e36f0d4395ec2e89f7d74799 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Fri, 27 Jan 2017 07:45:34 +1100 Subject: [PATCH 38/50] Replaced Implementation Types with non-Impl types Manually merging changes from Pull #528 --- Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index fd0667ab..e8137e26 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -101,7 +101,7 @@ Write-CustomOut $pLang.custAttr function Get-VMLastPoweredOffDate { param([Parameter(Mandatory=$true,ValueFromPipeline=$true)] - [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm) + [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $vm) process { $Report = "" | Select-Object -Property Name,LastPoweredOffDate $Report.Name = $_.Name @@ -114,7 +114,7 @@ function Get-VMLastPoweredOffDate { function Get-VMLastPoweredOnDate { param([Parameter(Mandatory=$true,ValueFromPipeline=$true)] - [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm) + [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $vm) process { $Report = "" | Select-Object -Property Name,LastPoweredOnDate @@ -223,7 +223,7 @@ if ($VIVersion -ge 5) { function Get-VIEventPlus { param( - [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, + [VMware.VimAutomation.ViCore.Types.V1.Inventory.InventoryItem[]]$Entity, [string[]]$EventType, [DateTime]$Start, [DateTime]$Finish = (Get-Date), From 96f7ee76db4c482bab9aad7a919ba3e4563aca34 Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Tue, 31 Jan 2017 22:42:04 -0800 Subject: [PATCH 39/50] Starting to update for PowerCLI Core Starting to make changes to make it work on PowerCLI Core for Mac and Linux --- vCheck.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vCheck.ps1 b/vCheck.ps1 index 4cfc43c5..440ad4e6 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -815,14 +815,14 @@ if ($job) { } # if no valid plugins specified, fall back to default if (!$vCheckPlugins) { - $vCheckPlugins = Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | Sort FullName + $vCheckPlugins = Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | Sort-Object FullName } } else { $ToNatural = { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } - $vCheckPlugins = @(Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | where { $_.Directory -match "initialize" } | Sort $ToNatural) + $vCheckPlugins = @(Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | where { $_.Directory -match "initialize" } | Sort-Object $ToNatural) $PluginsSubFolder = Get-ChildItem -Path $PluginsFolder | where { ($_.PSIsContainer) -and ($_.Name -notmatch "initialize") -and ($_.Name -notmatch "finish") } - $vCheckPlugins += $PluginsSubFolder | % { Get-ChildItem -Path $_.FullName -filter "*.ps1" | Sort $ToNatural } - $vCheckPlugins += Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | where { $_.Directory -match "finish" } | Sort $ToNatural + $vCheckPlugins += $PluginsSubFolder | % { Get-ChildItem -Path $_.FullName -filter "*.ps1" | Sort-Object $ToNatural } + $vCheckPlugins += Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | where { $_.Directory -match "finish" } | Sort-Object $ToNatural $GlobalVariables = $ScriptPath + "\GlobalVariables.ps1" } @@ -958,7 +958,7 @@ if (-not $GUIConfig) { } if ($ListEnabledPluginsFirst) { - $Plugins = $Plugins | Sort -property @{ Expression = "Enabled"; Descending = $true } + $Plugins = $Plugins | Sort-Object -property @{ Expression = "Enabled"; Descending = $true } $Comments = "Plugins in numerical order, enabled plugins listed first" } From 1ef2c77b76f42fca407a4ed7eb2a154311487aed Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Tue, 31 Jan 2017 22:46:27 -0800 Subject: [PATCH 40/50] Starting to update for PowerCLI Core More changes to make it work on PowerCLI Core for Mac and Linux --- .../00 Connection Plugin for vCenter.ps1 | 96 +++++++++++++++---- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index 39868ef5..f3acca8d 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -1,6 +1,6 @@ $Title = "Connection settings for vCenter" $Author = "Alan Renouf" -$PluginVersion = 1.10 +$PluginVersion = 1.20 $Header = "Connection Settings" $Comments = "Connection Plugin for connecting to vSphere" $Display = "None" @@ -60,28 +60,86 @@ $Credfile = $ScriptPath + "\Windowscreds.xml" # 2) Module + PSSnapin (-gt 5.8R1/-lt 6.5R1) # 3) Module (-ge 6.5R1) -$pcliCore = 'VMware.VimAutomation.Core' - -$pssnapinPresent = $false -$psmodulePresent = $false - -if(Get-Module -Name $pcliCore -ListAvailable){ - $psmodulePresent = $true - if(!(Get-Module -Name $pcliCore)){ - Import-Module -Name $pcliCore +function Get-CorePlatform { + [cmdletbinding()] + param() + #Thanks to @Lucd22 (Lucd.info) for this great function! + $osDetected = $false + try{ + $os = Get-CimInstance -ClassName Win32_OperatingSystem + Write-Verbose -Message 'Windows detected' + $osDetected = $true + $osFamily = 'Windows' + $osName = $os.Caption + $osVersion = $os.Version + $nodeName = $os.CSName + $architecture = $os.OSArchitecture + } + catch{ + Write-Verbose -Message 'Possibly Linux or Mac' + $uname = "$(uname)" + if($uname -match '^Darwin|^Linux'){ + $osDetected = $true + $osFamily = $uname + $osName = "$(uname -v)" + $osVersion = "$(uname -r)" + $nodeName = "$(uname -n)" + $architecture = "$(uname -p)" + } + # Other + else + { + Write-Warning -Message "Kernel $($uname) not covered" + } + } + [ordered]@{ + OSDetected = $osDetected + OSFamily = $osFamily + OS = $osName + Version = $osVersion + Hostname = $nodeName + Architecture = $architecture } } -if(Get-PSSnapin -Name $pcliCore -Registered -ErrorAction SilentlyContinue){ - $pssnapinPresent = $true - if(!(Get-PSSnapin -Name $pcliCore -ErrorAction SilentlyContinue)){ - Add-PSSnapin -Name $pcliCore +$Platform = Get-CorePlatform +switch ($platform.OSFamily) { + "Darwin" { + $templocation = "/tmp" + $Outputpath = $templocation + Get-Module -ListAvailable PowerCLI* | Import-Module } -} + "Linux" { + $Outputpath = $templocation + $templocation = "/tmp" + Get-Module -ListAvailable PowerCLI* | Import-Module + } + "Windows" { + $templocation = "$ENV:Temp" + $pcliCore = 'VMware.VimAutomation.Core' -if(!$pssnapinPresent -and !$psmodulePresent){ - Write-Error "Can't find PowerCLI. Is it installed?" - return + $pssnapinPresent = $false + $psmodulePresent = $false + + if(Get-Module -Name $pcliCore -ListAvailable){ + $psmodulePresent = $true + if(!(Get-Module -Name $pcliCore)){ + Import-Module -Name $pcliCore + } + } + + if(Get-PSSnapin -Name $pcliCore -Registered -ErrorAction SilentlyContinue){ + $pssnapinPresent = $true + if(!(Get-PSSnapin -Name $pcliCore -ErrorAction SilentlyContinue)){ + Add-PSSnapin -Name $pcliCore + } + } + + if(!$pssnapinPresent -and !$psmodulePresent){ + Write-Error "Can't find PowerCLI. Is it installed?" + return + } + } } $OpenConnection = $global:DefaultVIServers | where { $_.Name -eq $VIServer } @@ -290,4 +348,4 @@ function Get-VIEventPlus { $events } -} \ No newline at end of file +} From d32553383070aa22542392d95685228a5648acaa Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Tue, 31 Jan 2017 22:53:50 -0800 Subject: [PATCH 41/50] Starting to update for PowerCLI Core Making more changes to make it work on PowerCLI Core for Mac and Linux --- .../00 Connection Plugin for vCenter.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index 39868ef5..bee906cb 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -141,13 +141,13 @@ New-VIProperty -Name "HWVersion" -ObjectType VirtualMachine -Value { } -BasedOnExtensionProperty "Config.Version" -Force | Out-Null Write-CustomOut $pLang.collectVM -$VM = Get-VM | Sort Name +$VM = Get-VM | Sort-Object Name Write-CustomOut $pLang.collectHost -$VMH = Get-VMHost | Sort Name +$VMH = Get-VMHost | Sort-Object Name Write-CustomOut $pLang.collectCluster -$Clusters = Get-Cluster | Sort Name +$Clusters = Get-Cluster | Sort-Object Name Write-CustomOut $pLang.collectDatastore -$Datastores = Get-Datastore | Sort Name +$Datastores = Get-Datastore | Sort-Object Name Write-CustomOut $pLang.collectDVM $FullVM = Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} Write-CustomOut $pLang.collectTemplate @@ -267,8 +267,8 @@ function Get-VIEventPlus { $schTskMgr = Get-View $si.Content.ScheduledTaskManager $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | where {$_.Info.Name -match $ScheduledTask} | - Select -First 1 | - Select -ExpandProperty MoRef + Select-Object -First 1 | + Select-Object -ExpandProperty MoRef } if(!$Entity){ $Entity = @(Get-Folder -NoRecursion) @@ -290,4 +290,4 @@ function Get-VIEventPlus { $events } -} \ No newline at end of file +} From 922b5d4d1ec0243e4720131584c79bc2e8b50fd7 Mon Sep 17 00:00:00 2001 From: Bill Wall Date: Tue, 7 Feb 2017 14:40:28 -0600 Subject: [PATCH 42/50] Create 49 EVC Mismatch.ps1 Created a script to compare the EVC mode of the VM with the EVC mode of the cluster. For VMs which do not match the cluster, output the VM name, VM EVC, Host name, Host EVC and Cluster name. --- Plugins/60 VM/49 EVC Mismatch.ps1 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Plugins/60 VM/49 EVC Mismatch.ps1 diff --git a/Plugins/60 VM/49 EVC Mismatch.ps1 b/Plugins/60 VM/49 EVC Mismatch.ps1 new file mode 100644 index 00000000..059e91bd --- /dev/null +++ b/Plugins/60 VM/49 EVC Mismatch.ps1 @@ -0,0 +1,28 @@ +# Start of Settings +# End of Settings + +# Init arrays +$EVCMismatchedVMs = @() + +# For Each Host +ForEach ($EVCHost in $VMH) { + ## Get cluster EVC mode + $myHostEVCMode = $EVCHost.Parent.EVCMode + + ## Get cluster name + $myHostEVCCluster = $EVCHost.Parent.Name + + ## Get VMs on current host | Filter by Powered On and VM EVC not equal to host EVC | Select VM, Host and Cluster information and concatenate into array + $EVCMismatchedVMs += Get-VM -Location $EVCHost | Where-Object {($_.PowerState -eq "PoweredOn") -and ($_.ExtensionData.Summary.Runtime.MinRequiredEVCModeKey -ne $myHostEVCMode)} | Select-Object Name,@{Name='VM EVC';Expression = {$_.ExtensionData.Summary.Runtime.MinRequiredEVCModeKey}},@{Name='Host';Expression = {$EVCHost.Name}},@{Name='Host EVC';Expression = {$myHostEVCMode}},@{Name='Cluster';Expression = {$myHostEVCCluster}} +} + +# Display completed array +$EVCMismatchedVMs + +$PluginCategory = "vSphere" +$Title = "EVC Mismatch" +$Header = "EVC Mismatch" +$Comments = "List of VMs for which the EVC mode does not match the Host/Cluster. This can negatively impact performance." +$Display = "Table" +$Author = "Bill Wall" +$PluginVersion = 1.0 From bac40405a1543884e0e393dcb1ea1393538e8ad5 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Wed, 8 Feb 2017 09:08:54 +1100 Subject: [PATCH 43/50] Slight changes Removing unnecessary array. --- Plugins/60 VM/49 EVC Mismatch.ps1 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Plugins/60 VM/49 EVC Mismatch.ps1 b/Plugins/60 VM/49 EVC Mismatch.ps1 index 059e91bd..90421dab 100644 --- a/Plugins/60 VM/49 EVC Mismatch.ps1 +++ b/Plugins/60 VM/49 EVC Mismatch.ps1 @@ -1,9 +1,6 @@ # Start of Settings # End of Settings -# Init arrays -$EVCMismatchedVMs = @() - # For Each Host ForEach ($EVCHost in $VMH) { ## Get cluster EVC mode @@ -13,12 +10,9 @@ ForEach ($EVCHost in $VMH) { $myHostEVCCluster = $EVCHost.Parent.Name ## Get VMs on current host | Filter by Powered On and VM EVC not equal to host EVC | Select VM, Host and Cluster information and concatenate into array - $EVCMismatchedVMs += Get-VM -Location $EVCHost | Where-Object {($_.PowerState -eq "PoweredOn") -and ($_.ExtensionData.Summary.Runtime.MinRequiredEVCModeKey -ne $myHostEVCMode)} | Select-Object Name,@{Name='VM EVC';Expression = {$_.ExtensionData.Summary.Runtime.MinRequiredEVCModeKey}},@{Name='Host';Expression = {$EVCHost.Name}},@{Name='Host EVC';Expression = {$myHostEVCMode}},@{Name='Cluster';Expression = {$myHostEVCCluster}} + Get-VM -Location $EVCHost | Where-Object {($_.PowerState -eq "PoweredOn") -and ($_.ExtensionData.Summary.Runtime.MinRequiredEVCModeKey -ne $myHostEVCMode)} | Select-Object Name,@{Name='VM EVC';Expression = {$_.ExtensionData.Summary.Runtime.MinRequiredEVCModeKey}},@{Name='Host';Expression = {$EVCHost.Name}},@{Name='Host EVC';Expression = {$myHostEVCMode}},@{Name='Cluster';Expression = {$myHostEVCCluster}} } -# Display completed array -$EVCMismatchedVMs - $PluginCategory = "vSphere" $Title = "EVC Mismatch" $Header = "EVC Mismatch" From 3892b33cc39f53398cc08f8f337cf6d0e20f266f Mon Sep 17 00:00:00 2001 From: Sneddo Date: Fri, 24 Feb 2017 11:46:56 +1100 Subject: [PATCH 44/50] More updates to remove aliases - better support for PowerCLI core --- .../00 Connection Plugin for vCenter.ps1 | 8 +++--- .../00 Initialize/01 General Information.ps1 | 8 +++--- Plugins/10 vCenter/23 VI Events.ps1 | 2 +- Plugins/10 vCenter/41 vCenter Services.ps1 | 10 +++---- .../42 Windows vCenter Error Event Logs.ps1 | 8 +++--- .../42 Windows vCenter Event Logs.ps1 | 8 +++--- .../43 Windows vCenter Warning Event Logs.ps1 | 8 +++--- Plugins/10 vCenter/47 vCenter Session Age.ps1 | 6 ++--- Plugins/10 vCenter/82 License Report.ps1 | 8 +++--- .../20 Cluster/10 HA Configuration Issues.ps1 | 2 +- .../104 Clusters with no Host Profile.ps1 | 4 +-- Plugins/20 Cluster/17 DRS Migrations.ps1 | 4 +-- .../38 Cluster Configuration Issues.ps1 | 2 +- .../20 Cluster/52 Datastore Consistency.ps1 | 6 ++--- .../20 Cluster/70 Cluster Node Version.ps1 | 4 +-- Plugins/20 Cluster/71 Capacity Planning.ps1 | 6 ++--- .../20 Cluster/72 s-vMotion Information.ps1 | 4 +-- ... More RAM than free space on Datastore.ps1 | 6 ++--- Plugins/20 Cluster/75 DRS Rules.ps1 | 8 +++--- Plugins/30 Host/07 Hosts Overcommit State.ps1 | 2 +- Plugins/30 Host/08 Hosts Dead LUN Path.ps1 | 2 +- .../30 Host/105 Host Profile Compliance.ps1 | 14 +++++----- .../110 Host Certificate Expiration Check.ps1 | 2 +- .../30 Host/16 Host Swapfile datastores.ps1 | 2 +- ...Xi with Technical Support mode enabled.ps1 | 4 +-- ...hich do not have Lockdown mode enabled.ps1 | 4 +-- Plugins/30 Host/31 NTP Name and Service.ps1 | 2 +- .../30 Host/35 Host Configuration Issues.ps1 | 2 +- Plugins/30 Host/36 Host Alarms.ps1 | 6 ++--- Plugins/30 Host/44 VMKernel Warnings.ps1 | 10 +++---- Plugins/30 Host/46 Missing ESX patches.ps1 | 4 +-- .../53 Hardware status warnings-errors.ps1 | 4 +-- Plugins/30 Host/67 Host OS Pivot Table.ps1 | 2 +- Plugins/30 Host/68 Disk Max Total Latency.ps1 | 2 +- .../74 Host - Network Redundancy lost.ps1 | 4 +-- Plugins/30 Host/81 LUN Paths Check.ps1 | 2 +- .../109 Orphaned VMDK File.ps1.disabled | 2 +- ... Datastore Clusters with sDRS Disabled.ps1 | 4 +-- .../116 sDRS VM Behavior not Default.ps1 | 4 +-- .../34 Number of VMs per Datastore.ps1 | 2 +- .../69 Datastores in Maintenance mode.ps1 | 2 +- .../70 Datastores with Alarms Disabled.ps1 | 2 +- ...24 vSwitch with less than x Ports Free.ps1 | 2 +- Plugins/50 Network/98 vSwitch Security.ps1 | 2 +- Plugins/60 VM/02 Snapshot Information.ps1 | 6 ++--- Plugins/60 VM/04 Map disk region event.ps1 | 2 +- Plugins/60 VM/09 Created or cloned VMs.ps1 | 2 +- Plugins/60 VM/10 Removed VMs.ps1 | 2 +- ...00 VMs with CPU or Memory Reservations.ps1 | 2 +- Plugins/60 VM/102 VM Logging.ps1 | 4 +-- Plugins/60 VM/106 Find Phantom Snapshots.ps1 | 2 +- Plugins/60 VM/11 VMs with over CPU Count.ps1 | 2 +- Plugins/60 VM/114 VM Tools Not Up to Date.ps1 | 4 +-- .../60 VM/12 VMs Swapping or Ballooning.ps1 | 2 +- Plugins/60 VM/120 Multi-writer.ps1 | 4 +-- ... BusSharingMode - Physical and Virtual.ps1 | 4 +-- Plugins/60 VM/122 NonPersistent Disks.ps1 | 6 ++--- .../60 VM/13 Invalid or inaccessible VMs.ps1 | 4 +-- ...14 VMs restarted due to Guest OS Error.ps1 | 2 +- .../19 Guests with less than X MB free.ps1 | 2 +- .../60 VM/200 VMs on ephemeral portgroup.ps1 | 4 +-- .../60 VM/201 VMs Hot Add Configuration.ps1 | 2 +- Plugins/60 VM/26 No VM Tools.ps1 | 2 +- Plugins/60 VM/27 VM Tools Issues.ps1 | 2 +- .../60 VM/28 Removable Media Connected.ps1 | 2 +- Plugins/60 VM/30 Single Storage VMs.ps1 | 4 +-- Plugins/60 VM/32 VM CPU Percent RDY.ps1 | 4 +-- Plugins/60 VM/33 VM CPU Usage.ps1 | 2 +- Plugins/60 VM/37 VM Alarms.ps1 | 2 +- Plugins/60 VM/40 VCB Garbage.ps1 | 2 +- .../45 VMs needing snapshot consolidation.ps1 | 2 +- Plugins/60 VM/48 Find VM Disk Format.ps1 | 2 +- ...s with CPU or Memory Limits Configured.ps1 | 2 +- ...chines with incorrect OS Configuration.ps1 | 2 +- ...s with less hard disks than partitions.ps1 | 2 +- Plugins/60 VM/61 Guest OS Pivot table.ps1 | 4 +-- .../60 VM/62 Unwanted Virtual Hardware.ps1 | 2 +- Plugins/60 VM/620 CBT Status.ps1 | 2 +- Plugins/60 VM/64 Snapshots Oversize.ps1 | 4 +-- Plugins/60 VM/66 Misnamed VM.ps1 | 2 +- Plugins/60 VM/78 Reset VMs.ps1 | 2 +- ...Find VMs in Uncontrolled Snapshot Mode.ps1 | 10 +++---- Plugins/60 VM/85 Snapshot Activity.ps1 | 2 +- Plugins/70 Misc/108 SRM RPO Violations.ps1 | 6 ++--- ...s Not up to date or installed.ps1.disabled | 4 +-- Select-Plugins.ps1 | 2 +- Styles/CleanGreen/Style.ps1 | 2 +- Styles/VMware/Style.ps1 | 2 +- vCheck.ps1 | 16 ++++++------ vCheckUtils.ps1 | 26 +++++++++---------- 90 files changed, 186 insertions(+), 186 deletions(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index 72143ff8..1b32f5ad 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -142,7 +142,7 @@ switch ($platform.OSFamily) { } } -$OpenConnection = $global:DefaultVIServers | where { $_.Name -eq $VIServer } +$OpenConnection = $global:DefaultVIServers | Where-Object { $_.Name -eq $VIServer } if($OpenConnection.IsConnected) { Write-CustomOut ( "{0}: {1}" -f $pLang.connReuse, $Server ) $VIConnection = $OpenConnection @@ -207,7 +207,7 @@ $Clusters = Get-Cluster | Sort-Object Name Write-CustomOut $pLang.collectDatastore $Datastores = Get-Datastore | Sort-Object Name Write-CustomOut $pLang.collectDVM -$FullVM = Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} +$FullVM = Get-View -ViewType VirtualMachine | Where-Object {-not $_.Config.Template} Write-CustomOut $pLang.collectTemplate $VMTmpl = Get-Template Write-CustomOut $pLang.collectDVIO @@ -221,7 +221,7 @@ $clusviews = Get-View -ViewType ClusterComputeResource Write-CustomOut $pLang.collectDDatastore $storageviews = Get-View -ViewType Datastore Write-CustomOut $pLang.collectAlarms -$valarms = $alarmMgr.GetAlarm($null) | select value, @{N="name";E={(Get-View -Id $_).Info.Name}} +$valarms = $alarmMgr.GetAlarm($null) | Select-Object value, @{N="name";E={(Get-View -Id $_).Info.Name}} # Find out which version of the API we are connecting to $VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars(0) @@ -324,7 +324,7 @@ function Get-VIEventPlus { $si = Get-View ServiceInstance $schTskMgr = Get-View $si.Content.ScheduledTaskManager $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | - where {$_.Info.Name -match $ScheduledTask} | + Where-Object {$_.Info.Name -match $ScheduledTask} | Select-Object -First 1 | Select-Object -ExpandProperty MoRef } diff --git a/Plugins/00 Initialize/01 General Information.ps1 b/Plugins/00 Initialize/01 General Information.ps1 index f0a7269f..4cc84b17 100644 --- a/Plugins/00 Initialize/01 General Information.ps1 +++ b/Plugins/00 Initialize/01 General Information.ps1 @@ -32,20 +32,20 @@ $Info = New-Object -TypeName PSObject -Property @{ "Number of Templates" = (@($VMTmpl).Count) "Number of Clusters" = (@($Clusters).Count) "Number of Datastores" = (@($Datastores).Count) - "Active VMs" = (@($FullVM | Where { $_.Runtime.PowerState -eq "poweredOn" }).Count) - "In-active VMs" = (@($FullVM | Where { $_.Runtime.PowerState -eq "poweredOff" }).Count) + "Active VMs" = (@($FullVM | Where-Object { $_.Runtime.PowerState -eq "poweredOn" }).Count) + "In-active VMs" = (@($FullVM | Where-Object { $_.Runtime.PowerState -eq "poweredOff" }).Count) } # Don't display DRS line if 0 days are set if ($DRSMigrateAge -gt 0) { - $Info | Add-Member Noteproperty "DRS Migrations for last $($DRSMigrateAge) Days" (@($MigrationQuery1 | Where {$_.GetType().Name -eq "DrsVmMigratedEvent"}).Count) + $Info | Add-Member Noteproperty "DRS Migrations for last $($DRSMigrateAge) Days" (@($MigrationQuery1 | Where-Object {$_.GetType().Name -eq "DrsVmMigratedEvent"}).Count) } # Adding vSphere 5 informations if ($VIVersion -ge 5) { $Info | Add-Member Noteproperty "Number of Datastore Clusters" $(@($DatastoreClustersView).Count) if (($MigrationQuery2) -and ($SDRSMigrateAge -gt 0)) { - $Info | Add-Member Noteproperty "Storage DRS Migrations for last $($SDRSMigrateAge) Days" (@($MigrationQuery2 | Where {$_.FullFormattedMessage -imatch "(Storage vMotion){1}.*(DRS){1}"}).Count) + $Info | Add-Member Noteproperty "Storage DRS Migrations for last $($SDRSMigrateAge) Days" (@($MigrationQuery2 | Where-Object {$_.FullFormattedMessage -imatch "(Storage vMotion){1}.*(DRS){1}"}).Count) } } diff --git a/Plugins/10 vCenter/23 VI Events.ps1 b/Plugins/10 vCenter/23 VI Events.ps1 index 3c1ae955..f90bd261 100644 --- a/Plugins/10 vCenter/23 VI Events.ps1 +++ b/Plugins/10 vCenter/23 VI Events.ps1 @@ -10,6 +10,6 @@ $PluginCategory = "vSphere" $VCEventAge = 1 # End of Settings -Get-VIEventPlus -Start ($Date).AddDays(-$VCEventAge ) -EventType Error | Select @{N="Host";E={$_.host.name}}, createdTime, @{N="User";E={($_.userName.split("\"))[1]}}, fullFormattedMessage +Get-VIEventPlus -Start ($Date).AddDays(-$VCEventAge ) -EventType Error | Select-Object @{N="Host";E={$_.host.name}}, createdTime, @{N="User";E={($_.userName.split("\"))[1]}}, fullFormattedMessage $Header = ("Error Events (Last {0} Day(s)): [count]" -f $VCEventAge) \ No newline at end of file diff --git a/Plugins/10 vCenter/41 vCenter Services.ps1 b/Plugins/10 vCenter/41 vCenter Services.ps1 index 067214db..04559ea9 100644 --- a/Plugins/10 vCenter/41 vCenter Services.ps1 +++ b/Plugins/10 vCenter/41 vCenter Services.ps1 @@ -5,20 +5,20 @@ If (! $VCSA) { If (Test-Path $Credfile) { $LoadedCredentials = Import-Clixml $Credfile $creds = New-Object System.Management.Automation.PsCredential($LoadedCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString)) - $Services = get-wmiobject -Credential $creds win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue| Where {$_.DisplayName -like "VMware*" } + $Services = get-wmiobject -Credential $creds win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue| Where-Object {$_.DisplayName -like "VMware*" } } Else { - $Services = get-wmiobject win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue | Where {$_.DisplayName -like "VMware*" } + $Services = get-wmiobject win32_service -ComputerName $VIServer -ErrorAction SilentlyContinue | Where-Object {$_.DisplayName -like "VMware*" } if ($Error[0].Exception.Message -match "Access is denied.") { # Access Denied Error found so asking to store windows credentials in a file for future use Write-Host "Current windows credentials do not allow for access to WMI on the host $VIServer, please enter Administrator credentials for this check to work, these will be stored in an encrypted file: $credfile" $Credential = Get-Credential $Pass = $credential.Password | ConvertFrom-SecureString $Username = $Credential.UserName - $Store = "" | Select Username, Password + $Store = "" | Select-Object Username, Password $Store.Username = $Username $Store.Password = $Pass $Store | Export-Clixml $credfile - $Services = get-wmiobject win32_service -ComputerName $VIserver -ErrorAction SilentlyContinue | Where {$_.DisplayName -like "VMware*" } + $Services = get-wmiobject win32_service -ComputerName $VIserver -ErrorAction SilentlyContinue | Where-Object {$_.DisplayName -like "VMware*" } } } @@ -68,7 +68,7 @@ If (! $VCSA) { $myCol += $MyDetails } - $Results = $MyCol | Where {$_.Name -ne $null -and $_.Health -ne "OK"} + $Results = $MyCol | Where-Object {$_.Name -ne $null -and $_.Health -ne "OK"} $Results } diff --git a/Plugins/10 vCenter/42 Windows vCenter Error Event Logs.ps1 b/Plugins/10 vCenter/42 Windows vCenter Error Event Logs.ps1 index c6fd08e6..e651c016 100644 --- a/Plugins/10 vCenter/42 Windows vCenter Error Event Logs.ps1 +++ b/Plugins/10 vCenter/42 Windows vCenter Error Event Logs.ps1 @@ -10,20 +10,20 @@ if (! $VCSA){ If (Test-Path $Credfile) { $LoadedCredentials = Import-Clixml $Credfile $creds = New-Object System.Management.Automation.PsCredential($LoadedCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString)) - $WMI = @(Get-WmiObject -cred $creds -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -cred $creds -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) } Else { - $WMI = @(Get-WmiObject -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) if ($Error[0].Exception.Message -match "Access is denied.") { # Access Denied Error found so asking to store windows credentials in a file for future use Write-Host "Current windows credentials do not allow for access to WMI on the host $VIServer, please enter Administrator credentials for this check to work, these will be stored in an encrypted file: $credfile" $Credential = Get-Credential $Pass = $credential.Password | ConvertFrom-SecureString $Username = $Credential.UserName - $Store = "" | Select Username, Password + $Store = "" | Select-Object Username, Password $Store.Username = $Username $Store.Password = $Pass $Store | Export-Clixml $credfile - $WMI = @(Get-WmiObject -cred $Credential -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -cred $Credential -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) } } diff --git a/Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 b/Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 index 6ddd141f..7e3329cf 100644 --- a/Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 +++ b/Plugins/10 vCenter/42 Windows vCenter Event Logs.ps1 @@ -20,20 +20,20 @@ if (! $VCSA){ If (Test-Path $Credfile) { $LoadedCredentials = Import-Clixml $Credfile $creds = New-Object System.Management.Automation.PsCredential($LoadedCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString)) - $WMI = @(Get-WmiObject -cred $creds -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -cred $creds -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) } Else { - $WMI = @(Get-WmiObject -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) if ($Error[0].Exception.Message -match "Access is denied.") { # Access Denied Error found so asking to store windows credentials in a file for future use Write-Host "Current windows credentials do not allow for access to WMI on the host $VIServer, please enter Administrator credentials for this check to work, these will be stored in an encrypted file: $credfile" $Credential = Get-Credential $Pass = $credential.Password | ConvertFrom-SecureString $Username = $Credential.UserName - $Store = "" | Select Username, Password + $Store = "" | Select-Object Username, Password $Store.Username = $Username $Store.Password = $Pass $Store | Export-Clixml $credfile - $WMI = @(Get-WmiObject -cred $Credential -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -cred $Credential -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) } } diff --git a/Plugins/10 vCenter/43 Windows vCenter Warning Event Logs.ps1 b/Plugins/10 vCenter/43 Windows vCenter Warning Event Logs.ps1 index 7010a90d..12b4adc6 100644 --- a/Plugins/10 vCenter/43 Windows vCenter Warning Event Logs.ps1 +++ b/Plugins/10 vCenter/43 Windows vCenter Warning Event Logs.ps1 @@ -6,20 +6,20 @@ If (! $VCSA) { If (Test-Path $Credfile) { $LoadedCredentials = Import-Clixml $Credfile $creds = New-Object System.Management.Automation.PsCredential($LoadedCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString)) - $WMI = @(Get-WmiObject -Credential $creds -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Warning' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue| Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -Credential $creds -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Warning' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue| Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) } Else { - @($WMI = Get-WmiObject -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Warning' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + @($WMI = Get-WmiObject -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Warning' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) if ($Error[0].Exception.Message -match "Access is denied.") { # Access Denied Error found so asking to store windows credentials in a file for future use Write-Host "Current windows credentials do not allow for access to WMI on the host $VIServer, please enter Administrator credentials for this check to work, these will be stored in an encrypted file: $credfile" $Credential = Get-Credential $Pass = $credential.Password | ConvertFrom-SecureString $Username = $Credential.UserName - $Store = "" | Select Username, Password + $Store = "" | Select-Object Username, Password $Store.Username = $Username $Store.Password = $Pass $Store | Export-Clixml $credfile - $WMI = @(Get-WmiObject -Credential $Credential -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Warning' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where {$_.Message -like "*VMware*"} | Select @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) + $WMI = @(Get-WmiObject -Credential $Credential -computer $VIServer -query ("Select * from Win32_NTLogEvent Where Type='Warning' and TimeWritten >='" + $ConvDate + "'") -ErrorAction SilentlyContinue | Where-Object {$_.Message -like "*VMware*"} | Select-Object @{N="TimeGenerated";E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message) } } diff --git a/Plugins/10 vCenter/47 vCenter Session Age.ps1 b/Plugins/10 vCenter/47 vCenter Session Age.ps1 index 7f77af48..61612860 100644 --- a/Plugins/10 vCenter/47 vCenter Session Age.ps1 +++ b/Plugins/10 vCenter/47 vCenter Session Age.ps1 @@ -22,10 +22,10 @@ $vCenterSessionsDoNotInclude = Get-vCheckSetting $Title "vCenterSessionsDoNotInc # Retrieve vCenter sessions and report any sessions that exceed the maximum session age (Get-View $ServiceInstance.Content.SessionManager).SessionList | ` - Where {$_.LoginTime -lt (Get-Date).AddHours(-$MaxvCenterSessionAge) -AND ` + Where-Object {$_.LoginTime -lt (Get-Date).AddHours(-$MaxvCenterSessionAge) -AND ` $_.UserName -notmatch $vCenterSessionsDoNotInclude} | ` - select LoginTime, UserName, FullName, @{N="IdleMinutes";e={([Math]::Round(((Get-Date)-($_.lastActiveTime).ToLocalTime()).TotalMinutes))}} | ` - Where {$_.IdleMinutes -ge $MinvCenterSessionAge} + Select-Object LoginTime, UserName, FullName, @{N="IdleMinutes";e={([Math]::Round(((Get-Date)-($_.lastActiveTime).ToLocalTime()).TotalMinutes))}} | ` + Where-Object {$_.IdleMinutes -ge $MinvCenterSessionAge} $Comments = "The following displays vCenter sessions that exceed the maximum session age ($MaxvCenterSessionAge Hour(s))." diff --git a/Plugins/10 vCenter/82 License Report.ps1 b/Plugins/10 vCenter/82 License Report.ps1 index 95d135f4..7d6ac6ac 100644 --- a/Plugins/10 vCenter/82 License Report.ps1 +++ b/Plugins/10 vCenter/82 License Report.ps1 @@ -11,11 +11,11 @@ $PluginCategory = "vSphere" $vSphereLicInfo = @() -Foreach ($LicenseMan in Get-View ($ServiceInstance | Select -First 1).Content.LicenseManager) +Foreach ($LicenseMan in Get-View ($ServiceInstance | Select-Object -First 1).Content.LicenseManager) { - ($LicenseMan | Select -ExpandProperty Licenses) | Select @{Name="VC";e={([Uri]$LicenseMan.Client.ServiceUrl).Host}}, ` - Name, LicenseKey, Total, Used, @{Name="Information";e={$_.Labels | Select -ExpandProperty Value}}, ` - @{"Name"="ExpirationDate";e={$_.Properties | Where { $_.key -eq "expirationDate" } | Select -ExpandProperty Value}} + ($LicenseMan | Select-Object -ExpandProperty Licenses) | Select-Object @{Name="VC";e={([Uri]$LicenseMan.Client.ServiceUrl).Host}}, ` + Name, LicenseKey, Total, Used, @{Name="Information";e={$_.Labels | Select-Object -ExpandProperty Value}}, ` + @{"Name"="ExpirationDate";e={$_.Properties | Where-Object { $_.key -eq "expirationDate" } | Select-Object -ExpandProperty Value}} } # Changelog diff --git a/Plugins/20 Cluster/10 HA Configuration Issues.ps1 b/Plugins/20 Cluster/10 HA Configuration Issues.ps1 index 4481059a..f7d1272d 100644 --- a/Plugins/20 Cluster/10 HA Configuration Issues.ps1 +++ b/Plugins/20 Cluster/10 HA Configuration Issues.ps1 @@ -41,7 +41,7 @@ $HAIssues += $Clusters | Where-Object {$_.Name -notmatch $ClustersDoNotInclude - Select-Object @{Name="Cluster";Expression={$_.Name}},@{Name="Configuration Issue";Expression={$pLang.HADisabled}} # Clusters with host monitoring disabled -$HAIssues += $clusviews | where {$_.Name -notmatch $ClustersDoNotInclude -and ( $_.Configuration.DasConfig.HostMonitoring -eq "enabled" ) -ne $ClusterHAHostMonitoringShouldBeEnabled } | +$HAIssues += $clusviews | Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and ( $_.Configuration.DasConfig.HostMonitoring -eq "enabled" ) -ne $ClusterHAHostMonitoringShouldBeEnabled } | Select-Object @{Name="Cluster";Expression={$_.Name}}, @{N="Configuration Issue";E={$pLang.HAMonDisabled}} # Clusters with admission Control Disabled diff --git a/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 b/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 index 5b48cf87..5d26a28e 100644 --- a/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 +++ b/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 @@ -10,6 +10,6 @@ $PluginCategory = "vSphere" # End of Settings # Get all host profiles and corresponding cluster ID (don't really care about individual hosts at this stage!) -$HostProfiles = Get-VMHostProfile | Select Name, @{Name="ClusterID";Expression={$_.ExtensionData.Entity | ?{ $_.type -eq "ClusterComputeResource" }}} +$HostProfiles = Get-VMHostProfile | Select-Object Name, @{Name="ClusterID";Expression={$_.ExtensionData.Entity | ?{ $_.type -eq "ClusterComputeResource" }}} -$clusviews | ?{($HostProfiles | Select -expandProperty ClusterID) -notcontains $_.moref } | Sort-Object Name | Select Name \ No newline at end of file +$clusviews | ?{($HostProfiles | Select-Object -expandProperty ClusterID) -notcontains $_.moref } | Sort-Object Name | Select-Object Name \ No newline at end of file diff --git a/Plugins/20 Cluster/17 DRS Migrations.ps1 b/Plugins/20 Cluster/17 DRS Migrations.ps1 index 3a0a565b..68089dcd 100644 --- a/Plugins/20 Cluster/17 DRS Migrations.ps1 +++ b/Plugins/20 Cluster/17 DRS Migrations.ps1 @@ -33,8 +33,8 @@ if (-not $MigrationQuery1) } } -$DRSMigrations = @($MigrationQuery1 | Where {$_.Gettype().Name -eq "DrsVmMigratedEvent"} | Select createdTime, fullFormattedMessage) -$SDRSMigrations = @($MigrationQuery2 | Where {$_.FullFormattedMessage -imatch "(Storage vMotion){1}.*(DRS){1}"} | Select createdTime, fullFormattedMessage) +$DRSMigrations = @($MigrationQuery1 | Where-Object {$_.Gettype().Name -eq "DrsVmMigratedEvent"} | Select-Object createdTime, fullFormattedMessage) +$SDRSMigrations = @($MigrationQuery2 | Where-Object {$_.FullFormattedMessage -imatch "(Storage vMotion){1}.*(DRS){1}"} | Select-Object createdTime, fullFormattedMessage) $DRSMigrations $SDRSMigrations diff --git a/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 b/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 index 30279cbc..c64fb860 100644 --- a/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 +++ b/Plugins/20 Cluster/38 Cluster Configuration Issues.ps1 @@ -22,4 +22,4 @@ foreach ($clusview in $clusviews) { } } -$clualarms | sort name \ No newline at end of file +$clualarms | Sort-Object name \ No newline at end of file diff --git a/Plugins/20 Cluster/52 Datastore Consistency.ps1 b/Plugins/20 Cluster/52 Datastore Consistency.ps1 index 82b54c7d..181bc3ae 100644 --- a/Plugins/20 Cluster/52 Datastore Consistency.ps1 +++ b/Plugins/20 Cluster/52 Datastore Consistency.ps1 @@ -18,8 +18,8 @@ if ($Clusters -ne $null) { ForEach ($Cluster in ($Clusters)) { - $Cluster.ExtensionData.Host | %{ $h = $_; $Datastores | Where {$_.ExtensionData.Host.key -contains $h}} | - Where {$_.Name -notmatch $DSDoNotInclude } | Group-Object Name | Where { $_.Count -ne $cluster.ExtensionData.Host.count } | - Select @{Name="Name"; Expression={$_.Group.name}}, @{Name="Cluster";Expression={$Cluster.Name}} + $Cluster.ExtensionData.Host | %{ $h = $_; $Datastores | Where-Object {$_.ExtensionData.Host.key -contains $h}} | + Where-Object {$_.Name -notmatch $DSDoNotInclude } | Group-Object Name | Where-Object { $_.Count -ne $cluster.ExtensionData.Host.count } | + Select-Object @{Name="Name"; Expression={$_.Group.name}}, @{Name="Cluster";Expression={$Cluster.Name}} } } \ No newline at end of file diff --git a/Plugins/20 Cluster/70 Cluster Node Version.ps1 b/Plugins/20 Cluster/70 Cluster Node Version.ps1 index 13069d3d..3397b7fd 100644 --- a/Plugins/20 Cluster/70 Cluster Node Version.ps1 +++ b/Plugins/20 Cluster/70 Cluster Node Version.ps1 @@ -11,7 +11,7 @@ $PluginCategory = "vSphere" $HostsVer = @() foreach ($clusview in $clusviews) { - $HostsVerMiss = $HostsViews | ?{ $_.Parent -match "^$($clusview.MoRef)$"} | select @{N="FullName";E={$_.Config.Product.FullName}} -Unique + $HostsVerMiss = $HostsViews | ?{ $_.Parent -match "^$($clusview.MoRef)$"} | Select-Object @{N="FullName";E={$_.Config.Product.FullName}} -Unique if (($HostsVerMiss | Measure-Object).Count -gt 1) { $allVer = "" foreach ($Ver in $HostsVerMiss) { $allVer = $allVer + $Ver.FullName + ";" } @@ -27,4 +27,4 @@ foreach ($clusview in $clusviews) { } } -$HostsVer | Sort Cluster \ No newline at end of file +$HostsVer | Sort-Object Cluster \ No newline at end of file diff --git a/Plugins/20 Cluster/71 Capacity Planning.ps1 b/Plugins/20 Cluster/71 Capacity Planning.ps1 index a697f594..74ff7fd4 100644 --- a/Plugins/20 Cluster/71 Capacity Planning.ps1 +++ b/Plugins/20 Cluster/71 Capacity Planning.ps1 @@ -19,7 +19,7 @@ $limitResourceCPUClusNonHA = Get-vCheckSetting $Title "limitResourceCPUClusNonHA $limitResourceMEMClusNonHA = Get-vCheckSetting $Title "limitResourceMEMClusNonHA" $limitResourceMEMClusNonHA $capacityinfo = @() -foreach ($cluv in ($clusviews | Where {$_.Summary.NumHosts -gt 0 } | Sort Name)) { +foreach ($cluv in ($clusviews | Where-Object {$_.Summary.NumHosts -gt 0 } | Sort-Object Name)) { if ( $cluv.Configuration.DasConfig.Enabled -eq $true ) { $DasRealCpuCapacity = $cluv.Summary.EffectiveCpu - (($cluv.Summary.EffectiveCpu * $cluv.Configuration.DasConfig.FailoverLevel)/$cluv.Summary.NumHosts) @@ -29,7 +29,7 @@ foreach ($cluv in ($clusviews | Where {$_.Summary.NumHosts -gt 0 } | Sort Name)) $DasRealMemCapacity = $cluv.Summary.EffectiveMemory * $limitResourceMEMClusNonHA } - $cluvmlist = $VM | where { $cluv.Host -contains $_.VMHost.Id } + $cluvmlist = $VM | Where-Object { $cluv.Host -contains $_.VMHost.Id } #CPU $CluCpuUsage = (get-view $cluv.ResourcePool).Summary.runtime.cpu.OverallUsage @@ -74,4 +74,4 @@ foreach ($cluv in ($clusviews | Where {$_.Summary.NumHosts -gt 0 } | Sort Name)) $capacityinfo += $clucapacity } -$capacityinfo | Sort Datacenter, ClusterName \ No newline at end of file +$capacityinfo | Sort-Object Datacenter, ClusterName \ No newline at end of file diff --git a/Plugins/20 Cluster/72 s-vMotion Information.ps1 b/Plugins/20 Cluster/72 s-vMotion Information.ps1 index f1d70e15..b802880f 100644 --- a/Plugins/20 Cluster/72 s-vMotion Information.ps1 +++ b/Plugins/20 Cluster/72 s-vMotion Information.ps1 @@ -54,8 +54,8 @@ foreach($vmotion in ($vmotions | Sort-object CreatedTime | Group-Object ChainID) } } # Filter out unwanted vMotion Events -if (-not $IncludevMotions) { $Motions = $Motions | Where { $_.Type -ne "vMotion" }} -if (-not $IncludeSvMotions) { $Motions = $Motions | Where { $_.Type -ne "SvMotion" }} +if (-not $IncludevMotions) { $Motions = $Motions | Where-Object { $_.Type -ne "vMotion" }} +if (-not $IncludeSvMotions) { $Motions = $Motions | Where-Object { $_.Type -ne "SvMotion" }} $Motions $Header = ("s/vMotion Information (Over {0} Days Old): [count]" -f $vMotionAge) diff --git a/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 b/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 index 8ddf1ed8..d3a18e77 100644 --- a/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 +++ b/Plugins/20 Cluster/73 VM - More RAM than free space on Datastore.ps1 @@ -9,6 +9,6 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$VM | Where {$_.PowerState -eq "PoweredOn"} | - Select Name, MemoryMB, @{"Name"="FreeSpaceMB";e={($Datastores|Where {$_.Name -eq (($Machine.ExtensionData.Config.Files.VmPathName).Split('[')[1]).Split(']')[0]}).FreeSpaceMB}} | - Where {($_.FreeSpaceMB -ne $null) -and ($_.MemoryMB -gt $_.FreeSpaceMB)} | Sort Name \ No newline at end of file +$VM | Where-Object {$_.PowerState -eq "PoweredOn"} | + Select-Object Name, MemoryMB, @{"Name"="FreeSpaceMB";e={($Datastores | Where-Object {$_.Name -eq (($Machine.ExtensionData.Config.Files.VmPathName).Split('[')[1]).Split(']')[0]}).FreeSpaceMB}} | + Where-Object {($_.FreeSpaceMB -ne $null) -and ($_.MemoryMB -gt $_.FreeSpaceMB)} | Sort-Object Name \ No newline at end of file diff --git a/Plugins/20 Cluster/75 DRS Rules.ps1 b/Plugins/20 Cluster/75 DRS Rules.ps1 index 1cb4601c..8bfa8b01 100644 --- a/Plugins/20 Cluster/75 DRS Rules.ps1 +++ b/Plugins/20 Cluster/75 DRS Rules.ps1 @@ -29,10 +29,10 @@ if ($ShowVMAntiAffinity) { $Types += "VMAntiAffinity"} if ($ShowHostAffinity) { $Types += "VMHostAffinity"} $Clusters | Foreach { - Get-DrsRule -Cluster $_ -Type $Types | Where { $_.Name -notmatch $excludeName } | - Select Cluster, Enabled, Name, Type, @{N="VM";E={(Get-View $_.VMIDS | Select -ExpandProperty Name) -join "
"}}, - @{N="Rule Host";E={(Get-View $_.AffineHostIds | Select -ExpandProperty Name) -join "
" }}, - @{N="Running on";E={(Get-View (Get-View $_.VMIDS | %{$_.Runtime.Host}) | Select -ExpandProperty Name) -join "
"}} + Get-DrsRule -Cluster $_ -Type $Types | Where-Object { $_.Name -notmatch $excludeName } | + Select-Object Cluster, Enabled, Name, Type, @{N="VM";E={(Get-View $_.VMIDS | Select-Object -ExpandProperty Name) -join "
"}}, + @{N="Rule Host";E={(Get-View $_.AffineHostIds | Select-Object -ExpandProperty Name) -join "
" }}, + @{N="Running on";E={(Get-View (Get-View $_.VMIDS | %{$_.Runtime.Host}) | Select-Object ExpandProperty Name) -join "
"}} } $Comments = ("Contains all DRS rules defined in this vCenter - {0}" -f ($types -join ",")) diff --git a/Plugins/30 Host/07 Hosts Overcommit State.ps1 b/Plugins/30 Host/07 Hosts Overcommit State.ps1 index 4175d298..8d461733 100644 --- a/Plugins/30 Host/07 Hosts Overcommit State.ps1 +++ b/Plugins/30 Host/07 Hosts Overcommit State.ps1 @@ -57,4 +57,4 @@ Foreach ($VMHost in $VMH) { } Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $lang.Complete -Completed -$OverCommit | Select Host, "TotalMem$Units", "TotalAssignedMem$Units", "TotalUsed$Units", "OverCommit$Units" +$OverCommit | Select-Object Host, "TotalMem$Units", "TotalAssignedMem$Units", "TotalUsed$Units", "OverCommit$Units" diff --git a/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 b/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 index 2a3fb226..6cacae6e 100644 --- a/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 +++ b/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 @@ -9,7 +9,7 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -foreach ($esxhost in ($HostsViews | where {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { +foreach ($esxhost in ($HostsViews | Where-Object {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.State -eq "Dead"} | %{ New-Object PSObject -Property @{ VMHost = $esxhost.Name diff --git a/Plugins/30 Host/105 Host Profile Compliance.ps1 b/Plugins/30 Host/105 Host Profile Compliance.ps1 index 337776ed..e251751e 100644 --- a/Plugins/30 Host/105 Host Profile Compliance.ps1 +++ b/Plugins/30 Host/105 Host Profile Compliance.ps1 @@ -34,32 +34,32 @@ foreach ($Profile in $HostProfiles) { $Failures = $Profile | Test-VMHostProfileCompliance -UseCache # Find all Hosts with HP Applied and status - $VMHosts = @($VMH | Where {(($Profile.ExtensionData.entity | Where {$_.type -eq "HostSystem" } | Select @{n="Id";e={"HostSystem-{0}" -f $_.Value}}) | Select -expandProperty Id) -contains $_.Id}) + $VMHosts = @($VMH | Where-Object {(($Profile.ExtensionData.entity | Where-Object {$_.type -eq "HostSystem" } | Select-Object @{n="Id";e={"HostSystem-{0}" -f $_.Value}}) | Select-Object -expandProperty Id) -contains $_.Id}) # Filter out those with failures and select required columns - $VMHosts = @($VMHosts | where {($failures | Select -expandproperty VMHostID) -notcontains $_.id} | Select @{Name="VMHostProfile";Expression={$Profile.Name}}, @{Name="Host";Expression={$_.Name}}, @{Name="Compliant";Expression={$true}}, @{Name="Failures";Expression={"None"}}) + $VMHosts = @($VMHosts | Where-Object {($failures | Select-Object -expandproperty VMHostID) -notcontains $_.id} | Select-Object @{Name="VMHostProfile";Expression={$Profile.Name}}, @{Name="Host";Expression={$_.Name}}, @{Name="Compliant";Expression={$true}}, @{Name="Failures";Expression={"None"}}) # Add in the failures - $VMHosts += ($Failures | Select VMHostProfile, @{Name='Host';Expression={$_.vmhost.name}}, @{Name='Compliant';Expression={$false}}, @{Name="Failures";Expression={($_.IncomplianceElementList | Select -expandproperty Description) -join "
"}}) + $VMHosts += ($Failures | Select-Object VMHostProfile, @{Name='Host';Expression={$_.vmhost.name}}, @{Name='Compliant';Expression={$false}}, @{Name="Failures";Expression={($_.IncomplianceElementList | Select-Object -expandproperty Description) -join "
"}}) if ($ShowCompliant) { $VMHosts } else { - $VMHosts | Where { $_.Compliant -eq $false } + $VMHosts | Where-Object { $_.Compliant -eq $false } } } else { # Otherwise, we don't care about the detail - $Profile | Select Name, @{Name="Compliant";Expression={@($_ | Test-VMHostProfileCompliance -UseCache).count -eq 0 }} + $Profile | Select-Object Name, @{Name="Compliant";Expression={@($_ | Test-VMHostProfileCompliance -UseCache).count -eq 0 }} } } else { # Profile is not used - just return the name and "N/A" if ($ShowCompliant) { if ($ShowDetail) { - $Profile | Select @{Name="VMHostProfile";Expression={$_.Name}}, @{Name="Host";Expression="None"}, @{Name="Compliant";Expression={"N/A"}}, @{Name="Failures";Expression={"N/A"}} + $Profile | Select-Object @{Name="VMHostProfile";Expression={$_.Name}}, @{Name="Host";Expression="None"}, @{Name="Compliant";Expression={"N/A"}}, @{Name="Failures";Expression={"N/A"}} } else { - $Profile | Select Name, @{Name="Compliant";Expression="N/A"} + $Profile | Select-Object Name, @{Name="Compliant";Expression="N/A"} } } } diff --git a/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 b/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 index c983e2c4..4d95bd34 100644 --- a/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 +++ b/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 @@ -90,6 +90,6 @@ namespace PKI { # Plugin to report on upcoming host certificate expirations # Check for Host Certificates -$VMH | Where {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Foreach { Test-WebServerSSL -URL $_.Name | Select OriginalURi, Issuer, @{N="Expires";E={$_.Certificate.NotAfter} }, @{N="DaysTillExpire";E={(New-TimeSpan -Start (Get-Date) -End ($_.Certificate.NotAfter)).Days} }|? {$_.DaysTillExpire -le $WarningDays}} +$VMH | Where-Object {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Foreach { Test-WebServerSSL -URL $_.Name | Select-Object OriginalURi, Issuer, @{N="Expires";E={$_.Certificate.NotAfter} }, @{N="DaysTillExpire";E={(New-TimeSpan -Start (Get-Date) -End ($_.Certificate.NotAfter)).Days} }|? {$_.DaysTillExpire -le $WarningDays}} $Header = ("Hosts with upcoming Certificate Expirations: {0} Days" -f $WarningDays) \ No newline at end of file diff --git a/Plugins/30 Host/16 Host Swapfile datastores.ps1 b/Plugins/30 Host/16 Host Swapfile datastores.ps1 index 4823e327..57948631 100644 --- a/Plugins/30 Host/16 Host Swapfile datastores.ps1 +++ b/Plugins/30 Host/16 Host Swapfile datastores.ps1 @@ -11,7 +11,7 @@ $PluginCategory = "vSphere" foreach ($clusview in $clusviews) { if ($clusview.ConfigurationEx.VmSwapPlacement -eq "hostLocal") { - $CluNodes = $VMH | where {$clusview.Host -contains $_.Id } + $CluNodes = $VMH | Where-Object {$clusview.Host -contains $_.Id } foreach ($CluNode in $CluNodes) { if ($CluNode.VMSwapfileDatastore.Name -eq $null){ if ($CluNode.ExtensionData.Config.LocalSwapDatastore.Value) { diff --git a/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 b/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 index f23b0600..83667014 100644 --- a/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 +++ b/Plugins/30 Host/20 ESXi with Technical Support mode enabled.ps1 @@ -9,5 +9,5 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$VMH | Where { ($_.Version -lt 4.1) -and ($_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance") -and ($_.ExtensionData.Summary.Config.Product.Name -match "i")} | Select Name, @{N="TechSuportModeEnabled";E={($_ | Get-AdvancedSetting -Name VMkernel.Boot.techSupportMode).value}} | Where { $_.TechSuportModeEnabled -eq "True" } -$VMH | Where { $_.Version -ge "4.1.0" } | Where {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Select Name, @{N="TechSuportModeEnabled";E={($_ | Get-VMHostService | Where {$_.key -eq "TSM"}).Running}} | Where { $_.TechSuportModeEnabled -eq "True" } \ No newline at end of file +$VMH | Where-Object { ($_.Version -lt 4.1) -and ($_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance") -and ($_.ExtensionData.Summary.Config.Product.Name -match "i")} | Select-Object Name, @{N="TechSuportModeEnabled";E={($_ | Get-AdvancedSetting -Name VMkernel.Boot.techSupportMode).value}} | Where-Object { $_.TechSuportModeEnabled -eq "True" } +$VMH | Where-Object { $_.Version -ge "4.1.0" } | Where-Object {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Select-Object Name, @{N="TechSuportModeEnabled";E={($_ | Get-VMHostService | Where-Object {$_.key -eq "TSM"}).Running}} | Where-Object { $_.TechSuportModeEnabled -eq "True" } \ No newline at end of file diff --git a/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 b/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 index b0a3ff6f..13429577 100644 --- a/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 +++ b/Plugins/30 Host/21 ESXi hosts which do not have Lockdown mode enabled.ps1 @@ -9,7 +9,7 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$VMH | Where {@("Connected","Maintenance") -contains $_.ConnectionState -and +$VMH | Where-Object {@("Connected","Maintenance") -contains $_.ConnectionState -and $_.ExtensionData.Summary.Config.Product.Name -match "i" -and -not $_.ExtensionData.Config.AdminDisabled} | ` - Select Name, @{N="LockedMode";E={$_.ExtensionData.Config.AdminDisabled}} \ No newline at end of file + Select-Object Name, @{N="LockedMode";E={$_.ExtensionData.Config.AdminDisabled}} \ No newline at end of file diff --git a/Plugins/30 Host/31 NTP Name and Service.ps1 b/Plugins/30 Host/31 NTP Name and Service.ps1 index b5e2aeb3..56f7d296 100644 --- a/Plugins/30 Host/31 NTP Name and Service.ps1 +++ b/Plugins/30 Host/31 NTP Name and Service.ps1 @@ -11,4 +11,4 @@ $PluginCategory = "vSphere" $ntpserver = "pool.ntp.org,pool2.ntp.org" # End of Settings -$VMH | Where {$_.Connectionstate -ne "Disconnected"} | Select Name, @{N="NTPServer";E={($_ | Get-VMHostNtpServer) -join ","}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver} \ No newline at end of file +$VMH | Where-Object {$_.Connectionstate -ne "Disconnected"} | Select-Object Name, @{N="NTPServer";E={($_ | Get-VMHostNtpServer) -join ","}}, @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq "ntpd"}).Running}} | Where-Object {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver} \ No newline at end of file diff --git a/Plugins/30 Host/35 Host Configuration Issues.ps1 b/Plugins/30 Host/35 Host Configuration Issues.ps1 index d7b6742d..5d96bf47 100644 --- a/Plugins/30 Host/35 Host Configuration Issues.ps1 +++ b/Plugins/30 Host/35 Host Configuration Issues.ps1 @@ -22,4 +22,4 @@ foreach ($HostsView in $HostsViews) { } } -$hostcialarms | sort name \ No newline at end of file +$hostcialarms | Sort-Object name \ No newline at end of file diff --git a/Plugins/30 Host/36 Host Alarms.ps1 b/Plugins/30 Host/36 Host Alarms.ps1 index a8885ba4..b8de902e 100644 --- a/Plugins/30 Host/36 Host Alarms.ps1 +++ b/Plugins/30 Host/36 Host Alarms.ps1 @@ -9,14 +9,14 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -foreach ($HostsView in ($HostsViews | Where {$_.TriggeredAlarmState} | Sort-Object Name)){ +foreach ($HostsView in ($HostsViews | Where-Object {$_.TriggeredAlarmState} | Sort-Object Name)){ Foreach ($hostsTriggeredAlarm in $HostsView.TriggeredAlarmState){ New-Object PSObject -Property @{ "Object" = $HostsView.name; - "Alarm" = ($valarms | Where {$_.value -eq ($hostsTriggeredAlarm.alarm.value)}).name; + "Alarm" = ($valarms | Where-Object {$_.value -eq ($hostsTriggeredAlarm.alarm.value)}).name; "Status" = $hostsTriggeredAlarm.OverallStatus; "Time" = $hostsTriggeredAlarm.time.ToLocalTime() - } | Select Object, Alarm, Status, Time + } | Select-Object Object, Alarm, Status, Time } } diff --git a/Plugins/30 Host/44 VMKernel Warnings.ps1 b/Plugins/30 Host/44 VMKernel Warnings.ps1 index 5d1369e9..20e92f8e 100644 --- a/Plugins/30 Host/44 VMKernel Warnings.ps1 +++ b/Plugins/30 Host/44 VMKernel Warnings.ps1 @@ -18,7 +18,7 @@ $VMKernelWarnings = @() foreach ($VMHost in ($HostsViews)){ $product = $VMHost.config.product.ProductLineId if ($product -eq "embeddedEsx" -and $VIVersion -lt 5){ - $Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries |where {$_ -match "warning" -and $_ -match "vmkernel"} + $Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries | Where-Object {$_ -match "warning" -and $_ -match "vmkernel"} if ($Warnings -ne $null) { $VMKernelWarning = @() $Warnings | % { @@ -36,10 +36,10 @@ foreach ($VMHost in ($HostsViews)){ } $VMKernelWarning += $Details } - $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google + $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique | Select-Object VMHost, Message, KBSearch, Google } } else { - $Warnings = (Get-Log -VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$_ -match "warning"} + $Warnings = (Get-Log -VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | Where-Object {$_ -match "warning"} if ($Warnings -ne $null) { $VMKernelWarning = @() $Warnings | Foreach { @@ -57,9 +57,9 @@ foreach ($VMHost in ($HostsViews)){ } $VMKernelWarning += $Details } - $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google + $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique | Select-Object VMHost, Message, KBSearch, Google } } } -$VMKernelWarnings | sort Message -Descending \ No newline at end of file +$VMKernelWarnings | Sort-Object Message -Descending \ No newline at end of file diff --git a/Plugins/30 Host/46 Missing ESX patches.ps1 b/Plugins/30 Host/46 Missing ESX patches.ps1 index 6ce51efc..43417622 100644 --- a/Plugins/30 Host/46 Missing ESX patches.ps1 +++ b/Plugins/30 Host/46 Missing ESX patches.ps1 @@ -15,9 +15,9 @@ $PluginCategory = "vSphere" If (Get-PSSnapin Vmware.VumAutomation -ErrorAction SilentlyContinue) { foreach($esx in $VMH){ - foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where {$_.Status -eq "NotCompliant"})){ + foreach($baseline in (Get-Compliance -Entity $esx -Detailed | Where-Object {$_.Status -eq "NotCompliant"})){ $baseline.NotCompliantPatches | - select @{N="Host";E={$esx.Name}}, + Select-Object @{N="Host";E={$esx.Name}}, @{N="Baseline";E={$baseline.Baseline.Name}},Name,ReleaseDate,IdByVendor, @{N="KB";E={(Select-String "(?http://[\w|\.|/]*\w{1})" -InputObject $_.Description).Matches[0].Groups['url'].Value}} } diff --git a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 index a89402e4..a4783bbf 100644 --- a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 +++ b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 @@ -14,8 +14,8 @@ foreach ($HostsView in ($HostsViews|?{$_.runtime.connectionstate -eq "Connected" $HWStatus = $HealthStatus.HardwareStatusInfo if ($HWStatus) { $HWStatusProp = $HWStatus|gm|?{$_.membertype -eq "property"} - $HWStatusDetails = $HWStatusProp|%{$HWStatus.($_.name)}|?{$_.status.key -inotmatch "green" -band $_.status.key -inotmatch "unknown"}|select @{N="sensor";E={$_.name}},@{N="status";E={$_.status.key}} - $HealthStatusDetails = ($HealthStatus.SystemHealthInfo).NumericSensorInfo|?{$_.HealthState.key -inotmatch "green" -band $_.HealthState.key -inotmatch "unknown"}|select @{N="sensor";E={$_.name}},@{N="status";E={$_.HealthState.key}} + $HWStatusDetails = $HWStatusProp|%{$HWStatus.($_.name)}|?{$_.status.key -inotmatch "green" -band $_.status.key -inotmatch "unknown"}| Select-Object @{N="sensor";E={$_.name}},@{N="status";E={$_.status.key}} + $HealthStatusDetails = ($HealthStatus.SystemHealthInfo).NumericSensorInfo|?{$_.HealthState.key -inotmatch "green" -band $_.HealthState.key -inotmatch "unknown"}|Select-Object @{N="sensor";E={$_.name}},@{N="status";E={$_.HealthState.key}} if ($HWStatusDetails) { foreach ($HWStatusDetail in $HWStatusDetails) { New-Object PSObject -Property @{ diff --git a/Plugins/30 Host/67 Host OS Pivot Table.ps1 b/Plugins/30 Host/67 Host OS Pivot Table.ps1 index 98c239af..f41ed2d5 100644 --- a/Plugins/30 Host/67 Host OS Pivot Table.ps1 +++ b/Plugins/30 Host/67 Host OS Pivot Table.ps1 @@ -10,4 +10,4 @@ $PluginCategory = "vSphere" # End of Settings $HostsViews | Group-Object {$_.Summary.config.product.fullname} | ` - Select @{Name="Version";Expression={$_.Name}}, Count | Sort-Object Count -Descending \ No newline at end of file + Select-Object @{Name="Version";Expression={$_.Name}}, Count | Sort-Object Count -Descending \ No newline at end of file diff --git a/Plugins/30 Host/68 Disk Max Total Latency.ps1 b/Plugins/30 Host/68 Disk Max Total Latency.ps1 index ed579874..d41bb2c1 100644 --- a/Plugins/30 Host/68 Disk Max Total Latency.ps1 +++ b/Plugins/30 Host/68 Disk Max Total Latency.ps1 @@ -19,7 +19,7 @@ $HostsDiskLatency = @() foreach ($VMHost in $VMH | ?{$_.ConnectionState -eq "Connected"}) { if ($VMHost.Version -lt 4){continue}# not an esx 4.x host $HostDiskLatency = @() - $VHHMaxLatency = $VMHost | get-stat -stat "disk.maxTotalLatency.latest" -start ($Date).addhours(-$stattotallatency) -finish ($Date)|?{$_.value -gt $diskmaxtotallatency}|sort Timestamp -Descending + $VHHMaxLatency = $VMHost | get-stat -stat "disk.maxTotalLatency.latest" -start ($Date).addhours(-$stattotallatency) -finish ($Date)|?{$_.value -gt $diskmaxtotallatency}| Sort-Object Timestamp -Descending if ($VHHMaxLatency.Count -gt 0) { $Details = "" | Select-Object Host, Timestamp, milliseconds $Details.host = $VMHost.name diff --git a/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 b/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 index ff0c3f54..a05a7232 100644 --- a/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 +++ b/Plugins/30 Host/74 Host - Network Redundancy lost.ps1 @@ -12,7 +12,7 @@ $PluginCategory = "vSphere" $vsList = Get-VirtualSwitch foreach ($VMHost in $VMH) { foreach($pnic in $VMHost.ExtensionData.Config.Network.Pnic){ - $vSw = $vsList | where {($_.VMHost -eq $VMHost) -and ($_.Nic -contains $pNic.Device)} - $pnic | Select @{N="ESXname";E={$VMHost.Name}},@{N="pNic";E={$pnic.Device}},@{N="vSwitch";E={$vSw.Name}},@{N="Status";E={if($pnic.LinkSpeed -ne $null){"up"}else{"down"}}} | Where {$_.Status -eq "down"} + $vSw = $vsList | Where-Object {($_.VMHost -eq $VMHost) -and ($_.Nic -contains $pNic.Device)} + $pnic | Select-Object @{N="ESXname";E={$VMHost.Name}},@{N="pNic";E={$pnic.Device}},@{N="vSwitch";E={$vSw.Name}},@{N="Status";E={if($pnic.LinkSpeed -ne $null){"up"}else{"down"}}} | Where-Object {$_.Status -eq "down"} } } \ No newline at end of file diff --git a/Plugins/30 Host/81 LUN Paths Check.ps1 b/Plugins/30 Host/81 LUN Paths Check.ps1 index 99e6deee..3d8f56f3 100644 --- a/Plugins/30 Host/81 LUN Paths Check.ps1 +++ b/Plugins/30 Host/81 LUN Paths Check.ps1 @@ -14,7 +14,7 @@ $RecLUNPaths = 2 $RecLUNPaths = Get-vCheckSetting $Title "RecLUNPaths" $RecLUNPaths $missingpaths = @() -foreach ($esxhost in ($HostsViews | where {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { +foreach ($esxhost in ($HostsViews | Where-Object {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { #Write-Host $esxhost.Name $lun_array = @() # 2D array - LUN Name & Path Count $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.name -like "fc.*"} | %{ diff --git a/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled b/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled index d4210d7b..658d0d84 100644 --- a/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled +++ b/Plugins/40 Datastore/109 Orphaned VMDK File.ps1.disabled @@ -49,7 +49,7 @@ $report = @() $arrUsedDisks = $FullVM | % {$_.Layout} | % {$_.Disk} | % {$_.DiskFile} #Write-CustomOut "..filtering list to exclude datastores that match this regex pattern: $excludeDatastoreRegex" -$arrDS = $storageviews | Sort-Object -property Name | Where {$_.name -notmatch $excludeDatastoreRegex } +$arrDS = $storageviews | Sort-Object -property Name | Where-Object {$_.name -notmatch $excludeDatastoreRegex } foreach ($strDatastore in $arrDS) { # Write-CustomOut "..$($strDatastore.Name) Orphaned Disks:" diff --git a/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 b/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 index 2dc1848f..dd1229c5 100644 --- a/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 +++ b/Plugins/40 Datastore/115 Datastore Clusters with sDRS Disabled.ps1 @@ -10,8 +10,8 @@ $PluginCategory = "vSphere" # End of Settings $DatastoreClustersView | ` - Where {$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled -ne $true -or $_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior -ne "automated"} | ` - Select Name, @{N="sDRS Enabled";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled}}, @{N="sDRS Automation Level";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior}} + Where-Object {$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled -ne $true -or $_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior -ne "automated"} | ` + Select-Object Name, @{N="sDRS Enabled";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled}}, @{N="sDRS Automation Level";E={$_.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultVmBehavior}} # Changelog ## 1.0 : Initial Version diff --git a/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 b/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 index 167ea1e8..87f82a40 100644 --- a/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 +++ b/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 @@ -15,8 +15,8 @@ $ExcludedVMs = "" $ExcludedVMs = Get-vCheckSetting $Title "ExcludedVMs" $ExcludedVMs $DatastoreClustersView | Foreach {$_.PodStorageDrsEntry.StorageDrsConfig.VMConfig} | ` - Where {$_.Enabled -eq $false -or $_.Behavior -ne $null} | ` - Select @{N="VM";E={Get-View $_.Vm | Select -ExpandProperty Name}}, Enabled, Behavior,@{N="Datastore Cluster";E={$dc.Name}} | Where { $_.VM -notmatch $ExcludedVMs } + Where-Object {$_.Enabled -eq $false -or $_.Behavior -ne $null} | ` + Select-Object @{N="VM";E={Get-View $_.Vm | Select-Object -ExpandProperty Name}}, Enabled, Behavior,@{N="Datastore Cluster";E={$dc.Name}} | Where-Object { $_.VM -notmatch $ExcludedVMs } # Changelog ## 1.0 : Initial Version diff --git a/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 b/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 index 3e91b9a8..33988d9b 100644 --- a/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 +++ b/Plugins/40 Datastore/34 Number of VMs per Datastore.ps1 @@ -16,7 +16,7 @@ $ExcludedDatastores = "ExcludeMe" $NumVMsPerDatastore = Get-vCheckSetting $Title "NumVMsPerDatastore" $NumVMsPerDatastore $ExcludedDatastores = Get-vCheckSetting $Title "ExcludedDatastores" $ExcludedDatastores -$StorageViews | Where-Object { $_.Name -notmatch $ExcludedDatastores } | Select Name, @{N="NumVM";E={($_.vm).Count}} | Where { $_.NumVM -gt $NumVMsPerDatastore} | Sort NumVM -Descending +$StorageViews | Where-Object { $_.Name -notmatch $ExcludedDatastores } | Select-Object Name, @{N="NumVM";E={($_.vm).Count}} | Where-Object { $_.NumVM -gt $NumVMsPerDatastore} | Sort-Object NumVM -Descending $Header = "Number of VMs per Datastore over $($NumVMsPerDatastore) : [count]" diff --git a/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 b/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 index 615aab22..b2f9fee8 100644 --- a/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 +++ b/Plugins/40 Datastore/69 Datastores in Maintenance mode.ps1 @@ -10,7 +10,7 @@ $PluginCategory = "vSphere" # End of Settings if ($VIVersion -ge 5) { - $StorageViews | Where {$_.Summary.MaintenanceMode -match "inMaintenance"} | Select Name, @{N="MaintenanceMode";E={$_.Summary.MaintenanceMode}} + $StorageViews | Where-Object {$_.Summary.MaintenanceMode -match "inMaintenance"} | Select-Object Name, @{N="MaintenanceMode";E={$_.Summary.MaintenanceMode}} } # Change Log diff --git a/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 b/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 index 33748312..a0153759 100644 --- a/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 +++ b/Plugins/40 Datastore/70 Datastores with Alarms Disabled.ps1 @@ -9,7 +9,7 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$Datastores | where {!$_.ExtensionData.AlarmActionsEnabled} | Select Name, @{n='AlarmActionsEnabled'; e={$_.ExtensionData.AlarmActionsEnabled}} +$Datastores | Where-Object {!$_.ExtensionData.AlarmActionsEnabled} | Select-Object Name, @{n='AlarmActionsEnabled'; e={$_.ExtensionData.AlarmActionsEnabled}} # Change Log ## 1.0 : Initial version diff --git a/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 b/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 index 4af48f90..6e9dbe74 100644 --- a/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 +++ b/Plugins/50 Network/24 vSwitch with less than x Ports Free.ps1 @@ -12,7 +12,7 @@ $vSwitchLeft = 5 # Update settings where there is an override $vSwitchLeft = Get-vCheckSetting $Title "vSwitchLeft" $vSwitchLeft -$VMH | Get-VirtualSwitch -Standard | Sort NumPortsAvailable | Where {$_.NumPortsAvailable -lt $($vSwitchLeft)} | Select VMHost, Name, NumPortsAvailable +$VMH | Get-VirtualSwitch -Standard | Sort-Object NumPortsAvailable | Where-Object {$_.NumPortsAvailable -lt $($vSwitchLeft)} | Select-Object VMHost, Name, NumPortsAvailable $Header = "Standard vSwitch with less than $vSwitchLeft Port(s) Free: [count]" $Comments = "The following standard vSwitches have less than $vSwitchLeft left" \ No newline at end of file diff --git a/Plugins/50 Network/98 vSwitch Security.ps1 b/Plugins/50 Network/98 vSwitch Security.ps1 index 4c30ccf2..59649ed5 100644 --- a/Plugins/50 Network/98 vSwitch Security.ps1 +++ b/Plugins/50 Network/98 vSwitch Security.ps1 @@ -90,7 +90,7 @@ if ($VersionOK) { } } - if ($results.Host) { $results | where { ($_.AllowPromiscuous -eq $AllowPromiscuousPolicy) -or ($_.ForgedTransmits -eq $ForgedTransmitsPolicy) -or ($_.MacChanges -eq $MacChangesPolicy) } | Sort-Object vSwitch,PortGroup } + if ($results.Host) { $results | Where-Object { ($_.AllowPromiscuous -eq $AllowPromiscuousPolicy) -or ($_.ForgedTransmits -eq $ForgedTransmitsPolicy) -or ($_.MacChanges -eq $MacChangesPolicy) } | Sort-Object vSwitch,PortGroup } } else { Write-Warning "PowerCLi version installed is lower than 5.1 Release 2" diff --git a/Plugins/60 VM/02 Snapshot Information.ps1 b/Plugins/60 VM/02 Snapshot Information.ps1 index a0b23eff..041469ff 100644 --- a/Plugins/60 VM/02 Snapshot Information.ps1 +++ b/Plugins/60 VM/02 Snapshot Information.ps1 @@ -32,7 +32,7 @@ function Get-SnapshotSummary { $mySnaps += $SnapshotInfo } - $mySnaps | Select VM, @{N="SnapName";E={[System.Web.HttpUtility]::UrlDecode($_.Name)}}, @{N="DaysOld";E={((Get-Date) - $_.Created).Days}}, Creator, @{N="SizeGB";E={$_.SizeGB -as [int]}}, Created, Description -ErrorAction SilentlyContinue | Sort DaysOld + $mySnaps | Select-Object VM, @{N="SnapName";E={[System.Web.HttpUtility]::UrlDecode($_.Name)}}, @{N="DaysOld";E={((Get-Date) - $_.Created).Days}}, Creator, @{N="SizeGB";E={$_.SizeGB -as [int]}}, Created, Description -ErrorAction SilentlyContinue | Sort-Object DaysOld } else { throw 'ParameterBinderStrings\InputObjectNotBound' @@ -79,7 +79,7 @@ function Get-SnapshotExtra ($snap){ $dummy = $collectionImpl.RewindCollector $collection = $collectionImpl.ReadNextTasks($tasknumber) while($collection -ne $null){ - $collection | where {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $guestName} | %{ + $collection | Where-Object {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $guestName} | %{ $row = New-Object PsObject $row | Add-Member -MemberType NoteProperty -Name User -Value $_.Reason.UserName $vm = Get-View $_.Entity @@ -107,7 +107,7 @@ function Get-SnapshotExtra ($snap){ $snapshotsExtra } -$VM | Get-Snapshot | Where {$_.Created -lt (($Date).AddDays(-$SnapshotAge))} | Get-SnapshotSummary | Where {$_.SnapName -notmatch $excludeName -and $_.Description -notmatch $excludeDesc -and $_.Creator -notmatch $excludeCreator} +$VM | Get-Snapshot | Where-Object {$_.Created -lt (($Date).AddDays(-$SnapshotAge))} | Get-SnapshotSummary | Where-Object {$_.SnapName -notmatch $excludeName -and $_.Description -notmatch $excludeDesc -and $_.Creator -notmatch $excludeCreator} $Title = "Snapshot Information" $Header = "Snapshots (Over $SnapshotAge Days Old): [count]" diff --git a/Plugins/60 VM/04 Map disk region event.ps1 b/Plugins/60 VM/04 Map disk region event.ps1 index 5974b3f9..b195dfad 100644 --- a/Plugins/60 VM/04 Map disk region event.ps1 +++ b/Plugins/60 VM/04 Map disk region event.ps1 @@ -13,7 +13,7 @@ $eventAge = 5 # Update settings where there is an override $eventAge = Get-vCheckSetting $Title "eventAge" $eventAge -Get-VIEventPlus -Start ($Date).AddDays(-$eventAge) -Type Info | Where {$_.FullFormattedMessage -match "Map disk region"} | Foreach {$_.vm}|select name |Sort-Object -unique +Get-VIEventPlus -Start ($Date).AddDays(-$eventAge) -Type Info | Where-Object {$_.FullFormattedMessage -match "Map disk region"} | Foreach {$_.vm}| Select-Object name |Sort-Object -unique $Header = ("Map disk region event (Last {0} Day(s)): [count]" -f $eventAge) diff --git a/Plugins/60 VM/09 Created or cloned VMs.ps1 b/Plugins/60 VM/09 Created or cloned VMs.ps1 index ca8701f4..7ad1fa9b 100644 --- a/Plugins/60 VM/09 Created or cloned VMs.ps1 +++ b/Plugins/60 VM/09 Created or cloned VMs.ps1 @@ -12,7 +12,7 @@ $VMsNewRemovedAge = 5 # Update settings where there is an override $VMsNewRemovedAge = Get-vCheckSetting $Title "VMsNewRemovedAge" $VMsNewRemovedAge -Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent") | Select createdTime, UserName, fullFormattedMessage +Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent") | Select-Object createdTime, UserName, fullFormattedMessage $Header = ("VMs Created or Cloned (Last {0} Day(s)): [count])" -f $VMsNewRemovedAge) $Comments = ("The following VMs have been created over the last {0} Days" -f $VMsNewRemovedAge) diff --git a/Plugins/60 VM/10 Removed VMs.ps1 b/Plugins/60 VM/10 Removed VMs.ps1 index d44c30f4..c064e553 100644 --- a/Plugins/60 VM/10 Removed VMs.ps1 +++ b/Plugins/60 VM/10 Removed VMs.ps1 @@ -12,7 +12,7 @@ $VMsNewRemovedAge = 5 # Update settings where there is an override $VMsNewRemovedAge = Get-vCheckSetting $Title "VMsNewRemovedAge" $VMsNewRemovedAge -Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType "VmRemovedEvent" | Select @{Name="VMName";Expression={$_.vm.name}}, CreatedTime, UserName, fullFormattedMessage +Get-VIEventPlus -Start ((get-date).adddays(-$VMsNewRemovedAge)) -EventType "VmRemovedEvent" | Select-Object @{Name="VMName";Expression={$_.vm.name}}, CreatedTime, UserName, fullFormattedMessage $Header = ("VMs Removed (Last {0} Day(s)): [count]" -f $VMsNewRemovedAge) $Comments = "The following VMs have been removed/deleted over the last {0} days" -f $VMsNewRemovedAge diff --git a/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 b/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 index 33daeeec..932c6d13 100644 --- a/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 +++ b/Plugins/60 VM/100 VMs with CPU or Memory Reservations.ps1 @@ -14,7 +14,7 @@ $MCRDoNotInclude = "" # Update settings where there is an override $MCRDoNotInclude = Get-vCheckSetting $Title "MCRDoNotInclude" $MCRDoNotInclude -$FullVM | Where {$_.Name -notmatch $MCRDoNotInclude -and ($_.config.cpuallocation.Reservation -ne "0" -or $_.config.memoryallocation.Reservation -ne "0")} | Select Name, @{Name="CPUReservationMhz";E={$_.config.cpuallocation.Reservation}}, @{Name="MemReservationMB";E={$_.config.memoryallocation.Reservation}} +$FullVM | Where-Object {$_.Name -notmatch $MCRDoNotInclude -and ($_.config.cpuallocation.Reservation -ne "0" -or $_.config.memoryallocation.Reservation -ne "0")} | Select-Object Name, @{Name="CPUReservationMhz";E={$_.config.cpuallocation.Reservation}}, @{Name="MemReservationMB";E={$_.config.memoryallocation.Reservation}} # Change Log ## 1.0 : Initial Release diff --git a/Plugins/60 VM/102 VM Logging.ps1 b/Plugins/60 VM/102 VM Logging.ps1 index 3defe322..55832a03 100644 --- a/Plugins/60 VM/102 VM Logging.ps1 +++ b/Plugins/60 VM/102 VM Logging.ps1 @@ -17,8 +17,8 @@ $KeepOld = Get-vCheckSetting $Title "KeepOld" $KeepOld $RotateSize = Get-vCheckSetting $Title "RotateSize" $RotateSize $VM | Foreach { - $VMKeepOld = $_.ExtensionData.Config.ExtraConfig | Where {$_.Key -eq "log.keepold"} | Select -ExpandProperty Value - $VMRotateSize = $_.ExtensionData.Config.ExtraConfig | Where {$_.Key -eq "log.rotatesize"} | Select -ExpandProperty Value + $VMKeepOld = $_.ExtensionData.Config.ExtraConfig | Where-Object {$_.Key -eq "log.keepold"} | Select-Object -ExpandProperty Value + $VMRotateSize = $_.ExtensionData.Config.ExtraConfig | Where-Object {$_.Key -eq "log.rotatesize"} | Select-Object -ExpandProperty Value If ($VMKeepOld -ne $KeepOld -Or $VMRotateSize -ne $RotateSize) { New-Object -TypeName PSObject -Property @{ diff --git a/Plugins/60 VM/106 Find Phantom Snapshots.ps1 b/Plugins/60 VM/106 Find Phantom Snapshots.ps1 index 07a4b0e6..8cb15129 100644 --- a/Plugins/60 VM/106 Find Phantom Snapshots.ps1 +++ b/Plugins/60 VM/106 Find Phantom Snapshots.ps1 @@ -12,7 +12,7 @@ $PluginCategory = "vSphere" $OutputPhantomSnapshots = @() ForEach ($theVM in $VM){ - ForEach ($theVMdisk in ($theVM | Get-HardDisk | Where {$_.Filename -match "-\d{6}.vmdk"})){ + ForEach ($theVMdisk in ($theVM | Get-HardDisk | Where-Object {$_.Filename -match "-\d{6}.vmdk"})){ # Find VM's which don't have normal Snapshots registered if (!(Get-Snapshot $theVM)) { diff --git a/Plugins/60 VM/11 VMs with over CPU Count.ps1 b/Plugins/60 VM/11 VMs with over CPU Count.ps1 index ece26d45..7dea66d1 100644 --- a/Plugins/60 VM/11 VMs with over CPU Count.ps1 +++ b/Plugins/60 VM/11 VMs with over CPU Count.ps1 @@ -12,7 +12,7 @@ $vCPU = 2 # Update settings where there is an override $vCPU = Get-vCheckSetting $Title "vCPU" $vCPU -$VM | Where {$_.NumCPU -gt $vCPU} | Select Name, PowerState, NumCPU +$VM | Where-Object {$_.NumCPU -gt $vCPU} | Select-Object Name, PowerState, NumCPU $Header = ("VMs with over {0} vCPUs: [count]" -f $vCPU) $Comments = ("The following VMs have over {0} CPU(s) and may impact performance due to CPU scheduling" -f $vCPU) diff --git a/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 b/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 index e2daad98..388ab5e3 100644 --- a/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 +++ b/Plugins/60 VM/114 VM Tools Not Up to Date.ps1 @@ -16,8 +16,8 @@ $VMTMaxReturn = 30 $VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude $VMTMaxReturn = Get-vCheckSetting $Title "VMTMaxReturn" $VMTMaxReturn -$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude -and ($_.Runtime.Powerstate -eq "poweredOn" -And $_.Guest.toolsStatus -eq "toolsOld")} | ` - Select Name, @{N="Version";E={$_.Guest.ToolsVersion}}, @{N="Status";E={$_.Guest.ToolsStatus}} | Sort Name | Select -First $VMTMaxReturn +$FullVM | Where-Object {$_.Name -notmatch $VMTDoNotInclude -and ($_.Runtime.Powerstate -eq "poweredOn" -And $_.Guest.toolsStatus -eq "toolsOld")} | ` + Select-Object Name, @{N="Version";E={$_.Guest.ToolsVersion}}, @{N="Status";E={$_.Guest.ToolsStatus}} | Sort-Object Name | Select-Object -First $VMTMaxReturn $Comments = ("The following VMs are running an older version of Tools than is available on its Host (Max Shown: {0} Exceptions: {1})" -f $VMTMaxReturn, $VMTDoNotInclude) diff --git a/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 b/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 index bf8c10b3..6b10fd96 100644 --- a/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 +++ b/Plugins/60 VM/12 VMs Swapping or Ballooning.ps1 @@ -9,7 +9,7 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$FullVM | Where {$_.runtime.PowerState -eq "PoweredOn" -and ($_.Summary.QuickStats.SwappedMemory -gt 0 -or $_.Summary.QuickStats.BalloonedMemory -gt 0)} | Select Name, @{N="SwapMB";E={$_.Summary.QuickStats.SwappedMemory}}, @{N="MemBalloonMB";E={$_.Summary.QuickStats.BalloonedMemory}} +$FullVM | Where-Object {$_.runtime.PowerState -eq "PoweredOn" -and ($_.Summary.QuickStats.SwappedMemory -gt 0 -or $_.Summary.QuickStats.BalloonedMemory -gt 0)} | Select-Object Name, @{N="SwapMB";E={$_.Summary.QuickStats.SwappedMemory}}, @{N="MemBalloonMB";E={$_.Summary.QuickStats.BalloonedMemory}} # Changelog ## 1.1 : Using quick stats property in order to avoid using Get-Stat cmdlet for performance matter diff --git a/Plugins/60 VM/120 Multi-writer.ps1 b/Plugins/60 VM/120 Multi-writer.ps1 index b888b064..d6c7c297 100644 --- a/Plugins/60 VM/120 Multi-writer.ps1 +++ b/Plugins/60 VM/120 Multi-writer.ps1 @@ -11,8 +11,8 @@ $PluginCategory = "vSphere" # Multi-writer parameter ForEach ($mwvm in $FullVM){ - $mwvm.Config.ExtraConfig | Where {$_.Key -like "scsi*sharing"} | - Select @{N="VM";E={$mwvm.Name}},Key,Value + $mwvm.Config.ExtraConfig | Where-Object {$_.Key -like "scsi*sharing"} | + Select-Object @{N="VM";E={$mwvm.Name}},Key,Value } # Changelog diff --git a/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 b/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 index b192bb38..493aa7de 100644 --- a/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 +++ b/Plugins/60 VM/121 BusSharingMode - Physical and Virtual.ps1 @@ -11,9 +11,9 @@ $PluginCategory = "vSphere" # BusSharingMode - Physical and Virtual ForEach ($vm in $FullVM){ - $scsi = $vm.Config.Hardware.Device | where {$_ -is [VMware.Vim.VirtualSCSIController] -and ($_.SharedBus -eq "physicalSharing" -or $_.SharedBus -eq "virtualSharing")} + $scsi = $vm.Config.Hardware.Device | Where-Object {$_ -is [VMware.Vim.VirtualSCSIController] -and ($_.SharedBus -eq "physicalSharing" -or $_.SharedBus -eq "virtualSharing")} if ($scsi){ - $scsi | Select @{N="VM";E={$vm.Name}}, + $scsi | Select-Object @{N="VM";E={$vm.Name}}, @{N="Controller";E={$_.DeviceInfo.Label}}, @{N="BusSharingMode";E={$_.SharedBus}} } diff --git a/Plugins/60 VM/122 NonPersistent Disks.ps1 b/Plugins/60 VM/122 NonPersistent Disks.ps1 index e5f2466a..61c987b1 100644 --- a/Plugins/60 VM/122 NonPersistent Disks.ps1 +++ b/Plugins/60 VM/122 NonPersistent Disks.ps1 @@ -16,10 +16,10 @@ $NPExcludeVM = Get-vCheckSetting $Title "NPExcludeVM" $NPExcludeVM # NonPersistent Disks $diskModes = [VMware.Vim.VirtualDiskMode]::independent_nonpersistent,[VMware.Vim.VirtualDiskMode]::nonpersistent -ForEach($npvm in $FullVM | Where {$_.Name -notmatch $NPExcludeVM}){ +ForEach($npvm in $FullVM | Where-Object {$_.Name -notmatch $NPExcludeVM}){ $npvm.Config.Hardware.Device | - Where {$_ -is [VMware.Vim.VirtualDisk] -and $diskModes -contains $_.Backing.DiskMode} | - Select @{N="VM";E={$npvm.Name}}, + Where-Object {$_ -is [VMware.Vim.VirtualDisk] -and $diskModes -contains $_.Backing.DiskMode} | + Select-Object @{N="VM";E={$npvm.Name}}, @{N="Disk";E={$_.DeviceInfo.Label}}, @{N="Mode";E={$_.Backing.DiskMode}}, @{N="CapacityGB";E={$_.capacityInKB/1MB}}, diff --git a/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 b/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 index 12ede159..83e24ddd 100644 --- a/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 +++ b/Plugins/60 VM/13 Invalid or inaccessible VMs.ps1 @@ -9,5 +9,5 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$FullVM | Where {$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"} | Sort Name | ` - Select Name, @{Name="ConnectionState";e={$_.Runtime.ConnectionState}}, @{Name="PowerState";e={$_.Runtime.PowerState}}, @{Name="IP_Address";e={$_.Guest.IpAddress}} \ No newline at end of file +$FullVM | Where-Object {$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"} | Sort-Object Name | ` + Select-Object Name, @{Name="ConnectionState";e={$_.Runtime.ConnectionState}}, @{Name="PowerState";e={$_.Runtime.PowerState}}, @{Name="IP_Address";e={$_.Guest.IpAddress}} \ No newline at end of file diff --git a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 index 4bfb5d30..6cd95043 100644 --- a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 +++ b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 @@ -13,7 +13,7 @@ $HAVMresetold = 5 # Update settings where there is an override $HAVMresetold = Get-vCheckSetting $Title "HAVMresetold" $HAVMresetold -Get-VIEventPlus -Start ($Date).AddDays(-$HAVMresetold) -Type Info | ?{$_.FullFormattedMessage -match "reset due to a guest OS error"} |select CreatedTime,FullFormattedMessage | sort CreatedTime -Descending +Get-VIEventPlus -Start ($Date).AddDays(-$HAVMresetold) -Type Info | ?{$_.FullFormattedMessage -match "reset due to a guest OS error"} |Select-Object CreatedTime,FullFormattedMessage | Sort-Object Sort-Object CreatedTime -Descending $Comments = ("The following VMs have been restarted by HA in the last {0} days" -f $HAVMresetold) diff --git a/Plugins/60 VM/19 Guests with less than X MB free.ps1 b/Plugins/60 VM/19 Guests with less than X MB free.ps1 index 36a3f580..7b6e073c 100644 --- a/Plugins/60 VM/19 Guests with less than X MB free.ps1 +++ b/Plugins/60 VM/19 Guests with less than X MB free.ps1 @@ -16,7 +16,7 @@ $MBFree = Get-vCheckSetting $Title "MBFree" $MBFree $MBDiskMinSize = Get-vCheckSetting $Title "MBDiskMinSize" $MBDiskMinSize $MyCollection = @() -$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq "poweredOn" -And ($_.Guest.toolsStatus -ne "toolsNotInstalled" -And $_.Guest.ToolsStatus -ne "toolsNotRunning")} | Select *, @{N="NumDisks";E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks +$AllVMs = $FullVM | Where-Object {-not $_.Config.Template -and $_.Runtime.PowerState -eq "poweredOn" -And ($_.Guest.toolsStatus -ne "toolsNotInstalled" -And $_.Guest.ToolsStatus -ne "toolsNotRunning")} | Select-Object *, @{N="NumDisks";E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks ForEach ($VMdsk in $AllVMs){ Foreach ($disk in $VMdsk.Guest.Disk){ if ((([math]::Round($disk.Capacity / 1MB)) -gt $MBDiskMinSize) -and (([math]::Round($disk.FreeSpace / 1MB)) -lt $MBFree)){ diff --git a/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 b/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 index 9eef25d4..1bf2c2d4 100644 --- a/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 +++ b/Plugins/60 VM/200 VMs on ephemeral portgroup.ps1 @@ -9,5 +9,5 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$EphemeralPG = Get-VDSwitch | Get-VDPortgroup | where {$_.PortBinding -eq "Ephemeral"} -$VM | Get-NetworkAdapter | where {$_.NetworkName -contains $EphemeralPG} | Select @{Name="VMName"; Expression={$_.parent}}, @{Name="Portgroup"; Expression={$_.NetworkName}} \ No newline at end of file +$EphemeralPG = Get-VDSwitch | Get-VDPortgroup | Where-Object {$_.PortBinding -eq "Ephemeral"} +$VM | Get-NetworkAdapter | Where-Object {$_.NetworkName -contains $EphemeralPG} | Select-Object @{Name="VMName"; Expression={$_.parent}}, @{Name="Portgroup"; Expression={$_.NetworkName}} \ No newline at end of file diff --git a/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 b/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 index df158a0f..a0c89140 100644 --- a/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 +++ b/Plugins/60 VM/201 VMs Hot Add Configuration.ps1 @@ -16,7 +16,7 @@ $MEMHotAdd = $true $CPUHotAdd = Get-vCheckSetting $Title "CPUHotAdd" $CPUHotAdd $MEMHotAdd = Get-vCheckSetting $Title "MEMHotAdd" $MEMHotAdd -$VMs | Select-Object Name, @{N="CPU Hot Plug Enabled"; E={$_.ExtensionData.config.CpuHotAddEnabled}}, @{N="Memory Hot Add Enabled"; E={$_.ExtensionData.config.MemoryHotAddEnabled}} | Where {$_."CPU Hot Plug Enabled" -ne $CPUHotAdd -or $_."Memory Hot Add Enabled" -ne $MEMHotAdd} +$VMs | Select-Object Name, @{N="CPU Hot Plug Enabled"; E={$_.ExtensionData.config.CpuHotAddEnabled}}, @{N="Memory Hot Add Enabled"; E={$_.ExtensionData.config.MemoryHotAddEnabled}} | Where-Object {$_."CPU Hot Plug Enabled" -ne $CPUHotAdd -or $_."Memory Hot Add Enabled" -ne $MEMHotAdd} # Create variables with unexpected values, for use in the plugin comment $CPUNotExpected = if ($CPUHotAdd) { "disabled" } else { "enabled" } diff --git a/Plugins/60 VM/26 No VM Tools.ps1 b/Plugins/60 VM/26 No VM Tools.ps1 index 5390dfb4..b804a94f 100644 --- a/Plugins/60 VM/26 No VM Tools.ps1 +++ b/Plugins/60 VM/26 No VM Tools.ps1 @@ -14,7 +14,7 @@ $VMTDoNotInclude = "" # Update settings where there is an override $VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude -$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude -and $_.Runtime.Powerstate -eq "poweredOn" -And ($_.Guest.toolsStatus -eq "toolsNotInstalled" -Or $_.Guest.ToolsStatus -eq "toolsNotRunning")} | Select Name, @{N="Status";E={$_.Guest.ToolsStatus}} +$FullVM | Where-Object {$_.Name -notmatch $VMTDoNotInclude -and $_.Runtime.Powerstate -eq "poweredOn" -And ($_.Guest.toolsStatus -eq "toolsNotInstalled" -Or $_.Guest.ToolsStatus -eq "toolsNotRunning")} | Select-Object Name, @{N="Status";E={$_.Guest.ToolsStatus}} # Change Log ## 1.2 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/27 VM Tools Issues.ps1 b/Plugins/60 VM/27 VM Tools Issues.ps1 index fa60ec1a..7b8d13b1 100644 --- a/Plugins/60 VM/27 VM Tools Issues.ps1 +++ b/Plugins/60 VM/27 VM Tools Issues.ps1 @@ -14,7 +14,7 @@ $VMTDoNotInclude = "" # Update settings where there is an override $VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude -$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | Where {$_.Guest.GuestState -eq "Running" -And ($_.Guest.GuestFullName -eq $NULL -or $_.Guest.IPAddress -eq $NULL -or $_.Guest.HostName -eq $NULL -or $_.Guest.Disk -eq $NULL -or $_.Guest.Net -eq $NULL)} | select Name, @{N="IPAddress";E={$_.Guest.IPAddress[0]}},@{n="OSFullName";E={$_.Guest.GuestFullName}},@{n="HostName";e={$_.guest.hostname}},@{N="NetworkLabel";E={$_.guest.Net[0].Network}} -ErrorAction SilentlyContinue |sort Name +$FullVM | Where-Object {$_.Name -notmatch $VMTDoNotInclude -and $_.Guest.GuestState -eq "Running" -And ($_.Guest.GuestFullName -eq $NULL -or $_.Guest.IPAddress -eq $NULL -or $_.Guest.HostName -eq $NULL -or $_.Guest.Disk -eq $NULL -or $_.Guest.Net -eq $NULL)} | Select-Object Name, @{N="IPAddress";E={$_.Guest.IPAddress[0]}},@{n="OSFullName";E={$_.Guest.GuestFullName}},@{n="HostName";e={$_.guest.hostname}},@{N="NetworkLabel";E={$_.guest.Net[0].Network}} -ErrorAction SilentlyContinue | Sort-Object Name # Change Log ## 1.2 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/28 Removable Media Connected.ps1 b/Plugins/60 VM/28 Removable Media Connected.ps1 index 7c023ab4..d0053cee 100644 --- a/Plugins/60 VM/28 Removable Media Connected.ps1 +++ b/Plugins/60 VM/28 Removable Media Connected.ps1 @@ -16,7 +16,7 @@ $IgnoreVMMedia = Get-vCheckSetting $Title "IgnoreVMMedia" $IgnoreVMMedia $FullVM | ?{$_.runtime.powerState -eq "PoweredOn" -And $_.Name -notmatch $IgnoreVMMedia} | % { $VMName = $_.Name; $_.config.hardware.device | ?{($_ -is [VMware.Vim.VirtualFloppy] -or $_ -is [VMware.Vim.VirtualCdrom]) -and $_.Connectable.Connected} | - Select @{Name="VMName"; Expression={ $VMName}}, + Select-Object @{Name="VMName"; Expression={ $VMName}}, @{Name="Device Type"; Expression={ $_.GetType().Name}}, @{Name="Device Name"; Expression={ $_.DeviceInfo.Label}}, @{Name="Device Backing"; Expression={ $_.DeviceInfo.Summary}} diff --git a/Plugins/60 VM/30 Single Storage VMs.ps1 b/Plugins/60 VM/30 Single Storage VMs.ps1 index 4e586206..3c673f5c 100644 --- a/Plugins/60 VM/30 Single Storage VMs.ps1 +++ b/Plugins/60 VM/30 Single Storage VMs.ps1 @@ -14,9 +14,9 @@ $LVMDoNotInclude = "Template_*|VDI*" # Update settings where there is an override $LVMDoNotInclude = Get-vCheckSetting $Title "LVMDoNotInclude" $LVMDoNotInclude -$unSharedDatastore = $storageviews | ?{-Not $_.summary.multiplehostaccess} | Select -Expand Name +$unSharedDatastore = $storageviews | ?{-Not $_.summary.multiplehostaccess} | Select-Object -Expand Name -$FullVM | ?{$_.Name -notmatch $LVMDoNotInclude} | ?{$_.Runtime.ConnectionState -notmatch "invalid|orphaned"} | %{$_.layoutex.file} | ?{$_.type -ne "log" -and $_.name -notmatch ".vswp$" -And $unSharedDatastore -contains $_.name.Split(']')[0].Split('[')[1]} | Select Name +$FullVM | ?{$_.Name -notmatch $LVMDoNotInclude} | ?{$_.Runtime.ConnectionState -notmatch "invalid|orphaned"} | %{$_.layoutex.file} | ?{$_.type -ne "log" -and $_.name -notmatch ".vswp$" -And $unSharedDatastore -contains $_.name.Split(']')[0].Split('[')[1]} | Select-Object Name # Change Log ## 1.4 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/32 VM CPU Percent RDY.ps1 b/Plugins/60 VM/32 VM CPU Percent RDY.ps1 index 6e866592..4a0b1f0f 100644 --- a/Plugins/60 VM/32 VM CPU Percent RDY.ps1 +++ b/Plugins/60 VM/32 VM CPU Percent RDY.ps1 @@ -24,10 +24,10 @@ Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLa $PercCPUReady = Get-vCheckSetting $Title "PercCPUReady" $PercCPUReady $i=0 -ForEach ($v in ($VM | Where {$_.PowerState -eq "PoweredOn"})){ +ForEach ($v in ($VM | Where-Object {$_.PowerState -eq "PoweredOn"})){ Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $v.Name -PercentComplete ((100*$i)/$VM.Count) For ($cpunum = 0; $cpunum -lt $v.NumCpu; $cpunum++){ - $PercReady = [Math]::Round((($v | Get-Stat -ErrorAction SilentlyContinue -Stat Cpu.Ready.Summation -Realtime | Where {$_.Instance -eq $cpunum} | Measure-Object -Property Value -Average).Average)/200,1) + $PercReady = [Math]::Round((($v | Get-Stat -ErrorAction SilentlyContinue -Stat Cpu.Ready.Summation -Realtime | Where-Object {$_.Instance -eq $cpunum} | Measure-Object -Property Value -Average).Average)/200,1) if ($_.PercReady -gt $PercCPUReady) { diff --git a/Plugins/60 VM/33 VM CPU Usage.ps1 b/Plugins/60 VM/33 VM CPU Usage.ps1 index f7921b93..ea3a5084 100644 --- a/Plugins/60 VM/33 VM CPU Usage.ps1 +++ b/Plugins/60 VM/33 VM CPU Usage.ps1 @@ -16,7 +16,7 @@ $CPUDays = 1 $CPUValue = Get-vCheckSetting $Title "CPUValue" $CPUValue $CPUDays = Get-vCheckSetting $Title "CPUDays" $CPUDays -$VM | Select Name, @{N="AverageCPU";E={[Math]::Round(($_ | Get-Stat -Stat cpu.usage.average -IntervalMins 60 -MaxSamples ($CPUDays*24) -ErrorAction SilentlyContinue | Measure-Object -Property Value -Average).Average)}}, NumCPU, VMHost | Where {$_.AverageCPU -gt $CPUValue} | Sort AverageCPU -Descending +$VM | Select-Object Name, @{N="AverageCPU";E={[Math]::Round(($_ | Get-Stat -Stat cpu.usage.average -IntervalMins 60 -MaxSamples ($CPUDays*24) -ErrorAction SilentlyContinue | Measure-Object -Property Value -Average).Average)}}, NumCPU, VMHost | Where-Object {$_.AverageCPU -gt $CPUValue} | Sort-Object AverageCPU -Descending $Header = ("VM(s) CPU above {0}%: [count]" -f $CPUValue) diff --git a/Plugins/60 VM/37 VM Alarms.ps1 b/Plugins/60 VM/37 VM Alarms.ps1 index 34b54a29..367cd069 100644 --- a/Plugins/60 VM/37 VM Alarms.ps1 +++ b/Plugins/60 VM/37 VM Alarms.ps1 @@ -10,7 +10,7 @@ $PluginCategory = "vSphere" # End of Settings $vmsalarms = @() -foreach ($VMView in ($FullVM | Where {$_.TriggeredAlarmState})){ +foreach ($VMView in ($FullVM | Where-Object {$_.TriggeredAlarmState})){ Foreach ($VMsTriggeredAlarm in $VMView.TriggeredAlarmState){ New-Object -TypeName PSObject -Property @{ Object = $VMView.name diff --git a/Plugins/60 VM/40 VCB Garbage.ps1 b/Plugins/60 VM/40 VCB Garbage.ps1 index ec2221f9..ed0e911a 100644 --- a/Plugins/60 VM/40 VCB Garbage.ps1 +++ b/Plugins/60 VM/40 VCB Garbage.ps1 @@ -10,4 +10,4 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$FullVM | ?{$_.snapshot | %{$_.rootsnapshotlist | ?{$_.name -contains "VCB|Consolidate|veeam|NBU_SNAPSHOT"}}} | Sort Name | Select Name \ No newline at end of file +$FullVM | ?{$_.snapshot | %{$_.rootsnapshotlist | ?{$_.name -contains "VCB|Consolidate|veeam|NBU_SNAPSHOT"}}} | Sort-Object Name | Select-Object Name \ No newline at end of file diff --git a/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 b/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 index 75959dd5..118ddb8f 100644 --- a/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 +++ b/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 @@ -11,4 +11,4 @@ $PluginCategory = "vSphere" $htabHostVersion = @{} $HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)} -$FullVM | ?{$htabHostVersion[$_.runtime.host].Split('.')[0] -ge 5 -and $_.runtime.consolidationNeeded} | Sort-Object -Property Name | Select Name,@{N="Consolidation needed";E={$_.Runtime.consolidationNeeded}} \ No newline at end of file +$FullVM | ?{$htabHostVersion[$_.runtime.host].Split('.')[0] -ge 5 -and $_.runtime.consolidationNeeded} | Sort-Object -Property Name | Select-Object Name,@{N="Consolidation needed";E={$_.Runtime.consolidationNeeded}} \ No newline at end of file diff --git a/Plugins/60 VM/48 Find VM Disk Format.ps1 b/Plugins/60 VM/48 Find VM Disk Format.ps1 index 54f559c2..20d0e2da 100644 --- a/Plugins/60 VM/48 Find VM Disk Format.ps1 +++ b/Plugins/60 VM/48 Find VM Disk Format.ps1 @@ -9,7 +9,7 @@ $DatastoreIgnore = "local" $diskformat = Get-vCheckSetting $Title "diskformat" $diskformat $DatastoreIgnore = Get-vCheckSetting $Title "DatastoreIgnore" $DatastoreIgnore -$VM | Get-HardDisk | where {($_.storageformat -match $diskformat) -and ($_.Filename -notmatch $DatastoreIgnore)} | select @{N="VM";E={$_.parent.name}}, @{N="DiskName";E={$_.name}}, @{N="Format";E={$_.storageformat}}, @{N="FileName";E={$_.filename}} +$VM | Get-HardDisk | Where-Object {($_.storageformat -match $diskformat) -and ($_.Filename -notmatch $DatastoreIgnore)} | Select-Object @{N="VM";E={$_.parent.name}}, @{N="DiskName";E={$_.name}}, @{N="Format";E={$_.storageformat}}, @{N="FileName";E={$_.filename}} $Title = "Find VMs with thick or thin provisioned vmdk" $Header = "VMs with $diskformat provisioned vmdk(s): [count]" diff --git a/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 b/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 index fb117232..ad1f9218 100644 --- a/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 +++ b/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 @@ -9,4 +9,4 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$FullVM | ?{$_.config.cpuallocation.limit -ne "-1" -or $_.config.memoryallocation.limit -ne "-1"} | Select Name, @{Name="CpuLimitMhz";E={$_.config.cpuallocation.limit}}, @{Name="MemLimitMB";E={$_.config.memoryallocation.limit}} \ No newline at end of file +$FullVM | ?{$_.config.cpuallocation.limit -ne "-1" -or $_.config.memoryallocation.limit -ne "-1"} | Select-Object Name, @{Name="CpuLimitMhz";E={$_.config.cpuallocation.limit}}, @{Name="MemLimitMB";E={$_.config.memoryallocation.limit}} \ No newline at end of file diff --git a/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 b/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 index 9e133d72..a79bd5e7 100644 --- a/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 +++ b/Plugins/60 VM/54 Virtual Machines with incorrect OS Configuration.ps1 @@ -14,7 +14,7 @@ $VMTDoNotInclude = "VM1_*|VM2_*" # Update settings where there is an override $VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude -$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} |` +$FullVM | Where-Object {$_.Name -notmatch $VMTDoNotInclude} |` Where-Object {$_.Guest.GuestId -and $_.Guest.GuestId -ne $_.Config.GuestId} | ` Select-Object -Property Name,@{N="GuestId";E={$_.Guest.GuestId}}, @{N="Installed Guest OS";E={$_.Guest.GuestFullName}}, diff --git a/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 b/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 index 91b5601d..bb100f29 100644 --- a/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 +++ b/Plugins/60 VM/58 Virtual machines with less hard disks than partitions.ps1 @@ -14,7 +14,7 @@ $VMTDoNotInclude = "VM1_*|VM2_*" # Update settings where there is an override $VMTDoNotInclude = Get-vCheckSetting $Title "VMTDoNotInclude" $VMTDoNotInclude -$FullVM | Where {$_.Name -notmatch $VMTDoNotInclude} | +$FullVM | Where-Object {$_.Name -notmatch $VMTDoNotInclude} | Where-Object {$_.Config.ManagedBy.ExtensionKey -ne 'com.vmware.vcDr'} | Select-Object -Property Name,@{N="NrOfHardDisks";E={($_.Layout.Disk|measure).count}},@{N="NrOfGuestDisks";E={($_.Guest.Disk|measure).count}},@{N="GuestFamily";E={$_.Guest.GuestFamily}} | Where-Object {$_.GuestFamily -eq "windowsGuest" -and $_.NrOfHardDisks -lt $_.NrOfGuestDisks} diff --git a/Plugins/60 VM/61 Guest OS Pivot table.ps1 b/Plugins/60 VM/61 Guest OS Pivot table.ps1 index f1004da5..27bcfbc2 100644 --- a/Plugins/60 VM/61 Guest OS Pivot table.ps1 +++ b/Plugins/60 VM/61 Guest OS Pivot table.ps1 @@ -32,11 +32,11 @@ $FullVM | % { $myCol = @() foreach ( $gosname in $VMOSversions.Keys | sort) { - $MyDetails = "" | select OS, Count + $MyDetails = "" | Select-Object OS, Count $MyDetails.OS = $gosname $MyDetails.Count = $VMOSversions.$gosname $myCol += $MyDetails } -$myCol | sort Count -desc +$myCol | Sort-Object Count -desc Remove-Variable VMOSversions \ No newline at end of file diff --git a/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 b/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 index cfc8e970..db340cd2 100644 --- a/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 +++ b/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 @@ -15,7 +15,7 @@ $unwantedHardware = "VirtualUSBController|VirtualParallelPort|VirtualSerialPort" $unwantedHardware = Get-vCheckSetting $Title "unwantedHardware" $unwantedHardware foreach ($vmguest in $FullVM) { - $vmguest.Config.Hardware.Device | where {$_.GetType().Name -match $unwantedHardware} | %{ + $vmguest.Config.Hardware.Device | Where-Object {$_.GetType().Name -match $unwantedHardware} | %{ New-Object -TypeName PSObject -Property @{ Name = $vmguest.name Label = $_.DeviceInfo.Label diff --git a/Plugins/60 VM/620 CBT Status.ps1 b/Plugins/60 VM/620 CBT Status.ps1 index 22d08ac5..d2868355 100644 --- a/Plugins/60 VM/620 CBT Status.ps1 +++ b/Plugins/60 VM/620 CBT Status.ps1 @@ -14,7 +14,7 @@ $CBTEnabled = $false # Update settings where there is an override $CBTEnabled = Get-vCheckSetting $Title "CBTEnabled" $CBTEnabled -$FullVm | Where-object {$_.Config.ChangeTrackingEnabled -eq $CBTEnabled} | Select-Object Name, @{Name="Change Block Tracking";Expression={if ($_.Config.ChangeTrackingEnabled) { "enabled" } else { "disabled" }}} | Sort Name +$FullVm | Where-object {$_.Config.ChangeTrackingEnabled -eq $CBTEnabled} | Select-Object Name, @{Name="Change Block Tracking";Expression={if ($_.Config.ChangeTrackingEnabled) { "enabled" } else { "disabled" }}} | Sort-Object Name # Change Log ## 1.1 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/64 Snapshots Oversize.ps1 b/Plugins/60 VM/64 Snapshots Oversize.ps1 index dbb213fd..7973ae27 100644 --- a/Plugins/60 VM/64 Snapshots Oversize.ps1 +++ b/Plugins/60 VM/64 Snapshots Oversize.ps1 @@ -10,7 +10,7 @@ $PluginCategory = "vSphere" # End of Settings $snapp = @() -Foreach ($vmg in ($VM | Where {$_.ExtensionData.Snapshot})) { +Foreach ($vmg in ($VM | Where-Object {$_.ExtensionData.Snapshot})) { $hddsize = ($vmg | Get-HardDisk | Measure-Object -sum CapacityGB).sum $snapInfo = $vmg | Get-Snapshot | Measure-Object -Sum SizeGB @@ -28,7 +28,7 @@ Foreach ($vmg in ($VM | Where {$_.ExtensionData.Snapshot})) { }) } -$snapp | select VM, vmdkSizeGB, SnapSizeGB, SnapCount, @{N="OverSize %";E={$_.OverSize}} | sort "OverSize %" -Descending +$snapp | Select-Object VM, vmdkSizeGB, SnapSizeGB, SnapCount, @{N="OverSize %";E={$_.OverSize}} | Sort-Object "OverSize %" -Descending # Changelog ## 1.3 : Rewritten to cleanup and compare vmdk size to only snapshot size diff --git a/Plugins/60 VM/66 Misnamed VM.ps1 b/Plugins/60 VM/66 Misnamed VM.ps1 index 6b130b43..483fc5f4 100644 --- a/Plugins/60 VM/66 Misnamed VM.ps1 +++ b/Plugins/60 VM/66 Misnamed VM.ps1 @@ -14,7 +14,7 @@ $MNDoNotInclude = "VM1_*|VM2_*" # Update settings where there is an override $MNDoNotInclude = Get-vCheckSetting $Title "MNDoNotInclude" $MNDoNotInclude -($FullVM | Where {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name }) | +($FullVM | Where-Object {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name }) | foreach { $vmguest = $_ if ($vmguest.Parent -ne $null) diff --git a/Plugins/60 VM/78 Reset VMs.ps1 b/Plugins/60 VM/78 Reset VMs.ps1 index e842b803..8250310b 100644 --- a/Plugins/60 VM/78 Reset VMs.ps1 +++ b/Plugins/60 VM/78 Reset VMs.ps1 @@ -12,7 +12,7 @@ $VMsResetAge = 1 # Update settings where there is an override $VMsResetAge = Get-vCheckSetting $Title "VMsResetAge" $VMsResetAge -Get-VIEventPlus -Start ((get-date).adddays(-$VMsResetAge)) -EventType "VmResettingEvent" | Select createdTime, UserName, fullFormattedMessage +Get-VIEventPlus -Start ((get-date).adddays(-$VMsResetAge)) -EventType "VmResettingEvent" | Select-Object createdTime, UserName, fullFormattedMessage $Header = ("VMs Reset (Last {0} Day(s)) : [count]" -f $VMsResetAge) $Comments = ("The following VMs have been reset over the last {0} days" -f $VMsResetAge) diff --git a/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 b/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 index 7d9b307c..30cd5e73 100644 --- a/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 +++ b/Plugins/60 VM/79 Find VMs in Uncontrolled Snapshot Mode.ps1 @@ -21,21 +21,21 @@ $pLang = DATA { Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLang -ErrorAction SilentlyContinue $i=0; -foreach ($eachDS in ($Datastores | Where {$_.State -eq "Available"})) { +foreach ($eachDS in ($Datastores | Where-Object {$_.State -eq "Available"})) { Write-Progress -ID 2 -Parent 1 -Activity $pLang.pluginActivity -Status ($pLang.pluginStatus -f $i, $Datastores.count, $eachDS.Name) -PercentComplete ($i*100/$Datastores.count) $eachDS.Name $FilePath = $eachDS.DatastoreBrowserPath + '\*\*delta.vmdk*' - $fileList = @(Get-ChildItem -Path "$FilePath" | Select Name, FolderPath, FullName) + $fileList = @(Get-ChildItem -Path "$FilePath" | Select-Object Name, FolderPath, FullName) $FilePath = $eachDS.DatastoreBrowserPath + '\*\-*-flat.vmdk' - $fileList += Get-ChildItem -Path "$FilePath" | Select Name, FolderPath, FullName + $fileList += Get-ChildItem -Path "$FilePath" | Select-Object Name, FolderPath, FullName $i++ - foreach ($vmFile in $filelist | sort FolderPath) + foreach ($vmFile in $filelist | Sort-Object FolderPath) { $vmFile.FolderPath -match '^\[([^\]]+)\] ([^/]+)' > $null $VMName = $matches[2] - $eachVM = $FullVM | where {$_.Name -eq $VMName} + $eachVM = $FullVM | Where-Object {$_.Name -eq $VMName} if (!$eachVM.snapshot) { # Only process VMs without snapshots diff --git a/Plugins/60 VM/85 Snapshot Activity.ps1 b/Plugins/60 VM/85 Snapshot Activity.ps1 index 019209d1..86dd5fab 100644 --- a/Plugins/60 VM/85 Snapshot Activity.ps1 +++ b/Plugins/60 VM/85 Snapshot Activity.ps1 @@ -16,7 +16,7 @@ $snapshotUserException = "s-veeam" $VMsNewRemovedAge = Get-vCheckSetting $Title "VMsNewRemovedAge" $VMsNewRemovedAge $snapshotUserException = Get-vCheckSetting $Title "snapshotUserException" $snapshotUserException -Get-VIEventPlus -Start ((get-date).adddays(- $VMsNewRemovedAge)) -EventType "TaskEvent" | ? { $_.FullFormattedMessage -match "snapshot" -and $_.userName -notmatch $snapshotUserException } | Select @{ N = "Created Time"; E = { ($_.createdTime).ToLocalTime() } }, @{ N = "User"; E = { $_.userName } }, @{ N = "VM Name"; E = { $_.vm.name } }, @{ N = "Description"; E = { $_.FullFormattedMessage } } | sort "VM Name", "Created Time" +Get-VIEventPlus -Start ((get-date).adddays(- $VMsNewRemovedAge)) -EventType "TaskEvent" | ? { $_.FullFormattedMessage -match "snapshot" -and $_.userName -notmatch $snapshotUserException } | Select-Object @{ N = "Created Time"; E = { ($_.createdTime).ToLocalTime() } }, @{ N = "User"; E = { $_.userName } }, @{ N = "VM Name"; E = { $_.vm.name } }, @{ N = "Description"; E = { $_.FullFormattedMessage } } | Sort-Object "VM Name", "Created Time" $Comments = ("Last {0} Day(s) with user exception {1}" -f $VMsNewRemovedAge, $snapshotUserException) diff --git a/Plugins/70 Misc/108 SRM RPO Violations.ps1 b/Plugins/70 Misc/108 SRM RPO Violations.ps1 index 5cbc8f88..3f6f8f64 100644 --- a/Plugins/70 Misc/108 SRM RPO Violations.ps1 +++ b/Plugins/70 Misc/108 SRM RPO Violations.ps1 @@ -53,13 +53,13 @@ $ActiveViolationsOnly = Get-vCheckSetting $Title "ActiveViolationsOnly" $ActiveV ## Begin code block obtained from: http://www.virtu-al.net/2013/06/14/reporting-on-rpo-violations-from-vsphere-replication/ # modified by Joel Gibson -Foreach ($RPOvm in ($VMs | Where { $_.name -match $VMNameRegex })) { - $RPOEvents = Get-VIEventPlus -Entity $RPOvm | where { $_.EventTypeID -match "rpo" } | Where { $_.Vm.Name -eq $RPOvm.Name } | Select EventTypeId, CreatedTime, FullFormattedMessage, @{Name="VMName";Expression={$_.Vm.Name}} | Sort CreatedTime +Foreach ($RPOvm in ($VMs | Where-Object { $_.name -match $VMNameRegex })) { + $RPOEvents = Get-VIEventPlus -Entity $RPOvm | Where-Object { $_.EventTypeID -match "rpo" -and $_.Vm.Name -eq $RPOvm.Name } | Select-Object EventTypeId, CreatedTime, FullFormattedMessage, @{Name="VMName";Expression={$_.Vm.Name}} | Sort-Object CreatedTime if ($RPOEvents) { $Count = 0 do { - $details = "" | Select VMName, ViolationStart, ViolationEnd, Mins + $details = "" | Select-Object VMName, ViolationStart, ViolationEnd, Mins if ($RPOEvents[$count].EventTypeID -match "Violated") { If (-not $details.Start) { $Details.VMName = $RPOEvents[$Count].VMName diff --git a/Plugins/80 Finish/118 Plugins Not up to date or installed.ps1.disabled b/Plugins/80 Finish/118 Plugins Not up to date or installed.ps1.disabled index 4ab4905f..d4bd4a68 100644 --- a/Plugins/80 Finish/118 Plugins Not up to date or installed.ps1.disabled +++ b/Plugins/80 Finish/118 Plugins Not up to date or installed.ps1.disabled @@ -10,9 +10,9 @@ $proxy = "$false" . $ScriptPath\vcheckutils.ps1 | Out-Null if ($proxy -eq "$false"){ - $NotInstalled = Get-vCheckPlugin | Where {$_.Category -eq "vSphere" -and ($_.status -eq "Not Installed" -or $_.status -match "New Version Available")} | Select Name, version, Status, Description + $NotInstalled = Get-vCheckPlugin | Where-Object {$_.Category -eq "vSphere" -and ($_.status -eq "Not Installed" -or $_.status -match "New Version Available")} | Select-Object Name, version, Status, Description } else { - $NotInstalled = Get-vCheckPlugin -Proxy $proxy | Where {$_.Category -eq "vSphere" -and ($_.status -eq "Not Installed" -or $_.status -match "New Version Available")} | Select Name, version, Status, Description + $NotInstalled = Get-vCheckPlugin -Proxy $proxy | Where-Object {$_.Category -eq "vSphere" -and ($_.status -eq "Not Installed" -or $_.status -match "New Version Available")} | Select-Object Name, version, Status, Description } $NotInstalled diff --git a/Select-Plugins.ps1 b/Select-Plugins.ps1 index 711ad5dd..b053eecb 100644 --- a/Select-Plugins.ps1 +++ b/Select-Plugins.ps1 @@ -54,7 +54,7 @@ If ($PluginPath -notmatch 'plugins$') { $PluginPath += "\Plugins" } $plugins = Get-ChildItem -Path $PluginPath -Include *.ps1, *.ps1.disabled -Recurse | - Sort {[int]($_.Name -replace '\D')} | + Sort-Object {[int]($_.Name -replace '\D')} | Select FullName, Name, @{Label="Plugin";expression={$_.Name -replace '(.*)\.ps1(?:\.disabled|)$', '$1'}}, @{Label="Enabled";expression={$_.Name -notmatch '.*\.disabled$'}} diff --git a/Styles/CleanGreen/Style.ps1 b/Styles/CleanGreen/Style.ps1 index 9185ac8b..1a3c86ad 100644 --- a/Styles/CleanGreen/Style.ps1 +++ b/Styles/CleanGreen/Style.ps1 @@ -72,7 +72,7 @@ function Get-PluginHTML { #> function Get-ReportTOC { $TOCHTML = "
    " - foreach ($pr in ($PluginResult | Where {$_.Details})) { + foreach ($pr in ($PluginResult | Where-Object {$_.Details})) { $TOCHTML += ("
  • {1}
  • " -f $pr.PluginID, $pr.Title) } $TOCHTML += "
" diff --git a/Styles/VMware/Style.ps1 b/Styles/VMware/Style.ps1 index f16d8a7f..32bac19e 100644 --- a/Styles/VMware/Style.ps1 +++ b/Styles/VMware/Style.ps1 @@ -82,7 +82,7 @@ function Get-ReportTOC { $TOCHTML = "" $i = 0 - foreach ($pr in ($PluginResult | Where {$_.Details})) { + foreach ($pr in ($PluginResult | Where-Object {$_.Details})) { $TOCHTML += ("" -f $pr.PluginID, $pr.Title) $i++ diff --git a/vCheck.ps1 b/vCheck.ps1 index 440ad4e6..4590f254 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -358,7 +358,7 @@ Function Get-HTMLTable { # If only one column, fix up the table header if (($content | Get-Member -MemberType Properties).count -eq 1) { - $XMLTable.table.tr[0].th = (($content | Get-Member -MemberType Properties) | Select -ExpandProperty Name -First 1).ToString() + $XMLTable.table.tr[0].th = (($content | Get-Member -MemberType Properties) | Select-Object -ExpandProperty Name -First 1).ToString() } # If format rules are specified @@ -447,7 +447,7 @@ Function Get-HTMLList { # If only one column, fix up the table header if (($content | Get-Member -MemberType Properties).count -eq 1) { - $XMLTable.table.tr[0].th = (($content | Get-Member -MemberType Properties) | Select -ExpandProperty Name -First 1).ToString() + $XMLTable.table.tr[0].th = (($content | Get-Member -MemberType Properties) | Select-Object -ExpandProperty Name -First 1).ToString() } return (Format-HTMLEntities ([string]($XMLTable.OuterXml))) @@ -788,7 +788,7 @@ if ($job) { foreach ($PluginPath in ($jobConfig.vCheck.plugins.path -split ";")) { if (Test-Path $PluginPath) { $PluginPaths += (Get-Item $PluginPath).Fullname - $PluginPaths += Get-Childitem $PluginPath -Recurse | ?{ $_.PSIsContainer } | Select -ExpandProperty FullName + $PluginPaths += Get-Childitem $PluginPath -Recurse | ?{ $_.PSIsContainer } | Select-Object -ExpandProperty FullName } else { $PluginPaths += $ScriptPath + "\Plugins" Write-Warning ($lang.pluginpathInvalid -f $PluginPath, ($ScriptPath + "\Plugins")) @@ -819,10 +819,10 @@ if ($job) { } } else { $ToNatural = { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } - $vCheckPlugins = @(Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | where { $_.Directory -match "initialize" } | Sort-Object $ToNatural) - $PluginsSubFolder = Get-ChildItem -Path $PluginsFolder | where { ($_.PSIsContainer) -and ($_.Name -notmatch "initialize") -and ($_.Name -notmatch "finish") } + $vCheckPlugins = @(Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | Where-Object { $_.Directory -match "initialize" } | Sort-Object $ToNatural) + $PluginsSubFolder = Get-ChildItem -Path $PluginsFolder | Where-Object { ($_.PSIsContainer) -and ($_.Name -notmatch "initialize") -and ($_.Name -notmatch "finish") } $vCheckPlugins += $PluginsSubFolder | % { Get-ChildItem -Path $_.FullName -filter "*.ps1" | Sort-Object $ToNatural } - $vCheckPlugins += Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | where { $_.Directory -match "finish" } | Sort-Object $ToNatural + $vCheckPlugins += Get-ChildItem -Path $PluginsFolder -filter "*.ps1" -Recurse | Where-Object { $_.Directory -match "finish" } | Sort-Object $ToNatural $GlobalVariables = $ScriptPath + "\GlobalVariables.ps1" } @@ -953,7 +953,7 @@ if (-not $GUIConfig) { foreach ($Plugin in (Get-ChildItem $PluginsFolder -Include *.ps1, *.ps1.disabled -Recurse)) { $Plugins += New-Object PSObject -Property @{ "Name" = (Get-PluginID $Plugin.FullName).Title; - "Enabled" = (($vCheckPlugins | Select -ExpandProperty FullName) -Contains $plugin.FullName) + "Enabled" = (($vCheckPlugins | Select-Object -ExpandProperty FullName) -Contains $plugin.FullName) } } @@ -982,7 +982,7 @@ if (-not $GUIConfig) { "Title" = $lang.repTTRTitle; "Author" = "vCheck"; "Version" = $vCheckVersion; - "Details" = ($PluginResult | Where { $_.TimeToRun -gt $PluginSeconds } | Select Title, TimeToRun | Sort-Object TimeToRun -Descending); + "Details" = ($PluginResult | Where-Object { $_.TimeToRun -gt $PluginSeconds } | Select-Object Title, TimeToRun | Sort-Object TimeToRun -Descending); "Display" = "List"; "TableFormat" = $null; "Header" = ($lang.repTime -f [math]::round(($Finished - $Date).TotalMinutes, 2), ($Finished.ToLongDateString()), ($Finished.ToLongTimeString())); diff --git a/vCheckUtils.ps1 b/vCheckUtils.ps1 index 0d88d514..067c8eaf 100644 --- a/vCheckUtils.ps1 +++ b/vCheckUtils.ps1 @@ -135,11 +135,11 @@ function Get-vCheckPlugin foreach ($plugin in $plugins.pluginlist.plugin) { - $pluginObjectList | where {$_.name -eq $plugin.name -and [double]$_.version -lt [double]$plugin.version}| + $pluginObjectList | Where-Object {$_.name -eq $plugin.name -and [double]$_.version -lt [double]$plugin.version}| foreach{ $_.status = "New Version Available - " + $plugin.version } - if (!($pluginObjectList | where {$_.name -eq $plugin.name})) + if (!($pluginObjectList | Where-Object {$_.name -eq $plugin.name})) { $pluginObject = New-Object PSObject $pluginObject | Add-Member -MemberType NoteProperty -Name name -value $plugin.name @@ -162,15 +162,15 @@ function Get-vCheckPlugin } if ($name){ - $pluginObjectList | where {$_.name -eq $name} + $pluginObjectList | Where-Object {$_.name -eq $name} } Else { if ($category){ - $pluginObjectList | Where {$_.Category -eq $category} + $pluginObjectList | Where-Object {$_.Category -eq $category} } Else { if($notinstalled){ - $pluginObjectList | where {$_.status -eq "Not Installed"} + $pluginObjectList | Where-Object {$_.status -eq "Not Installed"} } elseif($pendingupdate) { - $pluginObjectList | where {$_.status -like "New Version Available*"} + $pluginObjectList | Where-Object {$_.status -like "New Version Available*"} } Else { $pluginObjectList @@ -523,7 +523,7 @@ Function Export-vCheckSettings { Foreach ($plugin in (Get-ChildItem -Path $vCheckPath\Plugins\* -Include *.ps1, *.ps1.disabled -Recurse)) { $Export += Get-PluginSettings -Filename $plugin.Fullname } - $Export | Select filename, question, var | Export-Csv -NoTypeInformation $outfile + $Export | Select-Object filename, question, var | Export-Csv -NoTypeInformation $outfile } @@ -611,10 +611,10 @@ Function Import-vCheckSettings { } $Import = Import-Csv $csvfile $GlobalVariables = "$vCheckPath\GlobalVariables.ps1" - $settings = $Import | Where {($_.filename).Split("\")[-1] -eq ($GlobalVariables).Split("\")[-1]} + $settings = $Import | Where-Object {($_.filename).Split("\")[-1] -eq ($GlobalVariables).Split("\")[-1]} Set-PluginSettings -Filename $GlobalVariables -Settings $settings -GB Foreach ($plugin in (Get-ChildItem -Path $vCheckPath\Plugins\* -Include *.ps1, *.ps1.disabled -Recurse)) { - $settings = $Import | Where {($_.filename).Split("\")[-1] -eq ($plugin.Fullname).Split("\")[-1]} + $settings = $Import | Where-Object {($_.filename).Split("\")[-1] -eq ($plugin.Fullname).Split("\")[-1]} Set-PluginSettings -Filename $plugin.Fullname -Settings $settings } Write-Warning "`nImport Complete!`n" @@ -656,10 +656,10 @@ Function Import-vCheckSettingsXML { } $Import = [xml](Get-Content $xmlFile) $GlobalVariables = "$vCheckPath\GlobalVariables.ps1" - $settings = $Import.vCheck.Setting | Where {($_.filename).Split("\")[-1] -eq ($GlobalVariables).Split("\")[-1]} + $settings = $Import.vCheck.Setting | Where-Object {($_.filename).Split("\")[-1] -eq ($GlobalVariables).Split("\")[-1]} Set-PluginSettings -Filename $GlobalVariables -Settings $settings -GB Foreach ($plugin in (Get-ChildItem -Path "$vCheckPath\Plugins\" -Filter "*.ps1" -Recurse)) { - $settings = $Import.vCheck.Setting | Where {($_.filename).Split("\")[-1] -eq ($plugin.Fullname).Split("\")[-1]} + $settings = $Import.vCheck.Setting | Where-Object {($_.filename).Split("\")[-1] -eq ($plugin.Fullname).Split("\")[-1]} Set-PluginSettings -Filename $plugin.Fullname -Settings $settings } Write-Warning "`nImport Complete!`n" @@ -750,7 +750,7 @@ param ( while ( ($i -lt $end) -and ($contents[$i] -notmatch "Start of Settings") ) { $i++ } while ( ($i -lt $end) -and ($contents[$i] -notmatch "End of Settings") ) { - if ($contents[$i] -match "`=") { "" | select @{n='File';e={$PluginFile.fullname}},@{n='Variable';e={$contents[$i]}}; $i++ } + if ($contents[$i] -match "`=") { "" | Select-Object @{n='File';e={$PluginFile.fullname}},@{n='Variable';e={$contents[$i]}}; $i++ } else { $i++ } } @@ -954,7 +954,7 @@ Function Get-vCheckLogData { $ContextInfo = Select-String "Plugin Start - $Section" $vCheckFile -context 0,6 # lines 3-6 are the data we want. - $table = $ContextInfo.Context.PostContext | select -last 4 + $table = $ContextInfo.Context.PostContext | Select-Object -last 4 # The table actually ends on line 7. But line 6 looks like this: #
{1}
Back To Top From cfd713b20448681013e8dafe263d980217d2075d Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Sun, 26 Feb 2017 15:11:55 -0800 Subject: [PATCH 45/50] Update 14 VMs restarted due to Guest OS Error.ps1 --- Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 index 6cd95043..21c12773 100644 --- a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 +++ b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 @@ -13,9 +13,9 @@ $HAVMresetold = 5 # Update settings where there is an override $HAVMresetold = Get-vCheckSetting $Title "HAVMresetold" $HAVMresetold -Get-VIEventPlus -Start ($Date).AddDays(-$HAVMresetold) -Type Info | ?{$_.FullFormattedMessage -match "reset due to a guest OS error"} |Select-Object CreatedTime,FullFormattedMessage | Sort-Object Sort-Object CreatedTime -Descending +Get-VIEventPlus -Start ($Date).AddDays(-$HAVMresetold) -Type Info | Where-Object {$_.FullFormattedMessage -match "reset due to a guest OS error"} | Select-Object CreatedTime,FullFormattedMessage | Sort-Object CreatedTime -Descending $Comments = ("The following VMs have been restarted by HA in the last {0} days" -f $HAVMresetold) # Change Log -## 1.3 : Add Get-vCheckSetting and switch to Get-VIEventPlus \ No newline at end of file +## 1.3 : Add Get-vCheckSetting and switch to Get-VIEventPlus From 137dfdde7b2032042257fce050ee96e6adbe77dd Mon Sep 17 00:00:00 2001 From: Sneddo Date: Mon, 27 Feb 2017 13:41:45 +1100 Subject: [PATCH 46/50] More updates - Replacing foreach and %{ on the pipeline with Foreach-Object - Replace ?{ with Where-object --- .../00 Connection Plugin for vCenter.ps1 | 2 +- .../20 Cluster/104 Clusters with no Host Profile.ps1 | 4 ++-- Plugins/20 Cluster/52 Datastore Consistency.ps1 | 2 +- Plugins/20 Cluster/70 Cluster Node Version.ps1 | 2 +- Plugins/20 Cluster/75 DRS Rules.ps1 | 4 ++-- Plugins/30 Host/07 Hosts Overcommit State.ps1 | 2 +- Plugins/30 Host/08 Hosts Dead LUN Path.ps1 | 2 +- .../110 Host Certificate Expiration Check.ps1 | 2 +- Plugins/30 Host/44 VMKernel Warnings.ps1 | 2 +- .../30 Host/53 Hardware status warnings-errors.ps1 | 12 ++++++------ Plugins/30 Host/68 Disk Max Total Latency.ps1 | 4 ++-- Plugins/30 Host/81 LUN Paths Check.ps1 | 2 +- .../116 sDRS VM Behavior not Default.ps1 | 2 +- Plugins/60 VM/02 Snapshot Information.ps1 | 2 +- Plugins/60 VM/04 Map disk region event.ps1 | 2 +- Plugins/60 VM/102 VM Logging.ps1 | 2 +- .../60 VM/14 VMs restarted due to Guest OS Error.ps1 | 2 +- Plugins/60 VM/28 Removable Media Connected.ps1 | 4 ++-- Plugins/60 VM/30 Single Storage VMs.ps1 | 4 ++-- Plugins/60 VM/37 VM Alarms.ps1 | 2 +- Plugins/60 VM/40 VCB Garbage.ps1 | 2 +- .../60 VM/45 VMs needing snapshot consolidation.ps1 | 4 ++-- .../50 VMs with CPU or Memory Limits Configured.ps1 | 2 +- Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 | 2 +- Plugins/60 VM/66 Misnamed VM.ps1 | 2 +- Plugins/60 VM/76 VM Network State.ps1 | 4 ++-- vCheckUtils.ps1 | 2 +- 27 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 index 1b32f5ad..2d359912 100644 --- a/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 +++ b/Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 @@ -331,7 +331,7 @@ function Get-VIEventPlus { if(!$Entity){ $Entity = @(Get-Folder -NoRecursion) } - $entity | %{ + $entity | Foreach-Object { $eventFilter.entity.entity = $_.ExtensionData.MoRef $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter)) $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) diff --git a/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 b/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 index 5d26a28e..5aa0d3ea 100644 --- a/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 +++ b/Plugins/20 Cluster/104 Clusters with no Host Profile.ps1 @@ -10,6 +10,6 @@ $PluginCategory = "vSphere" # End of Settings # Get all host profiles and corresponding cluster ID (don't really care about individual hosts at this stage!) -$HostProfiles = Get-VMHostProfile | Select-Object Name, @{Name="ClusterID";Expression={$_.ExtensionData.Entity | ?{ $_.type -eq "ClusterComputeResource" }}} +$HostProfiles = Get-VMHostProfile | Select-Object Name, @{Name="ClusterID";Expression={$_.ExtensionData.Entity | Where-Object { $_.type -eq "ClusterComputeResource" }}} -$clusviews | ?{($HostProfiles | Select-Object -expandProperty ClusterID) -notcontains $_.moref } | Sort-Object Name | Select-Object Name \ No newline at end of file +$clusviews | Where-Object {($HostProfiles | Select-Object -expandProperty ClusterID) -notcontains $_.moref } | Sort-Object Name | Select-Object Name \ No newline at end of file diff --git a/Plugins/20 Cluster/52 Datastore Consistency.ps1 b/Plugins/20 Cluster/52 Datastore Consistency.ps1 index 181bc3ae..1c064164 100644 --- a/Plugins/20 Cluster/52 Datastore Consistency.ps1 +++ b/Plugins/20 Cluster/52 Datastore Consistency.ps1 @@ -18,7 +18,7 @@ if ($Clusters -ne $null) { ForEach ($Cluster in ($Clusters)) { - $Cluster.ExtensionData.Host | %{ $h = $_; $Datastores | Where-Object {$_.ExtensionData.Host.key -contains $h}} | + $Cluster.ExtensionData.Host | Foreach-Object { $h = $_; $Datastores | Where-Object {$_.ExtensionData.Host.key -contains $h}} | Where-Object {$_.Name -notmatch $DSDoNotInclude } | Group-Object Name | Where-Object { $_.Count -ne $cluster.ExtensionData.Host.count } | Select-Object @{Name="Name"; Expression={$_.Group.name}}, @{Name="Cluster";Expression={$Cluster.Name}} } diff --git a/Plugins/20 Cluster/70 Cluster Node Version.ps1 b/Plugins/20 Cluster/70 Cluster Node Version.ps1 index 3397b7fd..9ea0eed6 100644 --- a/Plugins/20 Cluster/70 Cluster Node Version.ps1 +++ b/Plugins/20 Cluster/70 Cluster Node Version.ps1 @@ -11,7 +11,7 @@ $PluginCategory = "vSphere" $HostsVer = @() foreach ($clusview in $clusviews) { - $HostsVerMiss = $HostsViews | ?{ $_.Parent -match "^$($clusview.MoRef)$"} | Select-Object @{N="FullName";E={$_.Config.Product.FullName}} -Unique + $HostsVerMiss = $HostsViews | Where-Object { $_.Parent -match "^$($clusview.MoRef)$"} | Select-Object @{N="FullName";E={$_.Config.Product.FullName}} -Unique if (($HostsVerMiss | Measure-Object).Count -gt 1) { $allVer = "" foreach ($Ver in $HostsVerMiss) { $allVer = $allVer + $Ver.FullName + ";" } diff --git a/Plugins/20 Cluster/75 DRS Rules.ps1 b/Plugins/20 Cluster/75 DRS Rules.ps1 index 8bfa8b01..36e342b1 100644 --- a/Plugins/20 Cluster/75 DRS Rules.ps1 +++ b/Plugins/20 Cluster/75 DRS Rules.ps1 @@ -28,11 +28,11 @@ if ($ShowVMAffinity) { $Types += "VMAffinity"} if ($ShowVMAntiAffinity) { $Types += "VMAntiAffinity"} if ($ShowHostAffinity) { $Types += "VMHostAffinity"} -$Clusters | Foreach { +$Clusters | Foreach-Object { Get-DrsRule -Cluster $_ -Type $Types | Where-Object { $_.Name -notmatch $excludeName } | Select-Object Cluster, Enabled, Name, Type, @{N="VM";E={(Get-View $_.VMIDS | Select-Object -ExpandProperty Name) -join "
"}}, @{N="Rule Host";E={(Get-View $_.AffineHostIds | Select-Object -ExpandProperty Name) -join "
" }}, - @{N="Running on";E={(Get-View (Get-View $_.VMIDS | %{$_.Runtime.Host}) | Select-Object ExpandProperty Name) -join "
"}} + @{N="Running on";E={(Get-View (Get-View $_.VMIDS | Foreach-Object {$_.Runtime.Host}) | Select-Object ExpandProperty Name) -join "
"}} } $Comments = ("Contains all DRS rules defined in this vCenter - {0}" -f ($types -join ",")) diff --git a/Plugins/30 Host/07 Hosts Overcommit State.ps1 b/Plugins/30 Host/07 Hosts Overcommit State.ps1 index 8d461733..6a696c3b 100644 --- a/Plugins/30 Host/07 Hosts Overcommit State.ps1 +++ b/Plugins/30 Host/07 Hosts Overcommit State.ps1 @@ -29,7 +29,7 @@ $VMHCount = $VMH | Measure Foreach ($VMHost in $VMH) { Write-Progress -ID 2 -Parent 1 -Activity $plang.pluginActivity -Status $VMHost.Name -PercentComplete ((100*$i)/$VMHCount.Count) if ($VMMem) { Clear-Variable VMMem } - $VM | ?{$_.VMHost.Name -eq $VMHost.Name -and $_.PowerState -ne "PoweredOff"} | Foreach { + $VM | Where-Object {$_.VMHost.Name -eq $VMHost.Name -and $_.PowerState -ne "PoweredOff"} | Foreach-Object { [INT]$VMMem += $_.MemoryMB } diff --git a/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 b/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 index 6cacae6e..764d01fd 100644 --- a/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 +++ b/Plugins/30 Host/08 Hosts Dead LUN Path.ps1 @@ -10,7 +10,7 @@ $PluginCategory = "vSphere" # End of Settings foreach ($esxhost in ($HostsViews | Where-Object {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { - $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.State -eq "Dead"} | %{ + $esxhost | Foreach-Object {$_.config.storageDevice.multipathInfo.lun} | Foreach-Object {$_.path} | Where-Object {$_.State -eq "Dead"} | Foreach-Object { New-Object PSObject -Property @{ VMHost = $esxhost.Name Lunpath = $_.Name diff --git a/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 b/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 index 4d95bd34..80db50f0 100644 --- a/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 +++ b/Plugins/30 Host/110 Host Certificate Expiration Check.ps1 @@ -90,6 +90,6 @@ namespace PKI { # Plugin to report on upcoming host certificate expirations # Check for Host Certificates -$VMH | Where-Object {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Foreach { Test-WebServerSSL -URL $_.Name | Select-Object OriginalURi, Issuer, @{N="Expires";E={$_.Certificate.NotAfter} }, @{N="DaysTillExpire";E={(New-TimeSpan -Start (Get-Date) -End ($_.Certificate.NotAfter)).Days} }|? {$_.DaysTillExpire -le $WarningDays}} +$VMH | Where-Object {$_.ConnectionState -eq "Connected" -or $_.ConnectionState -eq "Maintenance"} | Foreach-Object { Test-WebServerSSL -URL $_.Name | Select-Object OriginalURi, Issuer, @{N="Expires";E={$_.Certificate.NotAfter} }, @{N="DaysTillExpire";E={(New-TimeSpan -Start (Get-Date) -End ($_.Certificate.NotAfter)).Days} }|? {$_.DaysTillExpire -le $WarningDays}} $Header = ("Hosts with upcoming Certificate Expirations: {0} Days" -f $WarningDays) \ No newline at end of file diff --git a/Plugins/30 Host/44 VMKernel Warnings.ps1 b/Plugins/30 Host/44 VMKernel Warnings.ps1 index 20e92f8e..611019b5 100644 --- a/Plugins/30 Host/44 VMKernel Warnings.ps1 +++ b/Plugins/30 Host/44 VMKernel Warnings.ps1 @@ -42,7 +42,7 @@ foreach ($VMHost in ($HostsViews)){ $Warnings = (Get-Log -VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | Where-Object {$_ -match "warning"} if ($Warnings -ne $null) { $VMKernelWarning = @() - $Warnings | Foreach { + $Warnings | Foreach-Object { if ($simpleWarning) { $Details = "" | Select-Object VMHost, Message $Details.VMHost = $VMHost.Name diff --git a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 index a4783bbf..9da40342 100644 --- a/Plugins/30 Host/53 Hardware status warnings-errors.ps1 +++ b/Plugins/30 Host/53 Hardware status warnings-errors.ps1 @@ -9,17 +9,17 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -foreach ($HostsView in ($HostsViews|?{$_.runtime.connectionstate -eq "Connected"})) { +foreach ($HostsView in ($HostsViews|Where-Object {$_.runtime.connectionstate -eq "Connected"})) { $HealthStatus = ((Get-View ($HostsView).ConfigManager.HealthStatusSystem).runtime) $HWStatus = $HealthStatus.HardwareStatusInfo if ($HWStatus) { - $HWStatusProp = $HWStatus|gm|?{$_.membertype -eq "property"} - $HWStatusDetails = $HWStatusProp|%{$HWStatus.($_.name)}|?{$_.status.key -inotmatch "green" -band $_.status.key -inotmatch "unknown"}| Select-Object @{N="sensor";E={$_.name}},@{N="status";E={$_.status.key}} - $HealthStatusDetails = ($HealthStatus.SystemHealthInfo).NumericSensorInfo|?{$_.HealthState.key -inotmatch "green" -band $_.HealthState.key -inotmatch "unknown"}|Select-Object @{N="sensor";E={$_.name}},@{N="status";E={$_.HealthState.key}} + $HWStatusProp = $HWStatus|gm|Where-Object {$_.membertype -eq "property"} + $HWStatusDetails = $HWStatusProp|Foreach-Object {$HWStatus.($_.name)}|Where-Object {$_.status.key -inotmatch "green" -band $_.status.key -inotmatch "unknown"}| Select-Object @{N="sensor";E={$_.name}},@{N="status";E={$_.status.key}} + $HealthStatusDetails = ($HealthStatus.SystemHealthInfo).NumericSensorInfo|Where-Object {$_.HealthState.key -inotmatch "green" -band $_.HealthState.key -inotmatch "unknown"}|Select-Object @{N="sensor";E={$_.name}},@{N="status";E={$_.HealthState.key}} if ($HWStatusDetails) { foreach ($HWStatusDetail in $HWStatusDetails) { New-Object PSObject -Property @{ - Cluster = ($HostsView | %{(Get-View $_.Parent).Name}) + Cluster = ($HostsView | Foreach-Object {(Get-View $_.Parent).Name}) Host = $HostsView.name Sensor = $HWStatusDetail.sensor Status = $HWStatusDetail.status @@ -29,7 +29,7 @@ foreach ($HostsView in ($HostsViews|?{$_.runtime.connectionstate -eq "Connected" if ($HealthStatusDetails) { foreach ($HealthStatusDetail in $HealthStatusDetails) { New-Object PSObject -Property @{ - Cluster = ($HostsView | %{(Get-View $_.Parent).Name}) + Cluster = ($HostsView | Foreach-Object {(Get-View $_.Parent).Name}) Host = $HostsView.name Sensor = $HealthStatusDetail.sensor Status = $HealthStatusDetail.status diff --git a/Plugins/30 Host/68 Disk Max Total Latency.ps1 b/Plugins/30 Host/68 Disk Max Total Latency.ps1 index d41bb2c1..3e2c74a7 100644 --- a/Plugins/30 Host/68 Disk Max Total Latency.ps1 +++ b/Plugins/30 Host/68 Disk Max Total Latency.ps1 @@ -16,10 +16,10 @@ $diskmaxtotallatency = Get-vCheckSetting $Title "diskmaxtotallatency" $diskmaxto $stattotallatency = Get-vCheckSetting $Title "stattotallatency" $stattotallatency $HostsDiskLatency = @() -foreach ($VMHost in $VMH | ?{$_.ConnectionState -eq "Connected"}) { +foreach ($VMHost in $VMH | Where-Object {$_.ConnectionState -eq "Connected"}) { if ($VMHost.Version -lt 4){continue}# not an esx 4.x host $HostDiskLatency = @() - $VHHMaxLatency = $VMHost | get-stat -stat "disk.maxTotalLatency.latest" -start ($Date).addhours(-$stattotallatency) -finish ($Date)|?{$_.value -gt $diskmaxtotallatency}| Sort-Object Timestamp -Descending + $VHHMaxLatency = $VMHost | get-stat -stat "disk.maxTotalLatency.latest" -start ($Date).addhours(-$stattotallatency) -finish ($Date)|Where-Object {$_.value -gt $diskmaxtotallatency}| Sort-Object Timestamp -Descending if ($VHHMaxLatency.Count -gt 0) { $Details = "" | Select-Object Host, Timestamp, milliseconds $Details.host = $VMHost.name diff --git a/Plugins/30 Host/81 LUN Paths Check.ps1 b/Plugins/30 Host/81 LUN Paths Check.ps1 index 3d8f56f3..be9e03c9 100644 --- a/Plugins/30 Host/81 LUN Paths Check.ps1 +++ b/Plugins/30 Host/81 LUN Paths Check.ps1 @@ -17,7 +17,7 @@ $missingpaths = @() foreach ($esxhost in ($HostsViews | Where-Object {$_.Runtime.ConnectionState -match "Connected|Maintenance"})) { #Write-Host $esxhost.Name $lun_array = @() # 2D array - LUN Name & Path Count - $esxhost | %{$_.config.storageDevice.multipathInfo.lun} | %{$_.path} | ?{$_.name -like "fc.*"} | %{ + $esxhost | Foreach-Object {$_.config.storageDevice.multipathInfo.lun} | Foreach-Object {$_.path} | Where-Object {$_.name -like "fc.*"} | Foreach-Object { $short_path_array = $_.name.split('-') $short_path = $short_path_array[2] $found = $false diff --git a/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 b/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 index 87f82a40..1ecd7880 100644 --- a/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 +++ b/Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1 @@ -14,7 +14,7 @@ $ExcludedVMs = "" # Update settings where there is an override $ExcludedVMs = Get-vCheckSetting $Title "ExcludedVMs" $ExcludedVMs -$DatastoreClustersView | Foreach {$_.PodStorageDrsEntry.StorageDrsConfig.VMConfig} | ` +$DatastoreClustersView | Foreach-Object {$_.PodStorageDrsEntry.StorageDrsConfig.VMConfig} | ` Where-Object {$_.Enabled -eq $false -or $_.Behavior -ne $null} | ` Select-Object @{N="VM";E={Get-View $_.Vm | Select-Object -ExpandProperty Name}}, Enabled, Behavior,@{N="Datastore Cluster";E={$dc.Name}} | Where-Object { $_.VM -notmatch $ExcludedVMs } diff --git a/Plugins/60 VM/02 Snapshot Information.ps1 b/Plugins/60 VM/02 Snapshot Information.ps1 index 041469ff..3dae759c 100644 --- a/Plugins/60 VM/02 Snapshot Information.ps1 +++ b/Plugins/60 VM/02 Snapshot Information.ps1 @@ -79,7 +79,7 @@ function Get-SnapshotExtra ($snap){ $dummy = $collectionImpl.RewindCollector $collection = $collectionImpl.ReadNextTasks($tasknumber) while($collection -ne $null){ - $collection | Where-Object {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $guestName} | %{ + $collection | Where-Object {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $guestName} | Foreach-Object { $row = New-Object PsObject $row | Add-Member -MemberType NoteProperty -Name User -Value $_.Reason.UserName $vm = Get-View $_.Entity diff --git a/Plugins/60 VM/04 Map disk region event.ps1 b/Plugins/60 VM/04 Map disk region event.ps1 index b195dfad..9f4d9434 100644 --- a/Plugins/60 VM/04 Map disk region event.ps1 +++ b/Plugins/60 VM/04 Map disk region event.ps1 @@ -13,7 +13,7 @@ $eventAge = 5 # Update settings where there is an override $eventAge = Get-vCheckSetting $Title "eventAge" $eventAge -Get-VIEventPlus -Start ($Date).AddDays(-$eventAge) -Type Info | Where-Object {$_.FullFormattedMessage -match "Map disk region"} | Foreach {$_.vm}| Select-Object name |Sort-Object -unique +Get-VIEventPlus -Start ($Date).AddDays(-$eventAge) -Type Info | Where-Object {$_.FullFormattedMessage -match "Map disk region"} | Foreach-Object {$_.vm}| Select-Object name |Sort-Object -unique $Header = ("Map disk region event (Last {0} Day(s)): [count]" -f $eventAge) diff --git a/Plugins/60 VM/102 VM Logging.ps1 b/Plugins/60 VM/102 VM Logging.ps1 index 55832a03..69f31214 100644 --- a/Plugins/60 VM/102 VM Logging.ps1 +++ b/Plugins/60 VM/102 VM Logging.ps1 @@ -16,7 +16,7 @@ $RotateSize = 1000000 $KeepOld = Get-vCheckSetting $Title "KeepOld" $KeepOld $RotateSize = Get-vCheckSetting $Title "RotateSize" $RotateSize -$VM | Foreach { +$VM | Foreach-Object { $VMKeepOld = $_.ExtensionData.Config.ExtraConfig | Where-Object {$_.Key -eq "log.keepold"} | Select-Object -ExpandProperty Value $VMRotateSize = $_.ExtensionData.Config.ExtraConfig | Where-Object {$_.Key -eq "log.rotatesize"} | Select-Object -ExpandProperty Value diff --git a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 index 6cd95043..51390599 100644 --- a/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 +++ b/Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1 @@ -13,7 +13,7 @@ $HAVMresetold = 5 # Update settings where there is an override $HAVMresetold = Get-vCheckSetting $Title "HAVMresetold" $HAVMresetold -Get-VIEventPlus -Start ($Date).AddDays(-$HAVMresetold) -Type Info | ?{$_.FullFormattedMessage -match "reset due to a guest OS error"} |Select-Object CreatedTime,FullFormattedMessage | Sort-Object Sort-Object CreatedTime -Descending +Get-VIEventPlus -Start ($Date).AddDays(-$HAVMresetold) -Type Info | Where-Object {$_.FullFormattedMessage -match "reset due to a guest OS error"} |Select-Object CreatedTime,FullFormattedMessage | Sort-Object Sort-Object CreatedTime -Descending $Comments = ("The following VMs have been restarted by HA in the last {0} days" -f $HAVMresetold) diff --git a/Plugins/60 VM/28 Removable Media Connected.ps1 b/Plugins/60 VM/28 Removable Media Connected.ps1 index d0053cee..ca0d2c60 100644 --- a/Plugins/60 VM/28 Removable Media Connected.ps1 +++ b/Plugins/60 VM/28 Removable Media Connected.ps1 @@ -14,8 +14,8 @@ $IgnoreVMMedia = "" # Update settings where there is an override $IgnoreVMMedia = Get-vCheckSetting $Title "IgnoreVMMedia" $IgnoreVMMedia -$FullVM | ?{$_.runtime.powerState -eq "PoweredOn" -And $_.Name -notmatch $IgnoreVMMedia} | - % { $VMName = $_.Name; $_.config.hardware.device | ?{($_ -is [VMware.Vim.VirtualFloppy] -or $_ -is [VMware.Vim.VirtualCdrom]) -and $_.Connectable.Connected} | +$FullVM | Where-Object {$_.runtime.powerState -eq "PoweredOn" -And $_.Name -notmatch $IgnoreVMMedia} | + % { $VMName = $_.Name; $_.config.hardware.device | Where-Object {($_ -is [VMware.Vim.VirtualFloppy] -or $_ -is [VMware.Vim.VirtualCdrom]) -and $_.Connectable.Connected} | Select-Object @{Name="VMName"; Expression={ $VMName}}, @{Name="Device Type"; Expression={ $_.GetType().Name}}, @{Name="Device Name"; Expression={ $_.DeviceInfo.Label}}, diff --git a/Plugins/60 VM/30 Single Storage VMs.ps1 b/Plugins/60 VM/30 Single Storage VMs.ps1 index 3c673f5c..29824fa3 100644 --- a/Plugins/60 VM/30 Single Storage VMs.ps1 +++ b/Plugins/60 VM/30 Single Storage VMs.ps1 @@ -14,9 +14,9 @@ $LVMDoNotInclude = "Template_*|VDI*" # Update settings where there is an override $LVMDoNotInclude = Get-vCheckSetting $Title "LVMDoNotInclude" $LVMDoNotInclude -$unSharedDatastore = $storageviews | ?{-Not $_.summary.multiplehostaccess} | Select-Object -Expand Name +$unSharedDatastore = $storageviews | Where-Object {-Not $_.summary.multiplehostaccess} | Select-Object -Expand Name -$FullVM | ?{$_.Name -notmatch $LVMDoNotInclude} | ?{$_.Runtime.ConnectionState -notmatch "invalid|orphaned"} | %{$_.layoutex.file} | ?{$_.type -ne "log" -and $_.name -notmatch ".vswp$" -And $unSharedDatastore -contains $_.name.Split(']')[0].Split('[')[1]} | Select-Object Name +$FullVM | Where-Object {$_.Name -notmatch $LVMDoNotInclude} | Where-Object {$_.Runtime.ConnectionState -notmatch "invalid|orphaned"} | Foreach-Object {$_.layoutex.file} | Where-Object {$_.type -ne "log" -and $_.name -notmatch ".vswp$" -And $unSharedDatastore -contains $_.name.Split(']')[0].Split('[')[1]} | Select-Object Name # Change Log ## 1.4 : Added Get-vCheckSetting \ No newline at end of file diff --git a/Plugins/60 VM/37 VM Alarms.ps1 b/Plugins/60 VM/37 VM Alarms.ps1 index 367cd069..e52c39de 100644 --- a/Plugins/60 VM/37 VM Alarms.ps1 +++ b/Plugins/60 VM/37 VM Alarms.ps1 @@ -14,7 +14,7 @@ foreach ($VMView in ($FullVM | Where-Object {$_.TriggeredAlarmState})){ Foreach ($VMsTriggeredAlarm in $VMView.TriggeredAlarmState){ New-Object -TypeName PSObject -Property @{ Object = $VMView.name - Alarm = ($valarms |?{$_.value -eq ($VMsTriggeredAlarm.alarm.value)}).name + Alarm = ($valarms |Where-Object {$_.value -eq ($VMsTriggeredAlarm.alarm.value)}).name Status = $VMsTriggeredAlarm.OverallStatus Time = $VMsTriggeredAlarm.time } diff --git a/Plugins/60 VM/40 VCB Garbage.ps1 b/Plugins/60 VM/40 VCB Garbage.ps1 index ed0e911a..070bee97 100644 --- a/Plugins/60 VM/40 VCB Garbage.ps1 +++ b/Plugins/60 VM/40 VCB Garbage.ps1 @@ -10,4 +10,4 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$FullVM | ?{$_.snapshot | %{$_.rootsnapshotlist | ?{$_.name -contains "VCB|Consolidate|veeam|NBU_SNAPSHOT"}}} | Sort-Object Name | Select-Object Name \ No newline at end of file +$FullVM | Where-Object {$_.snapshot | Foreach-Object {$_.rootsnapshotlist | Where-Object {$_.name -contains "VCB|Consolidate|veeam|NBU_SNAPSHOT"}}} | Sort-Object Name | Select-Object Name \ No newline at end of file diff --git a/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 b/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 index 118ddb8f..9bc12356 100644 --- a/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 +++ b/Plugins/60 VM/45 VMs needing snapshot consolidation.ps1 @@ -10,5 +10,5 @@ $PluginCategory = "vSphere" # End of Settings $htabHostVersion = @{} -$HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)} -$FullVM | ?{$htabHostVersion[$_.runtime.host].Split('.')[0] -ge 5 -and $_.runtime.consolidationNeeded} | Sort-Object -Property Name | Select-Object Name,@{N="Consolidation needed";E={$_.Runtime.consolidationNeeded}} \ No newline at end of file +$HostsViews | Foreach-Object {$htabHostVersion.Add($_.MoRef,$_.config.product.version)} +$FullVM | Where-Object {$htabHostVersion[$_.runtime.host].Split('.')[0] -ge 5 -and $_.runtime.consolidationNeeded} | Sort-Object -Property Name | Select-Object Name,@{N="Consolidation needed";E={$_.Runtime.consolidationNeeded}} \ No newline at end of file diff --git a/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 b/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 index ad1f9218..f44ab3aa 100644 --- a/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 +++ b/Plugins/60 VM/50 VMs with CPU or Memory Limits Configured.ps1 @@ -9,4 +9,4 @@ $PluginCategory = "vSphere" # Start of Settings # End of Settings -$FullVM | ?{$_.config.cpuallocation.limit -ne "-1" -or $_.config.memoryallocation.limit -ne "-1"} | Select-Object Name, @{Name="CpuLimitMhz";E={$_.config.cpuallocation.limit}}, @{Name="MemLimitMB";E={$_.config.memoryallocation.limit}} \ No newline at end of file +$FullVM | Where-Object {$_.config.cpuallocation.limit -ne "-1" -or $_.config.memoryallocation.limit -ne "-1"} | Select-Object Name, @{Name="CpuLimitMhz";E={$_.config.cpuallocation.limit}}, @{Name="MemLimitMB";E={$_.config.memoryallocation.limit}} \ No newline at end of file diff --git a/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 b/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 index db340cd2..2ce911d6 100644 --- a/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 +++ b/Plugins/60 VM/62 Unwanted Virtual Hardware.ps1 @@ -15,7 +15,7 @@ $unwantedHardware = "VirtualUSBController|VirtualParallelPort|VirtualSerialPort" $unwantedHardware = Get-vCheckSetting $Title "unwantedHardware" $unwantedHardware foreach ($vmguest in $FullVM) { - $vmguest.Config.Hardware.Device | Where-Object {$_.GetType().Name -match $unwantedHardware} | %{ + $vmguest.Config.Hardware.Device | Where-Object {$_.GetType().Name -match $unwantedHardware} | Foreach-Object { New-Object -TypeName PSObject -Property @{ Name = $vmguest.name Label = $_.DeviceInfo.Label diff --git a/Plugins/60 VM/66 Misnamed VM.ps1 b/Plugins/60 VM/66 Misnamed VM.ps1 index 483fc5f4..f7b35333 100644 --- a/Plugins/60 VM/66 Misnamed VM.ps1 +++ b/Plugins/60 VM/66 Misnamed VM.ps1 @@ -15,7 +15,7 @@ $MNDoNotInclude = "VM1_*|VM2_*" $MNDoNotInclude = Get-vCheckSetting $Title "MNDoNotInclude" $MNDoNotInclude ($FullVM | Where-Object {$_.Runtime.PowerState -eq 'poweredOn' -AND $_.Name -notmatch $MNDoNotInclude -AND $_.Guest.HostName -ne "" -AND $_.Guest.HostName -notmatch $_.Name }) | - foreach { + Foreach-Object { $vmguest = $_ if ($vmguest.Parent -ne $null) { diff --git a/Plugins/60 VM/76 VM Network State.ps1 b/Plugins/60 VM/76 VM Network State.ps1 index b023b749..57b959d7 100644 --- a/Plugins/60 VM/76 VM Network State.ps1 +++ b/Plugins/60 VM/76 VM Network State.ps1 @@ -16,8 +16,8 @@ $ShowOnlyStartupNICS = Get-vCheckSetting $Title "ShowOnlyStartupNICS" $ShowOnlyS $VMsNetworkNotConnected = @() # Check only on powered on VMs -foreach ($myVM in $FullVM | ?{$_.runtime.powerState -eq "PoweredOn"}) { - foreach ($myCard in $myVM.config.hardware.device | ?{$_ -is [VMware.Vim.VirtualEthernetCard] -and -Not $_.connectable.connected}) { +foreach ($myVM in $FullVM | Where-Object {$_.runtime.powerState -eq "PoweredOn"}) { + foreach ($myCard in $myVM.config.hardware.device | Where-Object {$_ -is [VMware.Vim.VirtualEthernetCard] -and -Not $_.connectable.connected}) { if ($ShowOnlyStartupNICS -and $myCard.connectable.StartConnected) { # The network card is not connected. Warn user New-Object -TypeName PSObject -Property @{ diff --git a/vCheckUtils.ps1 b/vCheckUtils.ps1 index 067c8eaf..f0c5d6fb 100644 --- a/vCheckUtils.ps1 +++ b/vCheckUtils.ps1 @@ -136,7 +136,7 @@ function Get-vCheckPlugin foreach ($plugin in $plugins.pluginlist.plugin) { $pluginObjectList | Where-Object {$_.name -eq $plugin.name -and [double]$_.version -lt [double]$plugin.version}| - foreach{ + Foreach-Object { $_.status = "New Version Available - " + $plugin.version } if (!($pluginObjectList | Where-Object {$_.name -eq $plugin.name})) From 9e720fd2cb86e62315c3388872ec556fac809552 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Thu, 2 Mar 2017 15:52:37 +1100 Subject: [PATCH 47/50] $info is now ordered Since we required PS3 now, we can implement a fix for #494 --- Plugins/00 Initialize/01 General Information.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/00 Initialize/01 General Information.ps1 b/Plugins/00 Initialize/01 General Information.ps1 index 4cc84b17..3168f68f 100644 --- a/Plugins/00 Initialize/01 General Information.ps1 +++ b/Plugins/00 Initialize/01 General Information.ps1 @@ -26,7 +26,7 @@ else $MigrationQuery2 = Get-VIEventPlus -Start ($Date).AddDays(-$SDRSMigrateAge) -Type Info } -$Info = New-Object -TypeName PSObject -Property @{ +$Info = New-Object -TypeName PSObject -Property ([ordered]@{ "Number of Hosts" = (@($VMH).Count) "Number of VMs" = (@($VM).Count) "Number of Templates" = (@($VMTmpl).Count) @@ -34,7 +34,7 @@ $Info = New-Object -TypeName PSObject -Property @{ "Number of Datastores" = (@($Datastores).Count) "Active VMs" = (@($FullVM | Where-Object { $_.Runtime.PowerState -eq "poweredOn" }).Count) "In-active VMs" = (@($FullVM | Where-Object { $_.Runtime.PowerState -eq "poweredOff" }).Count) -} +}) # Don't display DRS line if 0 days are set if ($DRSMigrateAge -gt 0) { @@ -54,4 +54,4 @@ $Info # Changelog ## 1.1 : Adding some vSphere5 features (Storage Pod, StorageDRS migration) ## 1.2 : Generalised the DRS Event Log Queries for use here and Plugin 17, potentially more efficient if $DRSMigrateAge and $SDRSMigrateAge are equal -## 1.3 : Add Get-vCheckSetting calls \ No newline at end of file +## 1.3 : Add Get-vCheckSetting calls From 10cc84332bcfbefe078bf962aac12713c73c1c3b Mon Sep 17 00:00:00 2001 From: Ben Hocker Date: Sat, 11 Mar 2017 14:29:19 -0600 Subject: [PATCH 48/50] Fixing PowerCLI match --- Plugins/50 Network/98 vSwitch Security.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/50 Network/98 vSwitch Security.ps1 b/Plugins/50 Network/98 vSwitch Security.ps1 index 3d44813f..2063dbde 100644 --- a/Plugins/50 Network/98 vSwitch Security.ps1 +++ b/Plugins/50 Network/98 vSwitch Security.ps1 @@ -16,7 +16,7 @@ $MacChangesPolicy = $true # Check Power CLI version. Build must be at least 1012425 (5.1 Release 2) to contain Get-VDPortGroup cmdlet $VersionOK = $false -if (((Get-PowerCLIVersion) -match "VMware vSphere PowerCLI (.*) build ([0-9]+)")) { +if (((Get-PowerCLIVersion) -match "VMware.* PowerCLI (.*) build ([0-9]+)")) { if ([int]($Matches[2]) -ge 1012425) { $VersionOK = $true # Add required Snap-In @@ -84,6 +84,6 @@ $Title = "vSwitch Security" $Header = "vSwitch and portgroup security settings" $Comments = "All security options for standard vSwitches should be set to REJECT. Distributed vSwitches may require ForgedTrasmits in the default portgroup but should be disabled in other VM Network portgroups unless expressly required." $Display = "Table" -$Author = "Justin Mercier, Sam McGeown, John Sneddon" -$PluginVersion = 1.2 +$Author = "Justin Mercier, Sam McGeown, John Sneddon, Ben Hocker" +$PluginVersion = 1.3 $PluginCategory = "vSphere" From e76f1e1f97aaace0d223de6bf34590db4d107c67 Mon Sep 17 00:00:00 2001 From: Kevin Kirkpatrick Date: Fri, 17 Mar 2017 02:44:18 -0400 Subject: [PATCH 49/50] Updated README file to fix GFMD parsing issue There was an issue where GFMD didn't know how to handle an HTML tag being directly above a `# Heading` --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 4a464372..94fd9406 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ + # vCheck Daily Report for vSphere [![stars badge]][stars] [![forks badge]][forks] @@ -30,6 +31,7 @@ |[More Info](#More)| + # About [*Back to top*](#Title) @@ -43,6 +45,7 @@ This script is not to be confused with an Audit script, although the reporting f + # What is checked for in the vSphere version ? [*Back to top*](#Title) @@ -106,6 +109,7 @@ The following items are included as part of the vCheck vSphere download, they ar Copy the vCheck files to the desired location. Run the script `vCheckUtils.ps1` and call the function `Schedule-vCheck`. Answer the prompts to configure the scheduled job. + # Enhancements [*Back to top*](#Title) @@ -118,6 +122,7 @@ Copy the vCheck files to the desired location. Run the script `vCheckUtils.ps1` In the meantime, don't hesitate to pop over to the [#vCheck channel on slack](https://code.vmware.com/slack/) and join in on active conversations about anything you see- or don't see- here! + # Release Notes [*Back to top*](#Title) @@ -158,12 +163,14 @@ In the meantime, don't hesitate to pop over to the [#vCheck channel on slack](ht * 4.0 - HTML Tidy up, comments added for each item and the ability to enable/disable comments. + # Contributing [*Back to top*](#Title) See out [Contributions](CONTRIBUTING.md) guidelines + # Plugins [*Back to top*](#Title) @@ -265,6 +272,7 @@ $TableFormat = @{"PercentFree" = @(@{ "-le 25" = "Row,class|warning"; }, @{ "-le Here we see the rules that apply to two different columns, with rules applied to the values in a fashion similar to Example 1. + # Styles [*Back to top*](#Title) @@ -289,6 +297,7 @@ Additionally, if the style is to define colours to be used by charts, the follow To include image resources, you may call Add-ReportResource, specifying CID and data. As these are not referenced by table formatting rules, this will need to be called with the `-Used $true` parameter. + # Jobs & Settings [*Back to top*](#Title) @@ -359,6 +368,7 @@ PS E:\scripts\vCheck-vSphere> Import-vCheckSettings -csvfile E:\MyvCheckSettings If new settings or plugins have been added to the new build you will be asked to answer the questions, similar to running the initial config. During the import, the initial config is disabled, so once the import is complete you are ready to run your new build. + # More Info [*Back to top*](#Title) From 2d19b948dcd182856337a193a3d05dd7ddbb72a7 Mon Sep 17 00:00:00 2001 From: Sneddo Date: Fri, 28 Apr 2017 08:30:58 +1000 Subject: [PATCH 50/50] Fix Filename when port is specified Issue #555 - issues with saving the report when a port is specified in $Server --- vCheck.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vCheck.ps1 b/vCheck.ps1 index 4590f254..d703a3d3 100644 --- a/vCheck.ps1 +++ b/vCheck.ps1 @@ -1023,7 +1023,7 @@ if (-not $GUIConfig) { # Set the output filename if (-not (Test-Path -PathType Container $Outputpath)) { New-Item $Outputpath -type directory | Out-Null } - $Filename = ("{0}\{1}_vCheck_{2}.htm" -f $Outputpath, $Server, (Get-Date -Format "yyyyMMdd_HHmm")) + $Filename = ("{0}\{1}_vCheck_{2}.htm" -f $Outputpath, $VIServer, (Get-Date -Format "yyyyMMdd_HHmm")) # Always generate the report with embedded images $embedReport = $MyReport