I’m working on a small script to make adding users to our AD easier. It’s just a one line New-ADUser powershell script that asks for inputs. It looks like this:
New-ADUser -Name (Read-Host "User Name") -AccountExpirationDate 0 -CannotChangePassword 1 -ChangePasswordAtLogon 0 -PasswordNeverExpires 1 -Company (Read-Host "Company") -Department (Read-Host "Department") -Title (Read-Host "Title") -Manager (Read-Host "Manager's User Name") -GivenName (Read-Host "Full Name") -MobilePhone (Read-Host "Cell Phone Number") -State (Read-Host "State") -AccountPassword (Read-Host -AsSecureString "Password") -ProfilePath (Read-Host "Roaming Profile Path") -Path (Read-Host "AD Path to User")
It asks for everything like it should but after inputting everything it returns: “New-ADUser : Not a valid Win32 FileTime. At line:1 char:11.” I checked that location in the command (it’s the space after “New-ADUser”) and I don’t know why it would return that.
Is this an efficient way of doing what I want? How can I fix my command to not return the error? Is it what I’m inputting into the spots?
You have to change:
with
or you can simply not set this parameter for an unexpiring account.
This technet page has an error.