Difference between revisions of "Active Directory (PowerShell)"
Jump to navigation
Jump to search
(→New-ADUser examples: Typo fix) |
(→Getting Started: Added Credentials) |
||
Line 12: | Line 12: | ||
Import-Module ActiveDirectory | Import-Module ActiveDirectory | ||
</source> | </source> | ||
=== Credentials === | |||
Whilst its probably possible to perform <code>Get</code>/read-only CmdLets from your normal login, you should need to use an admin account to actually make changes. If you get the following error, you probably need to supply different username and password credentials to the command. | |||
* '''Either the target name is incorrect or the server has rejected the client credentials.''' | |||
All of the Active Directory module commands allow you to specify a <code>-Credential</code>, you can either pre-create a credentials object, or supply one at the time of running the command. | |||
<source lang="powershell"> | |||
$cred = Get-Credential # Create a credential object, the command will ask for your user/pass | |||
Add-ADGroupMember -Identity $Group -Members $Users -Credential $cred # Add $users to $Group, using $cred credentials | |||
# Alternatively do it all in the same command | |||
Add-ADGroupMember -Identity $Group -Members $Users -Credential (Get-Credential) | |||
</source> | |||
For more info on using Credentials in PowerShell see this page - [[Credentials_(PowerShell)]] | |||
=== Group Policy === | === Group Policy === |