Wednesday, June 3, 2020

Automate Power on Operations using PS

Hi Guys,

In my previous post, I explained that how can you automate power on operation using vrops but what about those guys who don't have vROPS and having need to automate such operations. For those guys, I have created a simple but logical powershell function which you can use and it works just fine.

You need to run this script from the jump server where your vcenter is accessible. On that machine, you can also create task scheduler to run this script on every startup of the machine (Because restarting the machine will stop the running script).

This is Power-On example but you can do n number of automation using this logic. Here is the script-

Tell me in my comments that what else you can think to automate in this way.
-----------------------------------------------------------------------------------------------------------------------------
Connect-VIServer vcenter_IP_or_FQDN
Function AutoPower
{
foreach($vmlist in (Get-Content -Path C:\TEMP\vms.txt)){
$vm = Get-VM -Name $vmlist
If ($vm.powerstate -eq "PoweredOff"){ 
Start-VM -VM $vm -Confirm:$false -ErrorAction SilentlyContinue
}
}
AutoPower
}
AutoPower
-----------------------------------------------------------------------------------------------------------------------------

You need to save VM's name in a txt or csv file and then give that location in above script.

Below is the video demonstrating the function of the same. This will open up you mind to do many such actions on vCenter server. Feel free to comment if any doubt.




Thank you,
vCloudNotes

0 comments:

Post a Comment

Sponsor

AD BANNER
Powered by Blogger.
The Magazine

Text Widget

Facebook

Extra Ads

AD BANNER

Welcome to my Notes!

Hello Folks, My name is Gautam Johar. Actively working on VMware Cloud and keen to learn new and latest cloud technologies in market. Love ...

Contact Form

Name

Email *

Message *

Followers



Labels

Translate

Breaking

Random Posts

Follow Us

On Linkedin

Recent Posts

Recent Comments

Header Ads

Popular Posts

Popular Posts

Recent Posts

Text Widget

Search This Blog

Copyright © test blog | Powered by Blogger
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com