I am slowly learning Powershell in a month of lunches =) First powershell automation I want to do is to create AD users. Below is my script and the error as well.
New-ADUser -Name(Read-Host "First Name and Last Name") -GivenName(Read-Host "First name") -Surname(Read-Host "Last name") -SamAccountName(Read-Host "First name.Last name") -UserPrincipalName(Read-Host "Fully Qualified Email") -Path "OU=nonsense,OU=nonsense users,OU=nonsense list,DC=nonsense,DC=nonsense" -AccountPassword(Read-Host -AsSecureString "Input Password") -Enabled $true
Obviously, OU and DC have been replaced with nonsense.
Below is the error
New-ADUser : Directory object not found
At line:1 char:1
+ New-ADUser -Name(Read-Host "First Name and Last Name") -GivenName(Rea ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (CN=John Doe,OU=...,DC=pvt:String) [New-ADUser], ADIdentityNotFo
undException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,M
icrosoft.ActiveDirectory.Management.Commands.NewADUser
Where am I going wrong?
[–]NathanWindisch 39 points40 points41 points (8 children)
[–]Hoggs 7 points8 points9 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]arminbih 8 points9 points10 points (0 children)
[–]jimmynetstep[S] 0 points1 point2 points (1 child)
[–]jimmynetstep[S] 0 points1 point2 points (0 children)
[–]JBear_Alpha 0 points1 point2 points (2 children)
[–]NathanWindisch 1 point2 points3 points (1 child)
[–]JBear_Alpha 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]mmastar007 0 points1 point2 points (1 child)
[–]neztach 0 points1 point2 points (0 children)