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

Apply a host profile to multiple hosts from csv

$
0
0

I'm really close on this one I think.  The contents of my hostprofile.csv are:

 

"NAME,STATE,STATUS,% CPU,% MEMORY,LAST TIME EXITED STANDBY,ALARM ACTIONS,AUTODEPLOY.MACHINEIDENTITY,CREATED BY,FUNCTION,NOTIFICATION DL,OWNER/REQUESTER"

"esxdc2s01.DOMAIN.local,Maintenance Mode,Normal,0%,2%,Never,Enabled,,,,,"

"esxdc2s02.DOMAIN.local,Maintenance Mode,Normal,0%,2%,Never,Enabled,,,,,"

"esxdc2s03.DOMAIN.local,Maintenance Mode,Alert,0%,2%,Never,Enabled,,,,,"

 

And my code is:

 

$HostList = Import-Csv Hostprofiles.csv

Connect-VIServer -Server VIRTUALCENTER.DOMAIN.local -User "qa\a-dubutcher" -Password MYPASSWORD

# Apply host profile to all the VMs in $HostList
foreach($Host in $HostList) {
    Apply-VMHostProfile -Entity $($Host.NAME) -Profile YKFProfile -Confirm:$false
}

 

 

And my error message is:

 

Cannot overwrite variable Host because it is read-only or constant.
At C:\Users\dubutcher\Dropbox\VMware\Scripts\Blackberry_Applyprofile.ps1:6 char
:8
+ foreach <<<< ($Host in $HostList) {
    + CategoryInfo          : WriteError: (Host:String) [], SessionStateUnauth
   orizedAccessException
    + FullyQualifiedErrorId : VariableNotWritable

 

 

Any suggestions?


Viewing all articles
Browse latest Browse all 229602

Trending Articles



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