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

Re: How to invoke/execute the existing script/function to esxi 5.0 host in a CSV file by PowerCLI ?

$
0
0

If you create a file called vmhosts.csv that has the following structure:

 

Name

ESX1.yourdomain.com

ESX2.yourdomain.com

 

then you can use the following PowerCLI code as a wrapper around your code:

 

Import-Csv-Pathvmhosts.csv |ForEach-Object$VMHost=Get-VMHost$_  $VMHostView=$VMHost.ExtensionData  $NetworkSystem=$VMHostView.Configmanager.NetworkSystem  $VirtualNicManager=$VMHostView.Configmanager.VirtualNicManager  $IscsiManager=$VMHostView.Configmanager.IscsiManager    # Your code comes here!}

 

At each place where in your code is used something like:

 

$_this=Get-View-Id'IscsiManager-iscsiManager-360'$_this.QueryPnicStatus("vmnic1")

 

you need to replace the MoRef with the corresponding variable:

 

$_this=Get-View-Id$IscsiManager$_this.QueryPnicStatus("vmnic1")

 

Replace 'IscsiManager-iscsiManager-360' with $IscsiManager, 'HostVirtualNicManager-virtualNicManager-360' with $VirtualNicManager and 'HostNetworkSystem-networkSystem-360' with $NetworkSystem.


Viewing all articles
Browse latest Browse all 249166

Trending Articles



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