Created
August 11, 2015 15:47
-
-
Save lamw/e16f6b499c7a0de22ee9 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
####### 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