使用new-aduser脚本获取批量用户创建错误 [英] Getting error with Bulk user creations with new-aduser script

查看:224
本文介绍了使用new-aduser脚本获取批量用户创建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,只是尝试使用以下脚本创建批量广告用户但失败了:

Hello guys, just trying to create bulk ad user with the help of following script but failed:

Import-Csv 。\ users.csv | foreach-object {
$
$ userprinicpalname = $ _。SamAccountName +" @ EXAMPLE .com"


New-ADUser -SamAccountName $ _。 SamAccountName -UserPrincipalName $ userprinicpalname -Name $ _。 name -DisplayName $ _。 名称 -GivenName $ _。 cn - " ipPhone" $ _.ipPhone -AccountPassword(ConvertTo-SecureString
" PASSWORD1 " -AsPlainText -force)-Enabled $ True -PasswordNeverExpires $ True -PassThru}

Import-Csv .\users.csv | foreach-object {
$userprinicpalname = $_.SamAccountName + "@EXAMPLE.com"
New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $userprinicpalname -Name $_.name -DisplayName $_.name -GivenName $_.cn -"ipPhone" $_.ipPhone -AccountPassword (ConvertTo-SecureString "PASSWORD1" -AsPlainText -force) -Enabled $True -PasswordNeverExpires $True -PassThru }

得到以下错误:

PS C:\ Users \ad.admin \Desktop \Shell> 。\ BULKUSERSCRIPT.ps1

New-ADUser:找不到接受参数'-ipPhone'的位置参数。

在C:\ Users \ ad。 admin \Desktop \Shell \ BULKUSERSCRIPT.ps1:5 char:2

+  New-ADUser -SamAccountName $ _。SamAccountName -UserPrincipalName $ userprinicpaln ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo         :InvalidArgument:(:) [New-ADUser],ParameterBindingException

    + FullyQualifiedErrorId:PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.NewADUser

PS C:\Users\ad.admin\Desktop\Shell> .\BULKUSERSCRIPT.ps1
New-ADUser : A positional parameter cannot be found that accepts argument '-ipPhone'.
At C:\Users\ad.admin\Desktop\Shell\BULKUSERSCRIPT.ps1:5 char:2
+  New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $userprinicpaln ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.NewADUser

请帮助。

推荐答案

检查New-ADUser的帮助,没有-ipPhone参数。请改用-OtherAttributes参数,这需要一个属性赋值的哈希表,类似于:

Check the help for New-ADUser, there is no -ipPhone parameter. Use the -OtherAttributes parameter instead, which requires a hash table of attribute assignments, similar to:

-OtherAttributes @{title="director";mail="glenjohn@fabrikam.com"}





这篇关于使用new-aduser脚本获取批量用户创建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