I'm wondering if it's possible to create a service account remotely from the SQL box using PowerShell, and put the service accounts created in the OU (folder) they belong in AD as part of a unattended SQL install.

Could this be done without having to pre-create the service accounts before SQL installation? I'm able to query the AD from the SQL box by importing the AD module.

有帮助吗?

解决方案

If you have installed the Active Directory PowerShell components, and the account under which you are running the session has sufficient permission to perform the action, then it is actually pretty simple:

New-ADUser -Name "Jo Bloggs" -GivenName Jo -Surname Bloggs`
-SamAccountName jbloggs -UserPrincipalName jbloggs@corp.contoso.com `
-AccountPassword (Read-Host -AsSecureString "AccountPassword") `
-Path 'OU=Whatever,OU=Blah,DC=corp,DC=contoso,DC=com' `
-PassThru | Enable-ADAccount

The documentation is pretty extensive and can be found here: https://technet.microsoft.com/en-us/library/ee617253.aspx

许可以下: CC-BY-SA归因
不隶属于 dba.stackexchange
scroll top