jeffreywmcclain
Enthusiast
Enthusiast

Join VCSA VM to Active Directory using PowerCLI?

Jump to solution

Ideally, I'd like to create a script that checks if a vCenter is already joined to a specific Active Directory domain (and if not, the script should join the vCenter to said domain).

The reason for this is I have a lab environment with several nested VCSAs which get reset to a snapshot on a weekly basis (allowing people to run whatever tests they want each week).

However, I've noticed that the VCSAs eventually stop authenticating with Active Directory (used for Windows session authentication) which requires me to manually rejoin each one. I assume this has to do with restoring them from a snapshot, but since manually rejoining them seems to work fine so ideally I'd just like a way to automate this process.

I found KB50112055 which shows how this can be done via SSH, I just wanted to validate whether or not there is a cmdlet / method of doing this in PowerShell / PowerCLI natively.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Afaik there is no cmdlet for that functionality.
The only way I know is that command via an SSH session.

Luckily you can automate that with the Posh-SSH module, see my Use Posh-SSH instead of PuTTY post.


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

View solution in original post

4 Replies
LucD
Leadership
Leadership

Afaik there is no cmdlet for that functionality.
The only way I know is that command via an SSH session.

Luckily you can automate that with the Posh-SSH module, see my Use Posh-SSH instead of PuTTY post.


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

jeffreywmcclain
Enthusiast
Enthusiast

Thanks, I suspected as much but just wanted to be sure.

I've been using the Posh-SSH but sadly it still doesn't support PowerShell Core / PowerShell 7.

I guess I'll just stick with PowerShell 5.1 for now since most of my scripts tend to have SSH commands as part of them.

0 Kudos
LucD
Leadership
Leadership

According to issue #130 it shouldn't be long :smileygrin:


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

jeffreywmcclain
Enthusiast
Enthusiast

Funny you mention that, I was actually the most recent commenter on that GitHub issue, lol.

Definitely looking forward to Posh-SSH working with PowerShell 7, hopefully the SSH.net library is updated soon with the necessary changes.