VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

script_structure_powercli

Hi Luc,

can you please suggest on the orange part of the following code.  This is to add static routes on each esxi host and do some operations on replication appliances .

since there are no commands for replication nor any api so iam trying to automate whaterver possible with existing commnds.

i have two questions related to orange lines.

1 .stop-vm -vm $replication_appliance -whatif

will stop-vm is a kind of graceful shutdown for vm.

2:Start-Process https://172.16.7.20:5480 -Credential $cred_vami

can we ensure if start-proces to access vami opens in mozila and assign credential as mentioned above.

code is below:

$vcenter=read-host "provide vcenter name"

$cred=get-credential

$cred_vami=Get-Credential

connect-viserver $vcenter -credential $cred|out-null

$con=$global:defaultviserver

if($con.name -eq '172.1.1.1')

{

write-host "we are working in prod vcentercer remeber to enable vspherereplication traffic on vmk2 on esach esxi" -ForegroundColor DarkMagenta

$vmhosts=get-vmhost

foreach($vmhost in $vmhosts)

{

new-vmhostroute -vmhost $vmhost -destination 172.16.9.0 -prefixlength 25 -gateway 172.16.9.1 -whatif

}

$replication_appliance = get-vm vra_pro

stop-vm -vm $replication_appliance -whatif

$portgroup_replication=get-vdportgroup -name replication_113

new-networkadapter -vm $replication_appliance -portgroup $portgroup_replication -whatif

start-vm -vm $replication_appliance -whatif

write-host "now we are going to configure vra prod appilance" -ForegroundColor Blue

Start-Process https://172.16.7.20:5480 -Credential $cred_vami

}

else

{

write-host "we are working in dr vcenter rember to configure replication nfc traffic on each esxi on vmk2" -ForegroundColor Green

$vmhosts=get-vmhost

foreach($vmhost in $vmhosts)

{

new-vmhostroute -vmhost $vmhost -destination 172.16.9.128-prefixlength 25 -gateway 172.16.9.129 -whatif

}

$replication_appliance = get-vm vra_dr

stop-vm -vm $replication_appliance -whatif

$portgroup_replication=get-vdportgroup -name replication_113

new-networkadapter -vm $replication_appliance -portgroup $portgroup_replication -whatif

start-vm -vm $replication_appliance -whatif

  write-host "now we are going to configure vra_dr appilance" -ForegroundColor Blue

Start-Process https://172.16.7.150:5480 -Credential $cred_vami

}

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

1. No Stop-VM is a hard power off.
For a graceful shutdown of the guest OS, you use Stop-VMGuest

2. It depends what application you have defined as the default for webpages.
The Credential parameter on Start-Process is intended for use with -Verb runas, not to logon to a webpage.

I'm not sure why you are trying to go this way, with esxcli you can add static routes ($esxcli.network.ip.route.ipv4.add)

See also KB2001426


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
13 Replies
LucD
Leadership
Leadership
Jump to solution

1. No Stop-VM is a hard power off.
For a graceful shutdown of the guest OS, you use Stop-VMGuest

2. It depends what application you have defined as the default for webpages.
The Credential parameter on Start-Process is intended for use with -Verb runas, not to logon to a webpage.

I'm not sure why you are trying to go this way, with esxcli you can add static routes ($esxcli.network.ip.route.ipv4.add)

See also KB2001426


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

1:thnaks iam going to use stop-vmguest.

2:well i am trying to open vamiof appliance is there any powershell /powercli way to start page and login .

i think using essxcli or add-vmhost both are going to acheive the same result .or is there any diference.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not sure what you are doing with Add-VMHost here?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

sorry  i meant new-vmhostroute

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, got it.

Now why do you want to logon to the Appliance in this way?
There is an API to interact with the vRA appliance.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

thnaks.well my intension to put most of the things possible in script.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Which is exactly the purpose of an API.
What do you want to do in the appliance?
Did you check if it possible through the vRA API?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

by vRA i mean replication apliance.and i wanted to do some configurtion change inside vami .

adding ip address for incoming storage traffic.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You lost me there.
You are talking about vRealize Automation then?

Perhaps a screenshot would clarify what you are trying to do? Which setting?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

well i am talking about vsphere replication apliance .i know there are no powercli commands to do anything related for vsphere replication .

not sure why it has been left alone .Smiley Happy

however i though of adding extra ipbelow  .is there any api way??

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Got it, but I'm afraid there is no public API that appliance.

Not too sure how you would interact with that form over a remote connection.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

thnaks i will do that task manualy however i found something replication plugin for vro .if there is no api how can we have plugin or default workflows for replication.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sorry, don't know vRO that well.
Try asking in that community.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos