VMware Cloud Community
RobMokkink
Expert
Expert
Jump to solution

JoinDomain_Task + cmdlet

Is there also a cmdlet for the JoinDomain_Task?

So i can configure the Authentication Services

Reply
0 Kudos
1 Solution

Accepted Solutions
ykalchev
VMware Employee
VMware Employee
Jump to solution

Hi Rob,

Executing JoinDomain_task in PowerCLI 4.1 is a little bit tricky since some of the new vSphere 4.1 host managers are missing in VMware.Vim assembly. However you can workaround the problem with this simple script:

function GetHostADAuthManagerMoRef($vmHost) {
	$filter = New-Object VMware.Vim.PropertyFilterSpec
	$filter.ObjectSet += New-Object VMware.Vim.ObjectSpec
	$filter.ObjectSet[0].Obj = $vmHost.ConfigManager.AuthenticationManager
	$filter.PropSet += New-Object VMware.Vim.PropertySpec
	$filter.PropSet[0].Type = "HostAuthenticationManager"
	$filter.PropSet[0].All = $true
	
	$collector = Get-View $vmHost.Client.ServiceContent.PropertyCollector 
	$content = $collector.RetrieveProperties($filter)
	$supportedStore = $content[0].PropSet | ? {$_.Name -eq "supportedStore"} 
	$result = $supportedStore.Val | ? {$_.Type -eq "HostActiveDirectoryAuthentication"}
	
	return [http://VMware.Vim.VIConvert|http://VMware.Vim.VIConvert]::ToVim41($result)
}

Connect-VIServer 'MyVC' -User 'Username' -Pass 'Password'
$vmHost = Get-View (Get-VMHost 'MyHost')
$authManagerMoRef = GetHostADAuthManagerMoRef($vmHost)

$taskMoRef = $vmHost.Client.VimService.JoinDomain_Task($authManagerMoRef, 'DomainToJoin', 'DomainUsername', 'Password')
$vmHost.WaitForTask([http://VMware.Vim.VIConvert|http://VMware.Vim.VIConvert]::ToVim($taskMoRef))

Regards,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team

View solution in original post

Reply
0 Kudos
9 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Afaik there is no cmdlet for the JoinDomain_Task. The JoinDomain_Task in HostActiveDirectoryAuthentication is new in PowerCLI 4.1. In the VMware vSphere PowerCLI Change Log there is no cmdlet mentioned for this task.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
RobMokkink
Expert
Expert
Jump to solution

I am struggeling a little bit with the SDK on this subject.

How can you enable the JoinDomain_task on the host?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Do you mean the call to JoinDomain_Task ?

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
RobMokkink
Expert
Expert
Jump to solution

That's the one. I need to configure the authentication services to active directory.

Reply
0 Kudos
ykalchev
VMware Employee
VMware Employee
Jump to solution

Hi Rob,

Executing JoinDomain_task in PowerCLI 4.1 is a little bit tricky since some of the new vSphere 4.1 host managers are missing in VMware.Vim assembly. However you can workaround the problem with this simple script:

function GetHostADAuthManagerMoRef($vmHost) {
	$filter = New-Object VMware.Vim.PropertyFilterSpec
	$filter.ObjectSet += New-Object VMware.Vim.ObjectSpec
	$filter.ObjectSet[0].Obj = $vmHost.ConfigManager.AuthenticationManager
	$filter.PropSet += New-Object VMware.Vim.PropertySpec
	$filter.PropSet[0].Type = "HostAuthenticationManager"
	$filter.PropSet[0].All = $true
	
	$collector = Get-View $vmHost.Client.ServiceContent.PropertyCollector 
	$content = $collector.RetrieveProperties($filter)
	$supportedStore = $content[0].PropSet | ? {$_.Name -eq "supportedStore"} 
	$result = $supportedStore.Val | ? {$_.Type -eq "HostActiveDirectoryAuthentication"}
	
	return [http://VMware.Vim.VIConvert|http://VMware.Vim.VIConvert]::ToVim41($result)
}

Connect-VIServer 'MyVC' -User 'Username' -Pass 'Password'
$vmHost = Get-View (Get-VMHost 'MyHost')
$authManagerMoRef = GetHostADAuthManagerMoRef($vmHost)

$taskMoRef = $vmHost.Client.VimService.JoinDomain_Task($authManagerMoRef, 'DomainToJoin', 'DomainUsername', 'Password')
$vmHost.WaitForTask([http://VMware.Vim.VIConvert|http://VMware.Vim.VIConvert]::ToVim($taskMoRef))

Regards,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team
Reply
0 Kudos
RobMokkink
Expert
Expert
Jump to solution

Hi Yasen,

Thanks for your quick response. I will test it asap.

Reply
0 Kudos
RobMokkink
Expert
Expert
Jump to solution

It work perfectly. Thanks a lot!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Fyi I created a function around this bypass and added a function to retrieve the authentication settings.

See my Script vSphere 4.1 AD Authentication post.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

RobMokkink
Expert
Expert
Jump to solution

Luc thanks for the great functions.

Reply
0 Kudos