Advertisement Header

Tuesday 29 June 2010

Running a PowerCLI Scheduled task

There are two ways of doing this really:

1. Add a line to a start of each of your scripts to make sure it loads the PowerCLI snapin, without which PowerShell will not recognise any of the PowerCLI cmdlets.

Add the following line to the top of each script you will be running as a scheduled task:

add-pssnapin VMware.VimAutomation.Core

Then in the run box on your scheduled task you can call your script with the following command:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe “& ‘C:\Scripts\MyScript.ps1′”

But remember when you are troubleshooting this script or amending it you will most likely get an error as your script editor will automatically add the VMware snapin.

2. This method is the one I use as its easier than remembering to put the line at the top of each file and then commenting it out when you want to edit it etc, this method runs the PowerCLI Console file before it runs your script.

A PowerShell Console file is a xml like file containing information on what snapins to load when PowerShell is started.

This will enable the snapin for you and there is nothing to ad to the scripts.

The run command then looks like this:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& 'C:\Host-Inventory-Status.ps1'"

You can test both of these methods by running them from a cmd prompt before using it to ensure they work properly.

Monday 28 June 2010

How do I put Count Line numbers on an output

Command:
(get-vmhost).count

Output will be like this:
51

(or)

Command : get-vmhost | measure-object

Output will be:
Count : 51
Average :
Sum :
Maximum :
Minimum :
Property :

Thursday 24 June 2010

To manage more than one VirtualCenter server & ESX at a time

If you want to connect to more than one virtual center at the same time, here the starting code :

$vcs = @()
$vcs += connect-viserver "vc 1"
$vcs += connect-viserver "vc 2"
# You could add many as you need...

# Command example : Snapshot all VMs across all VirtualCenter servers.
get-vm -server $vcs | new-snapshot

Note:-
Be careful, the command GET-VM $VCS will not return the same values than GET-VM.
If you use GET-VM, you will receive the VM List only for the Virtual Center that you connect last. If you want the get all the VM of your different virtual centers, you absolutely need to add the parameter -server $vcs to you command. In a general way, don’t forget to add -server $vcs to every command than you use with the VI Toolkit.

Monday 14 June 2010

A few notes about the new VCAP certifications

Here's a colleciton of lots of things I've learned about the new VMware Certified Advanced Professional certifications for vSphere 4:

* The DataCenter Administration exam will be 100% live labs
* Your score for the DataCenter Administration exam will not be given immediately on completion of the exam, just like the Enterprise Administration exam for VI3 today
* The DataCenter Administration exam will cost $400, the price for the DataCenter Design exam has not yet been set
* The DataCenter Design exam will be a mixture of multiple-choice questions, and a design exercise, as it is today for VI3
* The testing centres for the DataCenter Administration exam will be expanded to a significantly larger pool than it is today
* The new exams will be scheduled directly with Pearson Vue, only the VCDX design defence will need arranging directly with VMware
* The blueprint documents for the new exams are still in development and will be released soon
* The new exams will not have compulsory training course requirements
* The advanced-level Performance, Troubleshooting, and Security courses are recommended as preparation for the DataCenter Administration exam, the exam content is centred around those 3 key areas
* The vSphere: Design Workshop will be excellent preparation for the DataCenter Design exam, the workshop content covers all of the objectives in the exam
* The beta periods for both exams will begin shortly, and will be invitation-only
* VMware partner requirements will not include VCAP certifications at this time

Advanced-level vSphere certifications


VMware have now officially announced the three advanced-level certifications for vSphere 4:

1. VMware Certified Advanced Professional on vSphere 4 - Datacenter Administration (VCAP-DCA)
2. VMware Certified Advanced Professional on vSphere 4 - Datacenter Design (VCAP-DCD)
3. VMware Certified Design Expert on vSphere 4 - Datacenter Design (VCDX4-DCD)

PowerCLI: One-Liner to get VMs, Clusters, ESX Hosts and Datastores

Get-VM | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}},
@{N="ESX Host";E={Get-VMHost -VM $_}},
@{N="Datastore";E={Get-Datastore -VM $_}} |
Export-Csv -NoTypeInformation C:\Scripts\VM_CLuster_Host_Datastore.csv