Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168400

Re: Change network setting on VM

$
0
0

Hi Jeremie,

 

I would'nt use a ps script, running on the vCenter server to configure the network adapter of a VM. Instead you can do this direct within orchestrator which prevents you from additional error which can occur with powershell invoking.

 

To your problem to change the in guest network settings you could try the following:

 

1. pipe the following vbs script local to your vCO server and replace the IP, subnetask and gateway:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters    errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)    errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)    If errEnable = 0 Then        WScript.Echo "The IP address has been changed."    Else        WScript.Echo "The IP address could not be changed."    End If
Next

 

2. copy the lokal file to the target server using "Copy file from vCO to guest" workflow

 

3. run the script on target server using "Run program in guest" workflow

 

Example: pass parameters to run in guest workflow

 

Hope this helps and regards,

Chris


Viewing all articles
Browse latest Browse all 168400

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>