重命名Active Directory用户 [英] Rename Active Directory Users

查看:83
本文介绍了重命名Active Directory用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Hello专家,我需要帮助来完成我的脚本。

Hello Experts, i need help to finish my script.


我们有一个拥有800个用户的Active Directory,我们曾经创建了一个基于名字和姓氏的第一个字母的帐户(例如John lennon将是jlennon)

但是现在我们需要为第一个点名更改它,所以jlennon必须被替换为john.lennon。

我开始用powershell做这个但是我面临一些麻烦来制作它工作。

We have an Active Directory with 800 users, and we used to create an account based in the first letter of the name and the last name (e.g John lennon will be jlennon)
But now we need change it for the first dot last name so jlennon have to be replaced to john.lennon.
I started to do this with powershell but i'm facing some trouble to make it work.


函数列表 - ValidUsers {

Function List-ValidUsers{

$ validUsers = Get-ADUser -Filter {enabled -eq $ TRUE }

$validUsers=Get-ADUser -Filter {enabled -eq $TRUE}

foreach($ validUsers中的$ user){

foreach ($user in $validUsers){

$ new =($ user.GivenName +"。 " + $ user.SurName)。ToLower()

$new=($user.GivenName + ". " + $user.SurName).ToLower()

}

问题是用户是否有名字(例如John Winston Ono Lennon,GivenName是John和Surname是Winston Ono Lennon)

The problem is if a user have a name (e.g John Winston Ono Lennon, GivenName is John and Surname is Winston Ono Lennon)

所以当我调用我的函数时它会创建john.Winston Ono Lennon

So when i call my function it will create john.Winston Ono Lennon

如何创建一个只创建john.lennon的函数?

How can i create a function to create only john.lennon?

非常感谢。

问候。

推荐答案

您可以在空格上拆分姓氏字符串并返回最后一个字符串像这样的数组:

You can split the surname string on spaces and return the last string in the array like so:


surname =
surname =



这篇关于重命名Active Directory用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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