Difference between revisions of "Virtual Machine Script Extracts and Examples"

Jump to navigation Jump to search
m
Added category
m (Added category)
m (Added category)
Line 1: Line 1:
= VM's with Host and Cluster List =
== VM's with Host and Cluster List ==
<source lang="powershell">
<source lang="powershell">
$vms = Get-VM | sort -property Name
$vms = Get-VM | sort -property Name
Line 8: Line 8:
</source>
</source>


= VM's Inventory CSV =
== VM's Inventory CSV ==
Creates a CSV export list of virtual machines.
Creates a CSV export list of virtual machines.


Line 66: Line 66:
</source>
</source>


= VM's with Snapshots Running =
== VM's with Snapshots Running ==
This script generates an email report of virtual machines that have snapshots running.
This script generates an email report of virtual machines that have snapshots running.


Line 151: Line 151:
...then I've just replaced <code>Get-Snapshot</code> with <code>CalculateVMSnapshotsSizeMB</code>
...then I've just replaced <code>Get-Snapshot</code> with <code>CalculateVMSnapshotsSizeMB</code>


= VM's Effective CPU Shares =
== VM's Effective CPU Shares ==
Calculates the effective relative CPU shares of VM's contained within resource pools.  Can only handle resource pool depth of 1.   
Calculates the effective relative CPU shares of VM's contained within resource pools.  Can only handle resource pool depth of 1.   


Line 230: Line 230:
</source>
</source>


= Ping All VM's On ESX =
== Ping All VM's On ESX ==
Useful sanity check prior to and after network level changes
Useful sanity check prior to and after network level changes


Line 270: Line 270:
</source>
</source>


= Enable Change Block Tracking =
== Enable Change Block Tracking ==
This script enables CBT for all VM's managed by the vCentre its run on.  It runs through all VM’s managed by the VC and determines which can be changed, then run through and changes them.
This script enables CBT for all VM's managed by the vCentre its run on.  It runs through all VM’s managed by the VC and determines which can be changed, then run through and changes them.


Line 341: Line 341:
</source>
</source>


= VM's Recently Created =
== VM's Recently Created ==
I run the following script twice a week (via a scheduled task), to generate a report of VM's recently created, as a catch-all reminder to check VM backup's, monitoring, etc etc have been set-up as required.  The number of days history it searches through can either be altered in the script (the <code>$days</code> parameter), or passed as a command line parameter when run as a scheduled task.
I run the following script twice a week (via a scheduled task), to generate a report of VM's recently created, as a catch-all reminder to check VM backup's, monitoring, etc etc have been set-up as required.  The number of days history it searches through can either be altered in the script (the <code>$days</code> parameter), or passed as a command line parameter when run as a scheduled task.


Line 538: Line 538:
</source>
</source>


= Add Attributes to VMs from CSV =
== Add Attributes to VMs from CSV ==
You have the option in vCentre to create your own custom attributes to any of the standard objects.  This can be incredibly useful if you have a sprawling estate of VM's to manage for various different parts of your company, as you can record information like Owning Dept., Product Family etc against your VM's.   
You have the option in vCentre to create your own custom attributes to any of the standard objects.  This can be incredibly useful if you have a sprawling estate of VM's to manage for various different parts of your company, as you can record information like Owning Dept., Product Family etc against your VM's.   


Line 679: Line 679:
</source>
</source>


= Migrate VMs Between vCentres =
== Migrate VMs Between vCentres ==
The following script will migrate virtual machines from one vCentre to another, so long as both have a shared datastore.
The following script will migrate virtual machines from one vCentre to another, so long as both have a shared datastore.


Line 785: Line 785:


[[Category:PowerCLI]]
[[Category:PowerCLI]]
[[Category:Virtual Machine]]

Navigation menu