Bulk Update
1 TopicUpdate Azure AD / Microsoft 365 users information - Office Phone numbers from a CSV file
Hello, I am trying to update the Office Phone numbers of my Microsoft 365 users using a list in a CSV file. Generally, the code works - it successfully updates all other attributes that are in the code (JobTitle, City, Office, etc.). Code: # Connect to Azure using the Az module Connect-AzAccount # Import the CSV file $csvPath = 'C:\Temp\AzureADUserAttributes.csv' $users = Import-Csv -Path $csvPath # Iterate through each user in the CSV and update their information foreach ($user in $users) { $userPrincipalName = $user.UserPrincipalName # Retrieve the user using Az module $existingUser = Get-AzADUser -UserPrincipalName $userPrincipalName # Check if the user exists if ($existingUser) { # Construct a hashtable of properties to update $userProperties = @{} # Update properties if they exist in the CSV if ($user.JobTitle) { $userProperties['JobTitle'] = $user.JobTitle } if ($user.Department) { $userProperties['Department'] = $user.Department } if ($user.CompanyName) { $userProperties['CompanyName'] = $user.CompanyName } if ($user.City) { $userProperties['City'] = $user.City } if ($user.Country) { $userProperties['Country'] = $user.Country } if ($user.PostalCode) { $userProperties['PostalCode'] = $user.PostalCode } if ($user.State) { $userProperties['State'] = $user.State } if ($user.StreetAddress) { $userProperties['StreetAddress'] = $user.StreetAddress } if ($user.Office) { $userProperties['Office'] = $user.Office } # Update user information only if there are properties to update if ($userProperties.Count -gt 0) { # Update user information using Az module Set-AzADUser -UserPrincipalName $userPrincipalName @userProperties Write-Host "User information updated for $userPrincipalName" } else { Write-Host "No properties to update for $userPrincipalName" } } else { Write-Host "User not found: $userPrincipalName" } } # Disconnect from Azure session (if needed) Disconnect-AzAccount However, when I add a new line after line 29 (if ($user.Office) { $userProperties['Office'] = $user.Office }) new line if ($user.TelephoneNumber) { $userProperties['TelephoneNumber'] = $user.TelephoneNumber } it throws an error: Update-AzADUser : A parameter cannot be found that matches parameter name 'TelephoneNumber'. At C:\Path\Update Bulk Azure AD Users information.ps1:36 char:64 + ... Set-AzADUser -UserPrincipalName $userPrincipalName @userProperties + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Update-AzADUser], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Update-AzADUser In the CSV File, the column with the phone number is called the same as in the code i.e. "TelephoneNumber". I tried different names: OfficeNumber BusinessPhones PhoneNumber Phone etc., but with each there is the same error.Solved4.6KViews0likes3Comments