Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
- Replacing foreach and %{ on the pipeline with Foreach-Object
- Replace  ?{ with Where-object
  • Loading branch information
Sneddo authored and Sneddo committed Feb 27, 2017
1 parent 3892b33 commit 137dfdd
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Plugins/20 Cluster/104 Clusters with no Host Profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
$clusviews | Where-Object {($HostProfiles | Select-Object -expandProperty ClusterID) -notcontains $_.moref } | Sort-Object Name | Select-Object Name
2 changes: 1 addition & 1 deletion Plugins/20 Cluster/52 Datastore Consistency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}
Expand Down
2 changes: 1 addition & 1 deletion Plugins/20 Cluster/70 Cluster Node Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ";" }
Expand Down
4 changes: 2 additions & 2 deletions Plugins/20 Cluster/75 DRS Rules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<br />"}},
@{N="Rule Host";E={(Get-View $_.AffineHostIds | Select-Object -ExpandProperty Name) -join "<br />" }},
@{N="Running on";E={(Get-View (Get-View $_.VMIDS | %{$_.Runtime.Host}) | Select-Object ExpandProperty Name) -join "<br />"}}
@{N="Running on";E={(Get-View (Get-View $_.VMIDS | Foreach-Object {$_.Runtime.Host}) | Select-Object ExpandProperty Name) -join "<br />"}}
}

$Comments = ("Contains all DRS rules defined in this vCenter - {0}" -f ($types -join ","))
Expand Down
2 changes: 1 addition & 1 deletion Plugins/30 Host/07 Hosts Overcommit State.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion Plugins/30 Host/08 Hosts Dead LUN Path.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Plugins/30 Host/110 Host Certificate Expiration Check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion Plugins/30 Host/44 VMKernel Warnings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Plugins/30 Host/53 Hardware status warnings-errors.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Plugins/30 Host/68 Disk Max Total Latency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Plugins/30 Host/81 LUN Paths Check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Plugins/40 Datastore/116 sDRS VM Behavior not Default.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion Plugins/60 VM/02 Snapshot Information.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Plugins/60 VM/04 Map disk region event.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion Plugins/60 VM/102 VM Logging.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Plugins/60 VM/14 VMs restarted due to Guest OS Error.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions Plugins/60 VM/28 Removable Media Connected.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
4 changes: 2 additions & 2 deletions Plugins/60 VM/30 Single Storage VMs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Plugins/60 VM/37 VM Alarms.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion Plugins/60 VM/40 VCB Garbage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
$FullVM | Where-Object {$_.snapshot | Foreach-Object {$_.rootsnapshotlist | Where-Object {$_.name -contains "VCB|Consolidate|veeam|NBU_SNAPSHOT"}}} | Sort-Object Name | Select-Object Name
4 changes: 2 additions & 2 deletions Plugins/60 VM/45 VMs needing snapshot consolidation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
$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}}
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
$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}}
2 changes: 1 addition & 1 deletion Plugins/60 VM/62 Unwanted Virtual Hardware.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Plugins/60 VM/66 Misnamed VM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Plugins/60 VM/76 VM Network State.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 @{
Expand Down
2 changes: 1 addition & 1 deletion vCheckUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
Expand Down

0 comments on commit 137dfdd

Please sign in to comment.