AD samAccountname脚本错误 [英] AD samAccountname scripting error

查看:65
本文介绍了AD samAccountname脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试输入一个包含Givename&用户的姓氏信息。当我运行下面列出的命令时,samAccountName没有给我期望的输出。

I'm trying to input a csv file, which contains Givename & Lastname information of the users. When I run the command listed below samAccountName does not give me the expected output.

请参阅下面的内容,让我知道应该更正的内容。

Please see below and let me know what should be corrected.

输入:

GivenName,LastName,Password,TargetOU,Description,Manager
Jeffrey,Terry,Pass12,"OU=Users,DC=mmc,DC=local",mmc user,knadella
A,King,Pass13,"OU=Users,DC=mmc,DC=local",mmc user,knadella
Chris ,Charles,Pass14,"OU=Users,DC=mmc,DC=local",mmc user,knadella

命令:

$samAccountName = ($csvcontent.GivenName.Substring(0,1))+( $csvcontent.LastName)

当前输出:

J A C Terry King Charles

所需的输出:

ATerry, AKing and CCharles 

请协助。谢谢!

推荐答案

您将一次性汇总所有详细信息,并结合 GivenName的结果列( JAC )和列( Terry King Charles )`

You are aggregating all of the details in one go, combining the results of the GivenNamecolumn (J A C) with the results of the LastName column (Terry King Charles)`

此循环遍历每个用户:

foreach($user in $csvcontent){
    [array]$samAccountName += $user.GivenName[0] + $user.LastName
}

输出:

JTerry AKing CCharles

这篇关于AD samAccountname脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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