A script with useful functions to manage VMs in VMWare vCenter
To install the module, run the following command in PowerShell:
Install-Module -Name VMware.PowerCLI -AllowClobber -Force
You may need to change the execution policy to run the script. To do this you have a few options:
You can change the execution policy for the current PowerShell session only, without affecting the system-wide execution policy:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
You can change the execution policy permanently for all PowerShell sessions. Open a PowerShell window with “Run as Administrator” option and run:
Set-ExecutionPolicy RemoteSigned
This will allow running unsigned scripts that you write on your local computer and signed scripts from the Internet. Please note that this changes the policy permanently. If you want to change it back to the default, run:
Set-ExecutionPolicy Restricted
You can also bypass the execution policy at run-time with this command:
powershell.exe -ExecutionPolicy Bypass -File "C:\FILE\LOCATION\vm-ssrc.ps1"
C:\FILE\LOCATION\vm-ssrc.ps1
Function | Description |
---|---|
Create VM | Creates a VM by entering the name, selecting the host, datastore, network, OS, RAM, CPU, and disk size. |
Start VM | Starts a VM selected from a list of VMs by number. |
Stop VM | Stops a VM selected from a list of VMs by number. |
Restart VM | Restarts a VM selected from a list of VMs by number. |
Open VM Console | Opens the console of a VM selected from a list of VMs by number. |
Get IP Address of VM | Gets the IP address of a VM selected from a list of VMs by number. |
Get VM Info | Gets the raw VM info of a VM selected from a list of VMs by number. |
VMware Tools | Submenu to install, update, or dismount VMware Tools on a VM selected from a list of VMs by number. |
Get VM List | Outputs a list of VMs in the vCenter and their power state color coded. Green = Powered On, Red = Powered Off, Yellow = Suspended. |
Delete VM | Deletes a VM selected from a list of VMs by number. |
See latest changes here.
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.