Virtu-Al.Net

Virtually everything is poshable

SCRIPT LIST

This page will give you a direct link to all scripts and useful one-liners I have written.


Getting Started

 

Name

Brief Description

Link

Icomasoft PowerCLI Reference Card

PowerCLI reference card Click Here
VI Toolkit Quick Reference Guide Quick reference guide of the VI Toolkit cmdlets Click Here
PowerShell Get-Member fun An example of using Get-Member Click Here
Getting Started with the VI Toolkit A guide on how to get started Click Here


Virtual Machines

 

Name

Brief Description

Link

More HAL Information List VM/Num vCPU/HAL/OS Version/Service Pack Click Here

last 10 VMs created and removed

List all VMs created or deleted over a period of time or last x number Click Here
Local stored VMs List all VM’s located on local storage Click Here
More one-Liner power Set the CPU and Memory limits on multiple VMs
Find a VM with a specific Mac Address
Click Here
Stats One-Liner List each VM and the average CPU/Memory over x amount of days Click Here
More One Liners List number of VM’s per resource pool and
list Host, Cluster, Number of VMs and number of templates
Click Here
Folder Name Mismatch Lists all VM’s which are stored in a folder not the same as their name Click Here
How many VMs ? Lists how many VM’s were on each host Click Here
Storage VMotion – The PowerCLI way Shows how to VMotion and SVMotion VMs using PowerCLI Click Here
PowerCLI on steroids – Custom attributes Exporting and importing Custom attributes Click Here
One-Liner: VM Guest Disk Sizes List all VM’s and their disk sizes Click Here
One-Liner: Correct HAL ? List the number of vCPU’s assigned to a VM and the type of HAL installed in the O/S Click Here
Setting MMU for your VMs Set MMU for multiple VMs Click Here
Reservations / Limits and Shares Export your Reservations limits and Shares Click Here
List VM’s with RDM List all VMs which have an RDM Click Here
Who deleted my VM ? A script to find the culprit ! Reading the VC database Click Here
Checking CPU Affinity A Script that lists each VM and the CPU they are tied to. Click Here


ESX Hosts

 

Name

Brief Description

Link

Checking Host Network Information List all ESX Host Service console and VMotion network information Click Here

Number of vCPUs in a cluster

detail the number of vCPU’s on a host and in a cluster Click Here
Reading host log files How to read a hosts log files and use these in your scripts Click Here
Processor Types List each of your hosts and a detailed CPU type Click Here
Do you have the time ? List each hosts NTP settings and if the service is running Click Here
Host Hardware one-liner Details the hosts hardware details Click Here
vProfiles A Script to automatically configure your hosts from an existing host Click Here
More One Liners List number of VM’s per resource pool and
list Host, Cluster, Number of VMs and number of templates
Click Here
Provision ESX Hosts through PowerShell A Link to a script by SCampbell Click Here
Getting VMware Host Physical Nic Speeds A script to list all Nics and their speeds Click Here
Rescan all hosts for new storage Rescan all hosts for new Storage Click Here


Licensing

 

Name

Brief Description

Link

License Server Scripts How to list the licensed features on each host and also monitor the license service Click Here


Datastores

 

Name

Brief Description

Link

How Many VMs on your Datastores ? Lists the number of VMs on each Datastore Click Here

Mass provision datastore’s

add multiple datastore’s from a csv file Click Here
Local stored VMs List all VM’s located on local storage Click Here


Networking

 

Name

Brief Description

Link

One-Liners Checking Host Network Information List Host PG/IP/Subnet/Console/DNS/Device information Click Here
More one-Liner power Find a VM with a specific Mac Address Click Here
vProfiles A GUI Script to automatically configure your hosts vSwitches and Port Groups from an existing host Click Here
Easy vSwitch & PortGroup Setup Copy existing vSwitches and PortGroups from an existing Host Click Here
Lesson 3 – Networking Creation of vSwitches Click Here
Lesson 4 – PortGroups Creation of PortGroups Click Here
More Network Info Various network information Click Here
Detailed VMware Host Network Information Network information including CDP info Click Here
Getting VMware Host Physical Nic Speeds A script to list all Nics and their speeds Click Here
Mass VM PortGroup Change Change the portgroup for multiple VMs Click Here
Host Network Config Lists all the needed information to perform this best practice analysis Click Here


Reporting

 

Name

Brief Description

Link

