-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGettingStartedWithPowerCLI.ps1
63 lines (63 loc) · 1.96 KB
/
GettingStartedWithPowerCLI.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#######################################################
# Getting Started with PowerCLI
#######################################################
# Author(s): Mike Ross
# Github: https://github.com/mikewireTX
# Web: https://mikewire.com/
#######################################################
# Below is a small collection of cmdlets to get started
# using PowerCLI - use at your own risk!
#
# Check if PowerCLi is already installed (this is the depricated version)
Get-PowerCLIVersion
#
# This is a better cmdlet to run and is not deprecated
Get-Module -Name VMware.* | Select-Object -Property Name,Version
#
# Use this cmdlet to install PowerCLI:
Install-Module VMware.PowerCLI -Scope CurrentUser
#
# Check the PowerShell module path:
$env:PSModulePath
#
# Set the execution policy to bypass and limit scope to CurrentUser (you):
Set-ExecutionPolicy Bypass -Scope CurrentUser
#
# Or set CEIP (Customer Experience Improvement Program) to true:
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true
#
# Set the CEIP to false:
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
#
# Update PowerCLI:
Update-Module -Name VMware.PowerCLI
#
# Uninstall PowerCLI Main module
Get-Module VMware.PowerCLI -ListAvailable | Uninstall-Module -Force
#
# Uninstall PowerCLI VMware modules except for the main PowerCLI module
(Get-Module VMware.PowerCLI -ListAvailable).RequiredModules | Uninstall-Module -Force
#
# Connect to vCenter - sub in your hostname below:
Connect-VIServer -Server <yourserver>
#
# Get a list VMs
Get-VM
#
# Get a list of VM Hosts
Get-VMHost
#
# Check what VIServer you are connected to:
$global:defaultviserver
#
# Update PowerCLI:
Update-Module -Name VMware.PowerCLI
#
# Disconnect from the single server- sub in your hostname below
Disconnect-VIServer -Server <yourserver>
#
# Disconnect from ALL vCenter server(s) - force all active connections to disconnect
Disconnect-VIServer -Force
#
# End
#######################################################