Found this great script online that joins all ESX to domain. I am trying to modify it and also set permissions on each ESX server to a security group or a username. I can't really get it to work as it does set the permission but it set it within vcenter itself for that host and I want the permission to be set within ESX. I am using the option with vcenter so I am guessing once PS connect to Vcenter it needs to reconnect to ESX to do that.
These are the lines I added to the script but it still doesnt work. I would request anyone with more experience on powercli to help me fix this.
Appreciate it. BTW I want to give credit to whoever created this script initially.
#Set Active Directory Permissions within each ESX host
connect-viserver $VMHost -credential $VMHosts_creds > $NULL 2>&1
New-VIPermission -Principal "domain\username" -role admin -entity $getvmhost
disconnect-viserver $VMHost -confirm:$false
yea I know but what I am trying to do is to not specify each ESX host .. I would like to go into vcenter itself pick up the list and then set permissions for each host... using this script..shouldn't be that hard once connected to vcenter then connect to each host do the job and then exit.
I think if you get rid of $getvmhost and use $VMHost instead. When calling $VMHost within commands use $VMHost.Name. This will only select the name property of object being passed in the loop, otherwise you are passing all properties for the oject in $VMHost which could be causing an issue. I am not able to view the script at this moment and going off of memory.
Also, you might try using this script as a template and creating a new script. Might find the new script less confusing.