Not able to add users from csv file in to Remote desktop Users group

113 Views Asked by At

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.

1

There are 1 best solutions below

2
Venkat V On

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.

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:

enter image description here

    Import-Csv -Path "C:\Users\v-vallepuv\Desktop\RDP Users.csv" | ForEach-Object {
        $userPrincipalName = $_.'userPrincipalName'
        Write-Host "Adding $userPrincipalName to Remote Desktop Users group"
        Add-LocalGroupMember -Group "Remote Desktop Users" -Member $userPrincipalName
    }

By adding Write-Host statements, you can see the progress of the script and identify any issues.

Output:

enter image description here

Reference: Add-LocalGroupMember