2020 年 3 月 25 日

IT Skills 波林

Polin WEI – 資訊工作者的技術手札

利用 PowerShell Script 將帳號加入群組

1 min read
獨木橋

Add Users To a Group by PowerShell Script

  • Purpose – Add users to a group from an input file – PowerShell V2 Script.
  • Input file – Input file (Users.csv) contains samAccountName in the following format:
# Users.csv
UserName
polin.wei
jack.wei

PowerShell Code:

# 
# Add User to a Group - PowerShell Script 
# 
Import-module ActiveDirectory  
Import-CSV "C:\Scripts\Users.csv" | % {  
Add-ADGroupMember -Identity testGroup -Member $_.UserName  
}

Ref: http://portal.sivarajan.com/2011/07/add-users-to-grouppowershell-script.html

Copyright © All rights reserved. | Newsphere by AF themes.