All posts by Aaron Gruber

PowerCLI: Get VM disk usage per cluster

powercli

 

 

Today I was asked to gather a list of all VMs within a given cluster and report on their disk usage (all the VMs are thick provisioned) and currently do not have a tool to perform a seemly simple task. After some searching I have found many versions of this script around the internet but none that quite suited me needs. I have modified about 50% of the original script to suit my needs and added these features.

  • Prompts for vCenter hostname or IP
  • Requires user to select a cluster
  • Queries vCenter for list of cluster names (for use above)
  • Limits results to specified cluster
  • Prompts for output filename
  • Default saves to current user’s Documents folder
  • Prints location of filename
  • Auto launches file once complete

I should also mention that I am not a script writer. My abilities exist in finding, understanding (most of the time), and modifying existing Powershell scripts. I will be unable to assist with drastic modifications to any script.

Requirements: VMware PowerCLI, vCenter Credentials with appropriate permissions

How to run: Save below script to .ps1 format and run from PowerCLI. No need to modify anything to make compatible with your environment.

$vCenterName = Read-Host -Prompt ‘Enter vCenter hostname or IP’
Write-Host “Connecting…”
connect-viserver $vCenterName

$MyCollection = @()

get-cluster | select-object name
$ClusterName = Read-Host -Prompt ‘Enter Cluster Name (must be exact)’
$ClusterFilter = get-view -ViewType ClusterComputeResource -Property Name -Filter @{“Name” = $ClusterName } | select -ExpandProperty MoRef

$AllVMs = Get-View -ViewType VirtualMachine -SearchRoot $ClusterFilter | Where {-not $_.Config.Template}
$SortedVMs = $AllVMs | Select *, @{N=”NumDisks”;E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks

ForEach ($VM in $SortedVMs){
$Details = New-object PSObject
$Details | Add-Member -Name Name -Value $VM.name -Membertype NoteProperty
$DiskNum = 0
Foreach ($disk in $VM.Guest.Disk){
$Details | Add-Member -Name “Disk$($DiskNum)path” -MemberType NoteProperty -Value $Disk.DiskPath
$Details | Add-Member -Name “Disk$($DiskNum)Capacity(MB)” -MemberType NoteProperty -Value ([fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][math]::Round($disk.Capacity/ 1MB))
$Details | Add-Member -Name “Disk$($DiskNum)FreeSpace(MB)” -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB))
$DiskNum++
}
$MyCollection += $Details
}

$OutputFileName = Read-Host ‘Enter filename including extension (.csv)’
$MyCollection | Export-Csv $env:USERPROFILE\Documents\$OutputFileName

Write-Host “File has been saved to” $env:USERPROFILE\Documents\$OutputFileName

explorer.exe $env:USERPROFILE\Documents\$OutputFileName

# Out-GridView, Export-Csv, ConvertTo-Html or ConvertTo-Xml can be used above instead

 