vCheck 3.1 Fixes for vCheck 3 to fix slight issues Click Here
vCheck (Daily Report V3) Version 3 of the Daily Report, or now known as vCheck Click Here
Daily Report V2 Enhanced Error and issues report, listing vital information for a daily check of your entire VI Click Here
Daily Report V1 Error and issues report, listing vital information for a daily check of your entire VI Click Here
vDiagram – Draw your VI with one script Draw your Virtual Infrastructure in Visio Click Here
Mapping your VI using Netmap Draw your Infrastructure in a netmap style Click Here
Checking Logs Checking the vmkernel log for issues Click Here
Quick Stats from VMware for reports Shows how to create quick charts on your VI Click Here
Exporting VI Info into MS Word A script which creates a word document with various VMware information Click Here


Lessons

 

Name

Brief Description

Link

Lesson 1 – Time Source

Setting up a host, adding a time source Click Here
Lesson 2 – Service and Firewall Configuration Service and firewall configuration Click Here
Lesson 3 – Networking Creation of vSwitches Click Here
Lesson 4 – PortGroups Creation of PortGroups Click Here
Using the VI APIs from Powershell Excellent guide by Luc on how to get started with the VI API’s Click Here
My First Powershell Export information into Excel Click Here


Cluster

 

Name

Brief Description

Link

HA Slot Size Information Detail the slot information for each Cluster Click Here

Number of vCPUs in a cluster

detail the number of vCPU’s on a host and in a cluster Click Here
More One Liners List number of VM’s per resource pool and
list Host, Cluster, Number of VMs and number of templates
Click Here
Check Cluster Configurations A great script by Hugo which compares the cluster configuration Click Here


Snapshots

 

Name

Brief Description

Link

SnapReminder Automatically emails the creator of a snapshot after x amount of days Click Here


Security

 

Name

Brief Description

Link

vSphere Permissions export and import – Part 1 Walkthrough of how to export and import permissions Click Here
vSphere Permissions export and import – Part 2 Walkthrough of how to export and import permissions Click Here
Lesson 2 – Service and Firewall Configuration Service and firewall configuration Click Here
Primal Forms Example (Virtual Center Log) A great script by FatBeard showulng how to use a GUI to read the VCenter Logs Click Here
Checking Logs Checking the vmkernel log for issues Click Here


Others

 

Name

Brief Description

Link

vTip – A VMware Expert updating your VI Message of the day updated by Jason Boche Click Here

Running a PowerCLI Scheduled Task

Details how to run a PowerCLI script as a scheduled task Click Here
vProfiles A Script to automatically configure your hosts from an existing host Click Here
Extra fields in the VI Client Excellent script by Hugo which adds information back into the Virtual Infrastructure Click Here
Check Active Directory Latency Script Check Active Directory Latency Click Here
Change DNS and WINS on multiple servers Change DNS and WINS on multiple servers Click Here
Powershell Citrix License Alerts Reading the Citrix licenses from the Web interface and reporting Click Here
Server/Workstation Audit script Audit multiple servers or workstations and produce a nice html output using this script. Click Here


VESI

 

Name

Brief Description

Link

The VESI 1.2 – Get it Now List of the 2.1 Features Click Here
HA Slot Size Information Detail the slot information for each Cluster Click Here

