I am able to import .csv file and its working for me without any error, but not able to add the users in Remote Desktop Users list. Can any one know the solution.
Import-csv -Path "C:\Users\Intune.Autopilot.Poc\Downloads\employees.csv" | ForEach-Object {
Add-LocalGroupMember -Group "Remote Desktop Users" -Member $_.'userPrincipalName'
}
my csv file contains only userPrinicipalName [email protected] advance thanks for helping.
please help me to get the issue resolved.
If you are trying to add users to the Remote Desktop Users group using PowerShell and a CSV file.
Make sure that CSV file is properly formatted and that the column header for userPrincipalName is spelled correctly and also there are no extra spaces or special characters in the values.
Here is the updated code to add users to the Remote Desktop Users
Excel Format:
By adding
Write-Hoststatements, you can see the progress of the script and identify any issues.Output:
Reference: Add-LocalGroupMember