Aug 02 2020
04:56 AM
- last edited on
Jan 14 2022
04:29 PM
by
TechCommunityAP
Aug 02 2020
04:56 AM
- last edited on
Jan 14 2022
04:29 PM
by
TechCommunityAP
Hello Community,
I'm trying to update users in bulk for the attribute of Azure AD which is called "Company Name" but when I tried to export all of the users in CSV, unfortunately, there was no such a column like that in the file. Is there anyway to workaround or there is a way to actually complete this without any hassle?
Thank you all for your supports!
P/S: I'm following this topic for the configuration: https://techcommunity.microsoft.com/t5/windows-powershell/bulk-update-azure-ad-with-user-attributes-...
Also, what does "physicalDeliveryOfficeName" attribute mean since I saw a column in the exported CSV?
Aug 02 2020 08:23 AM
You should share the code, unless you want us to guess :) If you are using the New-AzureADUser cmdlet to set the attribute, there's a known issue with that. Use the Set-AzureADUser cmdlet post creation.
Aug 02 2020 08:31 AM
@Vasil Michev I don't even know if it's new or old? I just want to get the job done and I said I followed the following PS script in this topic: https://techcommunity.microsoft.com/t5/windows-powershell/bulk-update-azure-ad-with-user-attributes-...
Something like this by the replying of @Manfred101:
# Connect to AzureAD
Connect-AzureAD
# Get CSV content
$CSVrecords = Import-Csv C:\Temp\Test.csv -Delimiter ";"
# Create arrays for skipped and failed users
$SkippedUsers = @()
$FailedUsers = @()
# Loop trough CSV records
foreach ($CSVrecord in $CSVrecords) {
$upn = $CSVrecord.UserPrincipalName
$user = Get-AzureADUser -Filter "userPrincipalName eq '$upn'"
if ($user) {
try{
$user | Set-AzureADUser -Department $CSVrecord.Department -TelephoneNumber $CSVrecord.TelephoneNumber
} catch {
$FailedUsers += $upn
Write-Warning "$upn user found, but FAILED to update."
}
}
else {
Write-Warning "$upn not found, skipped"
$SkippedUsers += $upn
}
}
# Array skipped users
# $SkippedUsers
# Array failed users
# $FailedUsers
And when you tried to export the users in Azure AD to CSV, note that there is no "Company Name" column in the file, I also want to ask how to add it into the CSV file so that I can do the bulk update of Company Name for all of the Users since we actually have 3 entities in real life but managed by only 1 entities in IT section. Because of that, I have to create a Dynamic Group so that it can do the queries to sort which ones of which company and add to the correct Groups.
Aug 03 2020 08:14 AM
Well how are you exporting it, the code above has nothing that relates to exporting to CSV file. I can see the CompanyName attribute just fine via the Get-AzureADUser cmdlet...
Mar 09 2022 02:06 AM
@Vasil Michev What am I doing wrong here?
I need to update office and company...
# Connect to AzureAD
Connect-AzureAD
# Get CSV content
$CSVrecords = Import-Csv C:\PSscripts\office.csv -Delimiter ","
# Create arrays for skipped and failed users
$SkippedUsers = @()
$FailedUsers = @()
# Loop trough CSV records
foreach ($CSVrecord in $CSVrecords) {
$upn = $CSVrecord.UserPrincipalName
$user = Get-AzureADUser -Filter "userPrincipalName eq '$upn'"
if ($user) {
try{
Set-AzureADUser -ObjectId $($_.ObjectId) -PhysicalDeliveryOfficeName $CSVrecord.PhysicalDeliveryOfficeName -CompanyName $CSVrecord.CompanyName
} catch {
$FailedUsers += $upn
Write-Warning "$upn user found, but FAILED to update."
}
}
else {
Write-Warning "$upn not found, skipped"
$SkippedUsers += $upn
}
}
# Array skipped users
# $SkippedUsers
# Array failed users
# $FailedUsers
---------
CVS looks like this.
But i'm getting the error...
Warning: xxxx user found but failed to update.
If i do not use OBjectID, it throws an error...
cmdlet Set-AzureADUser at command pipeline position 1
Supply values for the following parameters:
ObjectId:
Appreciate your help.
Thanks
Apr 27 2022 10:11 AM