Archive

Archive for October, 2010

Create an ‘Internal’ vSwitch with PowerCLI

October 27, 2010 1 comment

I was looking for the correct syntax to create a vSwitch with PowerCLI which has no vmnics attached (aka: Internal vSwitch).

 

I tried to run the following cmdlet.  The pNIC’s are specified with the –Nic parameter.

Get-VirtualSwitch -VMHost "ServerName" -Name "vSwitchName" | Set-VirtualSwitch -Nic "" -Confirm:$false

But this resulted in a nice error 🙂

image

Read more…

How to use Try – Catch in PowerCLI the easy way

October 13, 2010 Leave a comment

Sometimes you need to check if something exists.  For example, let’s check if a specific user exists on our ESX host (you need to connect directly to the ESX host for this example to work).

 

We do this by running:

Get-VMHostAccount -Id UserName

Read more…

Categories: PowerCLI, PowerShell, vSphere

Add license to a vSphere host

October 13, 2010 Leave a comment

This is a rather short PowerCLI post.

Licensing is not directly available in PowerCLI cmd-lets, so we’ll have to reach out to the SDK, which is easily accessible from PowerShell.  We’ll have to fetch a LicenseAssignmentManager to set the license, so this mean using quite some Get-View cmdlets.  These could all be combined into a single line of code but makes it hard to read.

$strVMHostName is the name of your ESX(i) server to license

$strLicense is your licensekey.  All zero’s like in the example sets the host to evaluation mode.

 

Enjoy!

$strVMHostName = "HostName.domain.com"

$strLicense = "00000-00000-00000-00000-00000"

 

$objServiceInstance = Get-View -Id ServiceInstance -Property Content.LicenseManager

$objLicenseManager = Get-View -Id $objServiceInstance.Content.LicenseManager -Property LicenseAssignmentManager

$objLicenseAssignmentManager = Get-View -Id $objLicenseManager.LicenseAssignmentManager

$objVMHost = Get-View -ViewType "HostSystem" -Filter @{Name=$strVMHostName} -Property Config.Host

$objLicenseAssignmentManager.UpdateAssignedLicense($objVMHost.Config.Host.Value, $strLicense, $null)

 

Categories: PowerCLI, PowerShell, vSphere

Load Balance your Exchange Mailboxes across Databases on one or multiple servers.

October 5, 2010 10 comments

A while ago i wrote a script to distribute Exchange mailboxes evenly across different mailbox databases on one server.

Recently, that customer installed an additional mailbox server.  So the script needed an update to distribute the mailboxes evenly across multiple servers.

Here is the explanation of the script:

Read more…

Categories: Uncategorized