heze54
asked on
Vmware script
HI,
I´m building a vmware script to shutdown / power on virtual machines listed in a csv file.
After exported them into that csv file, I´ve a code like this:
Then, how can I build a file and run it with a double click?
regards
I´m building a vmware script to shutdown / power on virtual machines listed in a csv file.
After exported them into that csv file, I´ve a code like this:
$vmservers=Get-VM | Where-Object {$_.powerstate -eq ‘PoweredOn’}
$vmservers | select Name | export-csv c:\MyScripts\servers.csv -NoTypeInformation
$vmservers| Shutdown-VMGuest
Then, how can I build a file and run it with a double click?
regards
ASKER
Hi Subsun,
Great post!!!
Rigth now I´ve the csv file and want to power off virtual machines listed by csv file.. For example:
file1.csv vm1 and file2.csv vm2
I´d like to power off file1 csv machines and, after x minutes, power off file2.csv.
And last question... could I power off and esxi server runing this same script.?
Regards
Great post!!!
Rigth now I´ve the csv file and want to power off virtual machines listed by csv file.. For example:
file1.csv vm1 and file2.csv vm2
I´d like to power off file1 csv machines and, after x minutes, power off file2.csv.
And last question... could I power off and esxi server runing this same script.?
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
A++
Open in new window
You can save the code in to a TestScript.ps1 (any name of your choice).Then create a bat file with following command in it.. you need to replace the D:\script\TestScript.ps1 with your script path..
Open in new window
You can also Compile a script and make .exe file.. Following article have an example..
https://dmitrysotnikov.wordpress.com/2011/08/22/compile-powershell-scripts-to-exe/