首页 > 系统服务 > 详细

Powershell批量修改用户的UPN后缀

时间:2018-01-16 17:49:29      阅读:546      评论:0      收藏:0      [点我收藏+]
适用产品:Windows Server ActiveDirectory
查询AD中UPN为空的用户
Get-ADUser -Filter * -Properties * | where {$_.UserPrincipalName -eq $null} | Select-Object name,SamAccountName,UserPrincipalName
设置UPN后缀
Get-ADUser -Filter * -Properties * | where {$_.UserPrincipalName -eq $null} | Select-Object name,SamAccountName,UserPrincipalName | foreach {Set-ADUser -Identity $_.name -UserPrincipalName ($_.SamAccountName+"@contoso.com")}
查询结果
PS C:\Users\Administrator> Get-ADUser -Filter * -Properties * | where {$_.UserPrincipalName -eq $null} | Select-Object name,SamAccountName,UserPrincipalName

name                       SamAccountName             UserPrincipalName        
----                       --------------             -----------------        
Guest                      Guest                                               
krbtgt                     krbtgt                                              
mailuser2                  mailuser2                                           
mailuser3                  mailuser3                                           
mailuser4                  mailuser4                                           
mailuser5                  mailuser5                                           
mailuser6                  mailuser6                                           
mailuser7                  mailuser7                                           
mailuser8                  mailuser8                  
设置结果
Get-ADUser -Filter * -Properties * | where {$_.UserPrincipalName -ne $null} | Select-Object name,SamAccountName,UserPrincipalName
name                                                        SamAccountName                                              UserPrincipalName                                         
----                                                        --------------                                              -----------------                                         
Administrator                                               Administrator                                               Administrator@demo.com                                    
Guest                                                       Guest                                                       Guest@demo.com                                            
krbtgt                                                      krbtgt                                                      krbtgt@demo.com                                           
Exchange Online-ApplicationAccount                          $331000-K0SAH4NCDJ2K                                        Exchange_Online-ApplicationAccount@demo.com   

Powershell批量修改用户的UPN后缀

原文:http://blog.51cto.com/543925535/2061643

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!