Emailing vCloud Organization Users

June 11, 2013

Table of Contents

Due to a lot of requests I found necessary to show you guys who might be having a problem using the “notify users” function in the vCloud Director web UI through the vCloud API. Even though the functionality is not in the API , PowerCLI and Powershell make work easier with the vCloud snap-in and powershell’s send-MailMessage cmdlet.

This example is sending an email to all Org users reminding them of the number of VMs they have in particular organization. The good thing about this code it can be adapted to show; resource usage, IP addresses OS usage. It also has the ability to be used in either a system admin role or an organization admin role:

$mailServer = “mail.example.com”

$users = Get-CIUser # use -Org “OrgName” if connected to system Org

$VApps = Get-CIVApp # use -Org “OrgName” if connected to system Org

foreach ($user in $users)

{

 $counter = 0

 $ownerVApps = $VApps | where {$_.owner -eq $user}

 $vapps | ForEach-Object {$counter += $_.extensiondata.children.vm.count}

$mailbody = “Greetings, You currently have $counter virtual machines in Organization: $($user.Org)”

Send-MailMessage -SmtpServer $mailServer -To $user.email -From “[email protected]” -Body $mailbody

}

Home

Share on
Facebook
Twitter
LinkedIn
Pinterest
More posts

Dedicated Servers Quick Guide

What is a Dedicated Servers? Why bother using a dedicated server over a VPS or Shared Hosting?A dedicated server is a server 100% dedicated to your website/project or business needs.

Power combined: PowerCLI and OVFTool

Power combined: Combining two good things creates wonders. In this post I will show how to combine the automation abilities of PowerCLI with OVFTool. You first have to get some

RVTools 3.3 Now Available

Good news: RVTools 3.3 from Rob de Veij is now generally available to the public.  Release notes for this build: GetWebResponse time-out value changed from 5 minutes to 10 minutes

Get 90% Discount

First 3 People gets the Bonus!
Don't Miss Out Our Big Sale

Get 0-90% On All
247Rack Services

247Rack

The Sale Is Until The End Of March