[英]Azure AD Updating Bulk users from CSV
我是新手,所以如果我錯過了一些信息,請道歉。
我有以下情況:
我在 CSV 中有一個員工列表,我需要通過 powershell 更新租戶中的現有用戶。我嘗試了一些我在網上找到的腳本,但沒有一個我可以工作。 我可以連接到租戶並導入 csv 但僅此而已。
我需要更新以下內容:
傳真、辦公室、街道地址、城市、郵政編碼、部門、職務、辦公電話、手機和郵件
有人可以給我一個模板或類似的東西嗎? 我真的很感激一些幫助。
如果您的 csv 文件以可區分的 object列出,例如 Active Directory 用戶sAMaccount及其相關數據“傳真、辦公室、街道地址、城市、郵政編碼、部門、職務、辦公電話、手機和郵件”
更新 Active Directory 用戶屬性的高級步驟
從 CSV 文件更新 AD 用戶的示例腳本
#Import Active Directory module
Import-Module ActiveDirectory
#Import CSV File to set variable for the user’s logon name + update data + delimiter
$Users = Import-CSV -Delimiter ";" -Path "c:\psscripts\users.csv"
#Using your code to filter AD Sam Accounts listed CSVData is listed with the information you wish to update
Foreach($user in $users){
#Using your code to filter AD Sam Accounts Based on column samaccountname in the csv file
Get-ADUser -Filter "SamAccountName -eq '$($user.samaccountname)'" | Set-ADUSer `
-fax $($User.Fax) `
-office $($User.Office) `
-StreetAddress $($User.StreetAddress) `
-city $($User.City) `
-postalcode $($User.PostCode) `
-title $($User.Title)`
-department $($User.Department) `
-officephone $($User.Officephone) `
-mobilephone $($User.Mobilephone) `
-mail ($User.Mail)
}
下面的帖子分享了 PowerShell 腳本,通過從 CSV 文件導入用戶詳細信息,以簡單的方式修改多個用戶帳戶的批量用戶屬性。
https://morgantechspace.com/2022/03/update-bulk-azure-ad-user-attributes-using-powershell.html
此腳本有助於在單個命令 (Set-AzureADUser) 中將批量用戶屬性更新為哈希表。
#Hashtable to keep multiple attribute values
$AttributesToUpdate = @{}
$AttributesToUpdate["JobTitle"] = "Sales Manager"
$AttributesToUpdate["Department"] = "Sales"
# Set required user attributes.
# Need to prefix the variable AttributesToUpdate with @ symbol instead of $ to pass hashtable as parameters (ex: @AttributesToUpdate).
Set-AzureADUser -ObjectId "user@domain.com" @AttributesToUpdate
# Refer to the below post for more details.
# https://morgantechspace.com/2022/03/update-bulk-azure-ad-user-attributes-using-powershell.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.