Skip to content

Instantly share code, notes, and snippets.

@lamw
Created August 11, 2015 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamw/e16f6b499c7a0de22ee9 to your computer and use it in GitHub Desktop.
Save lamw/e16f6b499c7a0de22ee9 to your computer and use it in GitHub Desktop.
####### PS Script (test2.ps1)
if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {
. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
}
$vcserver = "172.30.0.112"
$vcusername = "administrator@vghetto.local"
$vcpassword = "VMware1!"
Connect-VIServer -Server $vcserver -User $vcusername -Password $vcpassword -WarningAction SilentlyContinue
Get-VM
Disconnect-VIServer -Server $vcserver -Confirm:$false
######## Wrapper Script (wrapper.bat)
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -c C:\Users\primp\Desktop\test2.ps1 > C:\Users\primp\Desktop\log.txt
####### Output (log.txt)
Welcome to VMware vSphere PowerCLI!
Log in to a vCenter Server or ESX host: Connect-VIServer
To find out what commands are available, type: Get-VICommand
To show searchable help for all PowerCLI commands: Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity
Copyright (C) VMware, Inc. All rights reserved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment