Archive

Posts Tagged ‘PowerShell’

Keep it simple stupid – registering unregistered vm’s

July 27th, 2009 Sid Smith No comments

Last week my boss came to me and asked if I could write a script for a customer to register VM’s after being replicated from once VI environment to another.  I agreed to take on the project and go for it.

Like everything I do these days I decided to use powershell to write the script.  I have taken a liking to it and the fact that I can run the scripts on both ESX and ESXi hosts saves me from having to re-create scripts all the time.  So I plugged away to 3am wrote the script, tested it inside out and sideways in my lab.  I was confident in the scripts ability to register all vm’s form all datastores I went ahead and sent it off to the customer.

Read more…

Get Hal’s PowersHell Book Here!

April 30th, 2009 Dave Convery No comments

This is just a shameless plug to try selling books on DailyHypervisor.com…As you already know, Hal Rottenberg has written a book called “Managing VMware Infrastructure with Windows PowerShell TFM

Get it here:

Read more…

VI Toolkit powershell simple script #4 – VM Information

April 1st, 2009 Sid Smith No comments

This is a good powershell script for tacking virtual machine inforamtion for change management. It will output the vm’s name, the host it is on, the powerstate, Memory, Number of CPU’s, IP address, and FQDN to a csv file.


$IPprop = @{ Name = "IP Address"; Expression = { $_.Guest.IpAddress } }
$HostNameProp = @{ Name = "Hostname"; Expression = { $_.Guest.Hostname } }
Get-VM | select name, host, powerstate, MemoryMB, numCPU, $IPprop, $HostNameProp | export-csv c:\vm_info.csv

VI Toolkit powershell simple script #3 – Find Snapshots

March 31st, 2009 Sid Smith No comments

This really isn’t a script but more of a command but I think everyone gets the idea.

Find VM Snapshots for all servers in Virtual Infrastructure and display the VM Name, Snapshot Name, Date Created and power state. You can limit the VM’s this affects by using the location specific commands covered earlier.

Get-snapshot –vm (get-vm) | select vm, name, created, powerstate | export-csv [path_filename_csv]

Read more…

VI Toolkit powershell simple script #2 – Create new NFS datastore

March 21st, 2009 Sid Smith No comments

This simple little useful script can be used to add a new nfs datastore to all the hosts in an esx cluster.  Alternatively you can modify this and replace get-cluster CLUSTER_NAME with get-datacenter DATACENTER_NAME and add an ISO nfs share to your whole datacenter.

foreach ($ESXhost in get-cluster CLUSTER_NAME| get-vmhost)
                   {
                          New-datastore –nfs –vmhost $ESXhost –name [datastore_name] –path [/remote_path] –nfshost [nfs_server]
                   }

Read more…

VI Toolkit powershell simple script #1 – Create new portgroup

March 20th, 2009 Sid Smith No comments

This simple little usefull script can be used to create a portgroup at the cluster level.  This enables you to create it once and have it be consistently deployed to all the ESX and/or ESXi hosts in your cluster.

foreach ($ESXhost in get-cluster CLUSTER_NAME| get-vmhost)

Read more…