$vmhost_list = Import-Csv .\Desktop\hlw_vmhost_user_list.csv 
foreach ($vmhost in $vmhost_list){ 
    Connect-VIServer $vmhost.esxi_ip -user $vmhost.esxi_user -Password $vmhost.esxi_passwd
    New-VMHostAccount -Id $vmhost.oss_user -Password $vmhost.oss_passwd -UserAccount
    New-VIPermission -Entity $vmhost.esxi_ip -Principal ossuser -Role ReadOnly -Propagate:$true
}

esix主机登录信息表

powershell-批量创建ESXI主机账号_第1张图片