82 Responses to “SCRIPT LIST”

  • Michael says:

    Do you know of an equivalent in powercli to the esxcfg-firewall -o command? I am new to powercli and have not found a way to open a port. Thanks for your time.

  • Virtu-Al says:

    Did you see this post I did earlier ? http://www.virtu-al.net/2009/04/14/customisation-lesson-2-–-service-and-firewall-configuration/ Hopefully it will cover what you want

  • Michael says:

    Thanks for the fast response and helpful link. But, I am still looking to replace esxcfg-firewall -o 1311,tcp,in,OpenManageRequest command with a powercli cmdlet.

  • Virtu-Al says:

    @Michael
    Sorry looks like I was wrong, check this link, there is a way to mass do this but not using the PowerCLI cmdlets independantly….
    http://communities.vmware.com/message/1085547#1085547

  • bjorn bats says:

    where is the list then ?

  • Virtu-Al says:

    @bjorn bats
    Ummmm, its coming, other stuff keeps getting in the way !

  • gareth says:

    Hi there,

    I wonder if you could help. I am really new to powershell on VMware so feel free to be gentle. I am trying to work out the powershell command to show the last power on event for a host and also the memory size for the host as well.

    I have about 200 hosts I need to check this on so if I could use PS I would laughing!

    Thanks in advance

    Gareth

  • Virtu-Al says:

    @gareth
    Added to the blog for reference:

    To csv file use this:

    get-cluster “My Cluster” | Get-VM | Get-View | Select Name, @{N=”BootTime”;E={$_.Summary.runtime.boottime}} | Export-Csv c:\temp\boot.csv

    To a text file use this:

    get-cluster “Production Cluster 3″ | Get-VM | Get-View | Select Name, @{N=”BootTime”;E={$_.Summary.runtime.boottime}} | out-file c:\temp\boot.txt

  • Awesome collection! Thanks for sharing your knowledge Alan.

    Regards,

    Mike

  • q says:

    This is a great repository! Is there a script to get a list of which roles are applied to which groups on which folders? Thanks!

  • Virtu-Al says:

    @q
    Have you tried this… http://communities.vmware.com/message/1105904#1105904 you can always use this function to do….

    Get-folder | Get-Permissions

  • George says:

    Great Stuff!! I’ve used the report.ps1 script for a while now. Are there any plans to remove dependencies on the Office Web Components? MS has stated those are depricated.

  • Virtu-Al says:

    @George
    I would love to but cant find a nice ‘non dependant on 3rd party tool’ way of doing it.

  • Jason Boche says:

    Script Request: Need a script to change the portgroup connection in each VM from X to Y. ie. I have 100 VMs that need to move to a new VLAN (portgroup). Editing the settings of each VM and updating the portgroup connection would be tedious.

  • tony says:

    I am new to this powercli can you give me more info how to use it thanks

  • Virtu-Al says:

    @tony
    Sure, have you checked out the getting started links on this site and also a great book is “Managing vmware virtual infrastructure with Powershell” by Hal Rottenburg, there is also the PowerCLI forum and FAQ here: http://communities.vmware.com/community/vmtn/vsphere/automationtools/windows_toolkit;jsessionid=3F9B08F3F055E22FE877ED351B04CD7A?view=overview&numResults=15

  • [...] обнаружился обалденный список скриптов под VMware vSphere PowerCLI, ссылки на который с удовольствием [...]

  • Jason Boche says:

    Script Request: Search a datastore for all templates and register them in vCenter. Since Templates ownership cannot be transferred to another host, rebuilding a host which owns templates requires us to manually re-register the templates. This is a pain. I have been harping on VMware to fix this and make Templates portable like VMs. Check your email – Happy Holidays.

  • Ken says:

    Hey Alan,
    Do you have a script stashed anywhere that will sync ESX advanced settings across all hosts in a cluster? I’m looking around for one before I write it myself so I don’t have to reinvent the wheel.

  • Virtu-Al says:

    @Jason Boche
    Im sure you have already seen it but for the purposes of others looking, Luc has a great script which does that.. http://lucd.info/?p=1103

  • Peter says:

    Hi…
    This is a great repository!

    I’m looking for script to show the build version of VMware tools into vm machine….

  • Suresh Kumar says:

    Hi Alan,

    Thanks for this awesome repository of scripts.

    REQUEST: Please give us one script to collect patch information from the esx hosts in the VC and export it to csv or HTML.

  • [...] Script List « Virtu-Al – Sweet powershell scripts for ESX [...]

  • Brian says:

    Alan, do you know of a script that would show me a list of VMs on a datastore but specifically relating to thin provisioned VMs? I am trying to find a way that I can tell the amount of space used and over provisioned…. Does that make sense.

  • Virtu-Al says:

    Brian,

    Have you seen Luc’s great post on this ?

    http://lucd.info/?p=1935

  • [...] Aufgaben lösen. Ein Blick ins PowerCLI cmdlets Poster verdeutlicht den Funktionsumfang und Al Renoufs PowerCLI Scripts oder einige der Gewinner-Beiträge des Script-o-Mania Contests 2010 sind Beispiele, wie sich [...]

  • Gus Chavira says:

    Looking for a script similar to others I have seen but that captures all VMs but what resource pool they are registered under. Creating a new vCenter install. Have powershell script to recreate my resource pool organization under clusters but want to place the VMS by name reference back under those cluster’s resource pool structures.

  • Grog says:

    Alan,

    First let me say wonderful job on the vCheck 5 script. It is awesome!!!

    I wanted to see if you had worked on anything related to creating patch compliance reports for ESX hosts? It would be great to either create a standalone script or add it to vCheck as an option.

    Thanks,
    Marc

  • cemal says:

    Hi Alan
    I need a script to change of solaris guest ‘s ip adrress . Can you help me ?

    Thanks in advance

  • Srini says:

    Hi

    Iam look for a script which can pull cpu & memory stats for VM including max, min & AVG.

    Thanks
    Srini

  • Srini says:

    Sorry in my previous message missed couple of things.

    Iam looking for script which can pull stats as mentioned earlier for every 30mins intervals.

  • Bond West says:

    Script Request: Search a datastore for all templates and register them in vCenter. Since Templates ownership cannot be transferred to another host, rebuilding a host which owns templates requires us to manually re-register the templates. This is a pain. I have been harping on VMware to fix this and make Templates portable like VMs. Check your email – Happy Holidays.
    +1

  • Andrew Richardson says:

    Hi Alan,

    Is it possible to script the iSCSI initiator nic binding? Usually you’d use the “esxcli swiscsi” command but I can’t find any version of this for PowerCLI.

    Thanks!

  • Bit of an idea, trying to put together a script that will show VM’s by the folder structure in vCenter and let you choose what info to show, power state, memory, cpu etc..

    Any thoughts?

  • [...] And another must visit place is at virtu-al.net [...]

  • sanjai says:

    Alan,

    Need an one-liner to find out the Path Selection policy (MRU / Fixed) for esx 3.5 (cluster level / datacenter level)

    Any suggestions?

  • Chris says:

    Hi,

    Does anyone have a ecoshell script to remove hidden network adapters from a VM?

    Thanks,

    C

  • Guido says:

    Hi, Does anyone have a script to list all VM’s within a
    folder. Thanks Guido

  • John R says:

    Hello Alan Do you know if there is a script which will
    create a new virtual NIC with the same MAC as the existing NIC. We
    have an issue where we have hundreds of VMs with v4 hardware and we
    will be upgrading to v7 but want to create new VMXNet3 NICs on each
    VM. The MAC address needs to be the same as we reserve IP addresses
    in DHCP based on MAC address. Thanks John

  • Virtu-Al says:

    You can set a manual mac address on the vm but I don’t think you can use the same pool as what is used as the current mac, maybe an adjustment to the vmx file and a re-register would do it but I would need to check. Then you could automate that.

  • Dale S says:

    I need to export the I/O and MB/s for each connected SAN LUN in XML or CSV. Is there a way to do this?

  • Virtu-Al says:

    When you say SAN LUN do you mean datastore and RDM or just datastores?

  • Dale S says:

    I would like to see both, but would take just the datastores if I had to. Either way I am going to need to correlate what VMs are mapped to what RDM devices.

  • keshava says:

    Hi Virtu-al i happy that you are feeding knowledge to geeks on scripts and congrats for your work,
    please tell me how to remove old snapshots from the vm’s through the scripts

  • Virtu-Al says:

    Thanks, you need to look at the remove-snapshot cmdlet, there are some good examples in the help.

  • keshava says:

    Thanks,
    for the farst replay,
    and i am waiting for ur book,, when can hold it on my hand?

  • Virtu-Al says:

    Hopefully the end of April – Don’t hold me to that though !

  • ranjit says:

    Hello Alan, thanks for your scripts ..

    we have thin provisioned all the VMs and now we have set alarms on datastores..which shows us alert if datastore is used beyond 75%.

    could you provide us acript whcih can look for datastores used more than 75% and identify the datastores which has free space and move the VM to that datastore

    thanks ,
    Ranjit

  • ranjit says:

    Hi Alan,

    I have manage to write the script for manage thin provisioned datastores.
    script will migrate vms from datastore which doesn’t have free space to free datastore.
    it will take care that destination datastore will have enough free space.

    Your site help a lot for this… thanks

  • Sean says:

    I have two main VMware environments, back-end and customer facing and I have vKernel monitoring on the customer facing environment. Each day I get a cool report, Capacity Monitor Datastore Statistics Report, which gives me some useful information (total space, allocated space, free space, commited %, utilized %). My experience with powershell is related to Exchange and not VMware so all the commands available are new and I am just learning them. So far I have not found a way to get this same type of information (very useful with thin provisioned disks) using powershell.

    I see that get-datastore will give me some of the information but nothing related to the ‘over’ allocated space of each datastore (i.e. 2 TB lun with 2.7 TB allocated and 750 GB free). Could you point in the direction to where I can find this information/command(s) in powershell? Thank you for your time.

  • Pete L says:

    Suggestion:
    Is it possible to list all of the os types and platform? Example

    Datastore ABC Has 10 Win2k8R2 and 5 Windows2k3
    Datastore XYZ Has 2 Windows2008Std, 4 Windows 2008Enterprise.

    Again just an example.

  • Kris says:

    I i wonder if you could help me, I have VI with 10 ESX 4.1 U1 hosting around 100 VMs. I’
    m looking for a script that can pull perfrmance report/charts (graphical) on all VMs for last 30 days.

    Thanks,

  • Raul says:

    I am using vcheck5. I want to combind two scripts 1. Vm’s & Templates with inconsistant folder names and 2. vm guest disk sizes. Or to put it more directly. i want the second script to tell me which lun the VM resides with all the other information it already gives me. Thanks

  • Hitesh says:

    Hi All,
    First of all I would like to thank for this grt repository of scripts..
    I am really new to powershell and VM administration and really want to learn a lot and hope to get great help from you guys and thanks to you all in advance.
    I m trying to generate a report for last logons on virtual machines,script in which i can specify the login dates, i need this script to get VMs which has not been used for a month..
    Please let me know if there are other options to get these details.
    Thanks alot in advance..:)

  • Alan says:

    You will need to use the Invoke-VMScript or use Get-WMIObject to call the machines and check for this data,

  • a raza says:

    Great Site!!!

  • a raza says:

    Can you please tell me how to get a report contaning all VMs configuration information (e.g. # of CPU, Memory, host name, os info, sevice park)..any script which goes to word/excel

  • mmason says:

    Alan gotta say this is going to be an awesome addition to our vCenter monitoring. Thank you!

    I do have a quick question. I would LOVE to get the web page output of vCheck as an addon to vCenter so when our service desk is in the VIC they could add this page as an addon and pull it up without leaving the VIC. Any ideas on how to accomplish this?

  • Sean says:

    I am looking for a way to list each esx host and all the guest located on the host. I think i have seen it before but not sure. Is there a script out there for that?
    Thanks

    Sean

  • Alan says:

    Get-VM | Select VMHost, Name | Sort VMHost, Name

  • Mithilesh says:

    Hi Alan,

    I am looking for Powershell script to check VM first boot device is Network or local storage.

    any help will be greatly appriciated.

    -Mithilesh

  • CyberIDentity says:

    Is it possible to produce a one liner that shows multiple vmnic MAC addresses for guests and hosts? I have this so far, but I am still learning.

    Get-VM | Get-NetworkAdapter | Select Parent, MacAddress | Export-Csv D:\CLI\File.csv

    Thanks in advance.

    CB

  • pookatini says:

    Script request: Is there an existing script that will pull all necessary ESX host config info in case of a failure? (ie, network info, vswitches, NAS mounts, etc…)

  • kcmjr says:

    What version of ESX and do you want PowerShell or a Linux shell script?

  • pookatini says:

    ESX 4.1, and actually either is fine, which ever works best for you. Also, I do have some specifics as I trying to get the following info for the hosts in case of a need to rebuild from kickstart:

    switch configurations – uplinks, settings, speeds, switch names, vlan tags, port groups and port connections (Virtual Machine, vs Service Console vs VMKernel)

    NAS and SAN mounts and names
    Service Console IP addresses
    ESX version, build #

    Thank in advance for your assistance

  • kcmjr says:

    For any non “i” version of ESX I recommend the ESX Healthcheck shell script (https://sourceforge.net/projects/esxhealthscript/). This wont work on ESXi due to the lack of a service console. In this case I would recommend the PowerShell based health script from Al (http://www.virtu-al.net/featured-scripts/vcheck/) or the health check script from Ivo Beerens (http://www.ivobeerens.nl/2009/01/06/new-version-of-the-powershell-healthcheck-script-released/).

  • Leon says:

    Would it be possible from VM(guest Machine) that on which ESX server it is resides on?

  • kcmjr says:

    Absolutely, as long as they are accessible to each other over the network.

  • Wallander says:

    Hi,

    IS there anyway by which I can find out the Disk Read and Write Latency on the VM disks?

    No the disks on the ESX, but Disks on the VM.

    Get-Stat -Entity USB-SSWEB -stat virtualDisk.totalWriteLatency.average

    tried this nothing came

    Regards,

  • fragar says:

    alan, great site!

    installed the virtu-al.net powerpack. right-clicking on the node does not give us the ability to import the pack. at this time i cannot collapse the built-in queries.

  • Chris Turner says:

    I have over 500 esx servers and need to find out how many of them are configured to automatically startup its Vms when the hosts boots up. Does anyone have a script that will pull this information down quickly rather than me checking every host individually?

  • blackhorse says:

    I need to change IP address, Hostname and gateway of single or 10 number of Linux VMs.
    Does anyone have a script to get this done?

  • Nick Colyer says:

    Does anyone have the updated version of this with all of the corrections already in it for vsphere 5/Powercli 5.

    If so please can you e-mail it to me.

    Thanks,

    Nick

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>