-
-
Save sky-joker/077a46badcb48fd050b405d05dd2dadc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vCenter or ESXi Connection Variable. | |
$server = "" | |
$user = "" | |
$password = "" | |
# Output File. | |
$output_file = "C:\Users\Administrator\Desktop\vmlist.txt" | |
# VMware Spnapin List. | |
$vm_snaplist = @('VMware.VimAutomation.Core','VMware.DeployAutomation','VMware.ImageBuilder') | |
# Add VMware PSSnapin. | |
foreach($i in $vm_snaplist) { | |
if(-not(Get-PSSnapin -Name $i > $null 2>&1)) { Add-PSSnapin $i } | |
} | |
# Connect | |
Connect-VIServer -Server $server -User $user -Password $password | |
# Get VMs. | |
Get-VM > $output_file | |
# Disconnect | |
Disconnect-VIServer -Confirm:$false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment