我正在编写一个小脚本,以使添加用户到我们的AD更容易。这只是一个请求输入的New-ADUser powershell脚本。它看起来是这样的:
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")它会要求所有内容,但在输入所有返回内容后:“Win32 -ADUser: Not a valid Win32 FileTime. At line:1 char:11.”我在命令中检查了该位置(“New-ADUser”后的空格),但我不知道它为什么会返回该位置。
这是做我想做的事情的有效方式吗?如何修复我的命令,使其不返回错误?这是我输入到斑点中的内容吗?
发布于 2012-10-16 02:45:05
你必须改变:
-AccountExpirationDate 0使用
-AccountExpirationDate $null或者,您也可以简单地不为未到期的帐户设置此参数。
This technet页面有错误。
发布于 2016-10-28 23:44:40
对于Windows Server 2016,存在上述问题,并且上述解决方案(完全)不起作用。
我已经找到了一种解决方法。
是的,上面的Technet页面有一个错误;不幸的是,这也会导致PowerShell脚本系统在解析脚本时出现问题
因此-错误#1 -如果使用指定的命令New-ADUser并将0作为参数,则会得到错误New-ADUser : Not a valid win32 FileTime.
将0更改为$null时,将出现错误#2 - The term '(the next parameter in your command)' is not recognized as the name of a cmdlet, function
我找到了以下解决方案来彻底解决这个问题:
将此参数更改为最后一个参数(如上) -AccountExpirationDate $null
https://stackoverflow.com/questions/12901779
复制相似问题