[英]vcenter registration with nsx manager powercli script
I have a working powercli script to re-register vcenter server with nsx manager. 我有一个工作正常的powercli脚本,用于向nsx管理器重新注册vcenter服务器。 Because of my limited/poor knowledge with powercli I am not able to scale this up.
由于我对powercli的了解有限/较差,因此我无法进行扩展。 I want the script to connect to multiple vcenters and nsx managers at the same time and complete this.
我希望脚本同时连接到多个vcenter和nsx管理器并完成此操作。 Any help is appreciated!
任何帮助表示赞赏!
$NSX_IP = "nsx1.com"
$NSX_Username = "admin"
$NSX_Password = "password"
$VC_IP = "vc1.com"
$VC_Username = "administrator@vc1.com"
$VC_Password = "password"
Write-host "Connecting to NSX Manager and registering it to vCenter..." -foreground "magenta"
# Connect to vCenter first
if(!(Connect-VIServer -Server $VC_IP -User $VC_Username -Password $VC_Password)) {
#write-host "Connect-VIServer -Server" + $VC_IP + "-User" + $VC_Username + "-Password" + $VC_Password
write-host "Not able to connect to the vCenter" -foreground "red"
Exit
}
else {
write-host "Connect to vCenter!" -foreground "Cyan"
}
#Connect to NSX Manager
if(!(Connect-NSXServer -Server $NSX_IP -UserName $NSX_Username -Password $NSX_Password)) {
write-host "Not Connected to NSX Manage,r" -foreground "red"
Exit
}
else{
write-host "Connected to NSX Manager" -foreground "Cyan"
}
# Configure vCenter connection on NSX Manager
if(!(Set-NSXManager -vCenterServer $VC_IP -vCenterUserName $VC_Username -vCenterPassword $VC_Password))
{
write-host "vCenter registered with NSXManager" -foreground "Cyan"
}
Put the whole thing in a foreach loop after importing a csv with the constants to do this sequentially. 导入带有常量的csv之后,将整个对象放入foreach循环中以按顺序执行此操作。 To do them simultaneously, maybe use psremoting with Invoke-Command, specifying multiple targets with -comp (auth could be tricky depending on your environment).
要同时执行它们,可能将psremoting与Invoke-Command一起使用,并通过-comp指定多个目标(根据您的环境,auth可能很棘手)。 Or check out get-help about_jobs, more robust but more to learn.
或查看获得帮助about_jobs,功能更强大,但需要更多了解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.