[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

Updating DNS, NTP, and Domain via PowerCLI

To start off with, I did not write this script but I have tested a modified version of it (removed NTP and Domain pieces) as I did not need to perform everything it does.

 


# PowerCLI Script to Configure DNS and NTP on ESXi Hosts
# PowerCLI Session must be connected to vCenter Server using Connect-VIServer

# Prompt for Primary and Alternate DNS Servers
$dnspri = read-host “Enter Primary DNS”
$dnsalt = read-host “Enter Alternate DNS”

# Prompt for Domain
$domainname = read-host “Enter Domain Name”

#Prompt for NTP Servers
$ntpone = read-host “Enter NTP Server One”
$ntptwo = read-host “Enter NTP Server Two”

$esxHosts = get-VMHost

foreach ($esx in $esxHosts) {

Write-Host “Configuring DNS and Domain Name on $esx” -ForegroundColor Green
Get-VMHostNetwork -VMHost $esx | Set-VMHostNetwork -DomainName $domainname -DNSAddress $dnspri , $dnsalt -Confirm:$false

Write-Host “Configuring NTP Servers on $esx” -ForegroundColor Green
Add-VMHostNTPServer -NtpServer $ntpone , $ntptwo -VMHost $esx -Confirm:$false

Write-Host “Configuring NTP Client Policy on $esx” -ForegroundColor Green
Get-VMHostService -VMHost $esx | where{$_.Key -eq “ntpd”} | Set-VMHostService -policy “on” -Confirm:$false

Write-Host “Restarting NTP Client on $esx” -ForegroundColor Green
Get-VMHostService -VMHost $esx | where{$_.Key -eq “ntpd”} | Restart-VMHostService -Confirm:$false

}
Write-Host “Done!” -ForegroundColor Green

Credit for this script goes to vHersey
Full article fond HERE

EMC and VMware Introduce Hyper-Converged VCE VXRAIL Appliance Family

index
333590
vmware
STORY HIGHLIGHTS
·         Delivers a jointly engineered, simple and proven turnkey VCE Appliance Family for use cases including small/midsize data centers and for enterprise departmental and edge environments
·         Incorporates software from EMC/VCE and VMware including VMware’s hyper-converged software
·         Starts small with a list price of $60,000 and scales to match a variety of workloads with a range of configurations including all-flash options with 2x more flash than any other hyper-converged infrastructure appliance
·         Seamlessly integrates with existing VMware ecosystem management solutions for streamlined deployment and management in VMware environments
·         Integrated VCE VxRail Manager for deep element management and monitoring along with a full suite of best-of-breed data services from EMC and VMware, including deduplication, compression, replication and backup
·         EMC cloud tiering to public clouds, such as Virtustream, VMware vCloud Air, Amazon Web Services and Microsoft Azure
·         Expands one of the industry’s most comprehensive and complete converged and hyper-converged portfolio, including VCE’s Vblock™, VxBlock™ and VxRack™ Systems, that uniquely cover every customer, every workload and every scale point with the ability to manage any combination of infrastructure centrally.

VMware Confirms Layoffs

 

Very interesting article posted yesterday and getting a lot of attention today.

 

vmware

VMware confirmed that it was laying off 800 employees today as part of its fourth quarter earnings statement. The layoffs had been originally reported by Fortune last week.

The move appears to be part of the ongoing dance among EMC federated companies prior to the Dell acquisition expected to go through later this year. Dell announced it was buying EMC in October for $67 billion. EMC owns 80 percent of VMware, but it operates as a separate, independent company with its own stock. It decides when to make layoffs and other strategic decisions.

 

Read the entire article here

My vCenter C: drive ran out of space

I came across something interesting today. The 160 GB C: drive on my vCenter Server ran out of space today…rather embarrassing. The first thing I checked is why in the heck my alerts didn’t go off…ok..problem fixed. After a couple of Google searches I came across and interesting VMware KB. Apparently there is a bug in the vCenter 5.5 upgrade that enables debug logging on the VMware Syslog Collector service and logs to C:\ProgramData\VMware\VMware Syslog Collector\logs\debug.log. In this case, my debug log was 62GB. The fix is rather simple. Stop the ‘VMware Syslog Collector’ service and edit the C:\ProgramData\VMware\VMware Syslog Collector\vmconfig-syslog.xml file (make a copy of it first) and change the following:

<debug> <level>1</level> </debug>

to

<debug> <level>0</level> </debug>

 

Remove the debug.log file and start the service again.

 

After upgrading to vCenter Server 5.5, the debug.log file of syslog collector is growing without limit (2094175)

KB: 2094175

  • Updated: Mar 3, 2015
  • Categories:
    Troubleshooting
  • Languages:
    English
  • Product(s):
    VMware vCenter Server
  • Product Version(s):
    VMware vCenter Server 5.5.x

 

Symptoms

  • After upgrading to vCenter Server 5.5, the debug.log file of syslog collector is growing without limit
  • C:\ProgramData\VMware\VMware Syslog Collector\logs\debug.log continues to grow without being rotated

Resolution

This is a known issue affecting VMware Syslog Collector 5.5.

 

Currently, there is no resolution.

To work around this issue:

  1. Stop the VMware Syslog Collector service. For more information, see Stopping, starting, or restarting VMware vCenter Server services (1003895).
  2. On the server running the VMware Syslog Collector service, navigate to C:\ProgramData\VMware\VMware Syslog Collector and save a copy of vmconfig-syslog.xml.
  3. In a text editor, open vmconfig-syslog.xml and modify  from:

    <debug> <level>1</level> </debug>

    to

    <debug> <level>0</level> </debug>

  4. Start the VMware Syslog Collector service. For more information, see Stopping, starting, or restarting VMware vCenter Server services (1003895).

 

-Aaron

Get-Blogger -identity “Aaron Gruber” -Blog vBrainstorm | Export-ToInternet http://vbrainstorm.com

Hello, my name is Aaron Gruber. I am a first time blogger on the site and excited to share my knowledge and experiences with my fellow colleges. I am a Systems Administrator for Array Services Group in Sartell, MN. I have experiences in a variety of Microsoft products (AD, Exchange, SQL, etc…) but my main focus is data center infrastructure. I am responsible for maintaining 28 VMware vSphere hosts, two EMC VNX SANs, one Compellent SAN, three Cisco UCS blade centers, and about a thousand other things. I have been in the Server Admin role for four years at my current employer, one and a half years as a Systems Admin at an Orthopedic Clinic, and about a year as a Dell PC technician. I am involved with the Minneapolis VMware User Group (VMUG) and its leaders which has provided a wealth of knowledge and contacts.

This year will be my first year going to VMworld and I am very excited to be a part of it. I have heard many stories of meeting interesting people and learning about technology at levels normally never discussed. If anyone has any hints, recommendations, or warnings I would appreciate any feedback. My twitter handle is @virtualroads. Looking forward to seeing you all there and look for my posts about VMworld content.

-Aaron

PS: constructive criticism welcome