• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Yellow Bricks

by Duncan Epping

  • Home
  • Unexplored Territory Podcast
  • HA Deepdive
  • ESXTOP
  • Stickers/Shirts
  • Privacy Policy
  • About
  • Show Search
Hide Search

powershell

Add RDM Size info to VI Client using Powershell

Duncan Epping · Dec 19, 2008 ·

Hugo keeps on going writing and updating his powershell scripts! This time Hugo created a script that adds a custom field to your VC with RDM disk size info:

In the VMware VI Toolkit Communities, a request was made for a similar script that adds the total size of all Raw Device Mappings (RDMs) on a VM to a Custom Field in the VI Client.

Visit his article for the script and the complete blogpost. Don’t forget to download the updated versions of the other custom field related scripts.

Add Custom Fields to VI Client with Powershell Part 2!

Duncan Epping · Dec 17, 2008 ·

Yesterday I blogged about the Powershell script that Hugo Peeters created for adding a snapshot Column to your VI Client with Powershell. Hugo used a custom field to show this data and I wrote the following:

Some of you might say that this lacks the detail one would love to see within vCenter. Well knowing Hugo my guess it that this will evolve fast, and I expect some cool additions coming up.

Well I wasn’t expecting Hugo to be this quick, but he just blogged about four new additions:

Total Snapshot Size

The number of snapshots is quite interesting, but even more interesting, is the total size of the delta files all snapshots are occupying. They might be eating up all your precious SAN space. Plus, reverting to or committing a large snapshot is tricky. Add-VMSnapshotSize.ps1

Host Hardware Model

Want to see what models of hardware you are using in your datacenter? You could look at the summary tab of each host. Or run this script to add the info to the every Hosts tab in the VI Client. Select your Datacenter, select the Hosts tab and enjoy! Add-VMHostModel.ps1

Host ESX Version

Did you update all your ESX Servers to the latest version? Check it quickly using this script. Add-VMHostVersion.ps1

Host LUN Count

Last but certainly not least: are you sure every datastore you are using is available to all your ESX Servers? It is visible at a glance when you add the LUN Count to your VI Client! Add-VMHostLUNCount.ps1

So what can we expect in the future? I really don’t know… but my guess is that we can expect a lot more coming up over the next few days.

[update: if any of the links fail, here’s the source article.]

Snapshot info within vCenter?

Duncan Epping · Dec 16, 2008 ·

snapsHugo Peeters has done it again. He created another very usefull script. This time Hugo created a script which adds a “custom field” within vCenter with Snapshot information, the amount of snapshots that is.

Some of you might say that this lacks the detail one would love to see within vCenter. Well knowing Hugo my guess it that this will evolve fast, and I expect some cool additions coming up.

If you don’t want to wait just check his post, download the code and start modifying / adding yourself. Hugo outlined the concept so it should be fairly easy to add new functionality to it.

And if you haven’t done it by now, add Hugo’s blog to your RSS Reader or Bookmarks!

HAL check?!

Duncan Epping · Nov 14, 2008 ·

My post about reverting your HAL triggered Alanrenouf to create a short, but very cool script that compares the amount of cpu’s to the windows HAL you’ve chosen. This way you will know within a second if you need to change the HAL of any of your vm’s! Cool stuff:

connect-viserver MYVISERVER
$myCol = @()
ForEach ($VM in (Get-VM))
{
$MyDetails = “” | select-Object Name, HAL, NumvCPU
$MYDetails.Name = $VM.Name
$Hal = Get-WmiObject -ComputerName $VM.Name -Query “SELECT * FROM Win32_PnPEntity where ClassGuid = ‘{4D36E966-E325-11CE-BFC1-08002BE10318}'” | Select Name
$MYDetails.HAL = $Hal.Name
$MYDetails.NumvCPU = $VM.NumCPU
$myCol += $MYDetails
}
$myCol

Adding users + roles with powershell

Duncan Epping · Nov 6, 2008 ·

So you can easily add users with useradd command we talked about. But there’s still a problem, you can’t add user-roles to the user you’re creating. You still need the VirtualCenter client to do that. My colleague Horst Mundt read my post and was so kind to email me a powershell script he created that can add roles to specific users or groups for you:

$VCimpl = Get-VIServer -Server 192.168.116.201 -User root -Password <...>
# Note: Server is an ESX host, not VC
# Force load
[Reflection.Assembly]::LoadWithPartialName("vmware.vim")

# Edit hostname below
$hostname = "esx302.hm.local" 

# The name of the role to be assigned
$roleLabel="Read-Only"
#$roleLabel="Administrator"

#The name of the principal (user or group) that the role is assigned to
$principal="GroupX"

# set to false if principal is a user , not a group
$principalIsGroup = $true

$propagateToSubEntities = $true

$svcRef = new-object VMware.Vim.ManagedObjectReference 
$svcRef.Type = "ServiceInstance" 
$svcRef.Value = "ServiceInstance" 
$serviceInstance = get-view $svcRef

$authMgr = Get-View $serviceInstance.Content.AuthorizationManager
$hahost = Get-View (Get-VMhost -Name $hostname).ID
$compResource = $hahost.Parent
$oldperms = $authMgr.retrieveEntityPermissions($hahost.MoRef, $true)
$roles = $authMgr.roleList
$roleid = 0
$found = $false
for ($i = 0 ; $i -lt $roles.Length ; $i++)
{
      $role=$roles[$i]
      if ($role.Info.Label -eq $roleLabel)
      {
            $roleid = $role.RoleId
            $found = $true
      }
}
if ( $found -eq $false )
{
      echo ("Role not found: " + $roleLabel )
      exit 1
}

$permission = New-Object Vmware.Vim.Permission
$permission.group = $principalIsGroup
$permission.principal = $principal
$permission.propagate = $propagateToSubEntities
$permission.roleID = $roleid
$authmgr.SetEntityPermissions($compResource, @($permission))

The script has been tested on ESX 3.0.2. I did not have the opportunity to test it myself by the way… So if anyone can test it against ESX 3.5 and let’s us know what the results are!

  • « Go to Previous Page
  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Page 5
  • Go to Next Page »

Primary Sidebar

About the Author

Duncan Epping is a Chief Technologist and Distinguished Engineering Architect at Broadcom. Besides writing on Yellow-Bricks, Duncan is the co-author of the vSAN Deep Dive and the vSphere Clustering Deep Dive book series. Duncan is also the host of the Unexplored Territory Podcast.

Follow Us

  • X
  • Spotify
  • RSS Feed
  • LinkedIn

Recommended Book(s)

Advertisements




Copyright Yellow-Bricks.com © 2025 · Log in