사용자는 Microsoft Entra ID에서 Microsoft Entra의 회사 또는 학교 사용자 계정 또는 개인 Microsoft 계정을 나타냅니다. Microsoft Entra PowerShell의 사용자 리소스는 사용자의 표현이며 사용자와 관련된 관계 및 리소스를 포함합니다.
사용자 리소스는 추가 호출을 수행하고, 특정 인증 정보를 조회하고, 다른 Microsoft Entra PowerShell 개체에 대해 쿼리를 직접 실행하지 않고도 사용자 리소스에 액세스하고 조작할 수 있는 간단한 방법을 제공합니다.
사전 요구 사항
Microsoft Entra PowerShell을 사용하여 사용자를 관리하려면 다음이 필요합니다.
- Microsoft Entra 사용자 계정. 계정이 없다면 무료로 만들 수 있습니다.
- 적어도 클라우드 애플리케이션 관리자 역할.
- Microsoft Entra PowerShell 모듈이 설치되었습니다. Microsoft Entra PowerShell 모듈 설치 가이드에 따라 모듈을 설치합니다.
사용자 정보에 액세스하고 해당 사용자를 대신하여 또는 자체 ID를 사용하여 앱으로 데이터를 관리할 수 있습니다.
사용자 온보딩
사용자를 온보딩하려면 Microsoft Entra ID 새 사용자 계정을 만듭니다. 이 프로세스에는 표시 이름, 전자 메일 주소 및 암호를 포함하여 사용자의 프로필을 설정하는 작업이 포함됩니다.
사용자 만들기
이 예제에서는 새 사용자를 만듭니다.
Connect-Entra -Scopes 'User.ReadWrite.All'
$passwordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$passwordProfile.Password = '<Strong-Password>'
$userParams = @{
DisplayName = 'New User'
PasswordProfile = $passwordProfile
UserPrincipalName = 'NewUser@contoso.com'
AccountEnabled = $true
MailNickName = 'NewUser'
}
New-EntraUser @userParams
출력에는 새로 만든 사용자의 세부 정보가 표시됩니다.
DisplayName Id Mail UserPrincipalName
----------- -- ---- -----------------
New User aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb NewUser@contoso.com
사용자 대량 만들기
여러 사용자를 대량으로 만들려면 CSV 파일을 사용할 수 있습니다. CSV 파일에는 필요한 사용자 특성(예: DisplayName, UserPrincipalName및 PasswordProfile)이 포함되어야 합니다.
# Connect to Microsoft Entra PowerShell
Connect-Entra -Scopes 'User.ReadWrite.All'
# Create a new Password Profile for the new users. We'll be using the same password for all new users in this example
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = '<Your-Password>'
# Import the csv file. You will need to specify the path and file name of the CSV file in this cmdlet
$NewUsers = import-csv -Path '<path-to-your-csv-file>'
# Loop through all new users in the file to create them in Microsoft Entra ID
ForEach ($user in $NewUsers) {
# Create a new user in Microsoft Entra ID
New-EntraUser -UserPrincipalName $user.'EmailAddress' -DisplayName $user.'DisplayName' -GivenName $user.'FirstName' -Surname $user.'LastName' -Department $user.'Department' -MailNickname $user.'MailNickname' -AccountEnabled $true -PasswordProfile $passwordProfile
}
| 이름 (FirstName) | 성씨 | DisplayName | 이메일 주소 | 부서 | 메일 별칭 |
|---|---|---|---|---|---|
| Adele | Vance | 아델 밴스 | adelev@contoso.com | Marketing | adelev |
출력에는 새로 만든 사용자의 세부 정보가 표시됩니다.
DisplayName Id Mail UserPrincipalName
----------- -- ---- -----------------
Adele Vance aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb adelev@contoso.com
사용자의 암호 업데이트
관리자가 사용자의 암호를 업데이트하려면 다음 명령을 사용합니다.
Connect-Entra -Scopes 'Directory.AccessAsUser.All' $newPassword = '<strong-password>' $securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force Set-EntraUserPasswordProfile -UserId 'SawyerM@contoso.com' -Password $securePassword로그인한 사용자(셀프 서비스)의 암호를 업데이트하려면 다음 명령을 사용합니다.
Connect-Entra -Scopes 'Directory.AccessAsUser.All' $currentPassword = ConvertTo-SecureString '<strong-password>' -AsPlainText -Force $newPassword = ConvertTo-SecureString '<strong-password>' -AsPlainText -Force Set-EntraSignedInUserPassword -CurrentPassword $currentPassword -NewPassword $newPassword이 명령을 사용하면 사용자가 관리자 권한 없이 자신의 암호를 변경할 수 있습니다.
사용자의 사진을 업로드하거나 가져오기
사용자의 사진을 업로드합니다.
Connect-Entra -Scopes 'User.ReadWrite.All' Set-EntraUserThumbnailPhoto -UserId 'SawyerM@contoso.com' -FilePath 'D:\UserThumbnailPhoto.jpg'다음은 UserId 매개 변수로 지정된 사용자의 썸네일 사진을 FilePath 매개 변수로 지정된 이미지로 설정하는 예제입니다.
사용자의 사진을 검색합니다.
Connect-Entra -Scopes 'ProfilePhoto.Read.All' Get-EntraUserThumbnailPhoto -UserId 'SawyerM@contoso.com'이 예제에서는 매개 변수 값을
UserId통해 지정된 사용자의 썸네일 사진을 검색하는 방법을 보여 줍니다.
조직에서 사용자에게 관리 역할 부여
조직에서 사용자에게 관리 역할을 부여하면 특정 작업을 수행하고 리소스를 관리할 수 있습니다. 그룹 관리자, 사용자 관리자 또는 기타 사용자 지정 역할과 같은 역할에 사용자를 할당할 수 있습니다.
Microsoft Entra PowerShell을 사용하여 사용자에게 역할을 할당하는 방법을 알아보려면 사용자에게 역할 할당을 참조하세요.
사용자 검색
, , 등의 다양한 특성을 displayNamemailNicknameuserPrincipalNamedepartment사용하여 조직에서 사용자를 검색할 수 있습니다.jobTitle 다음 예제에서는 userPrincipalName를 사용해 사용자를 검색하는 방법을 보여 줍니다.
Connect-Entra -Scopes 'User.Read.All'
Get-EntraUser -Filter "userPrincipalName eq 'SawyerM@contoso.com'"
출력은 검색을 기반으로 사용자 세부 정보를 표시합니다 userPrincipalName .
DisplayName Id Mail UserPrincipalName
----------- -- ---- -----------------
Sawyer Miller aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb SawyerM@contoso.com SawyerM@contoso.com
특정 기준에 따라 사용자 감사
로그인 활동 및 그룹 멤버 자격과 같은 특정 기준에 따라 사용자를 감사할 수 있습니다. 이 기능은 사용자 활동을 추적하고 리소스에 대한 액세스를 관리하는 데 도움이 됩니다.
사용자의 로그인 활동 검색
다음 예제에서는 특정 사용자의 로그인 활동을 검색하는 방법을 보여줍니다.
Connect-Entra -Scopes 'User.Read.All','AuditLog.Read.All'
Get-EntraUser -UserId 'SawyerM@contoso.com' -Property 'SignInActivity' |
Select-Object -Property Id, DisplayName, UserPrincipalName -ExpandProperty 'SignInActivity'
출력에는 사용자의 로그인 활동이 표시됩니다.
lastNonInteractiveSignInRequestId : bbbbbbbb-1111-2222-3333-aaaaaaaaaaaa
lastSignInRequestId : cccccccc-2222-3333-4444-dddddddddddd
lastSuccessfulSignInDateTime : 9/9/2024 1:12:13 PM
lastNonInteractiveSignInDateTime : 9/9/2024 1:12:13 PM
lastSuccessfulSignInRequestId : bbbbbbbb-1111-2222-3333-aaaaaaaaaaaa
lastSignInDateTime : 9/7/2024 9:15:41 AM
id : aaaaaaaa-bbbb-cccc-1111-222222222222
displayName : Sawyer Miller
userPrincipalName : SawyerM@contoso.com
모든 사용자의 로그인 활동 다운로드
다음 예제에서는 라이선스가 부여된 모든 사용자 계정과 마지막으로 성공한 로그인 활동을 검색합니다. 추가 분석을 위해 데이터를 CSV 파일로 내보냅니다.
# Connect to Microsoft Entra PowerShell
Connect-Entra -Scopes 'User.Read.All','AuditLog.Read.All','Directory.Read.All'
try {
Get-EntraUser -All -Property Id, UserPrincipalName, DisplayName, SignInActivity -ErrorAction Stop |
Select-Object `
Id, `
UserPrincipalName, `
DisplayName, `
@{ Name = 'LastSignInDateTime'; Expression = { $_.SignInActivity.LastSignInDateTime } }, `
@{ Name = 'LastSuccessfulSignInDateTime'; Expression = { $_.SignInActivity.LastSuccessfulSignInDateTime } } |
Export-Csv -Path 'C:\temp\lastSignIns.csv' -NoTypeInformation -Encoding UTF8 -ErrorAction Stop
Write-Host "Sign-in activity exported successfully to lastSignIns.csv"
}
catch {
Write-Error "Failed to retrieve or export data: $_"
}
이 예제에서는 조직의 모든 사용자에 대한 마지막 로그인 날짜와 마지막으로 성공한 로그인 날짜를 모두 검색합니다. 그런 다음 데이터가 C:\temp 디렉터리의 lastSignIns.csv라는 이름의 CSV 파일로 내보내집니다.
사용자의 그룹 멤버 자격 나열
다음 예제에서는 사용자가 구성원인 그룹을 나열합니다.
Connect-Entra -Scopes 'User.Read'
Get-EntraUserMembership -UserId 'SawyerM@contoso.com' |
Select-Object Id, displayName, createdDateTime, '@odata.type' |
Format-Table -AutoSize
출력은 사용자의 멤버 자격을 보여 줍니다.
Id displayName createdDateTime @odata.type
-- ----------- --------------- -----------
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Contoso 2024-10-06T08:49:16Z #microsoft.graph.group
22cc22cc-dd33-ee44-ff55-66aa66aa66aa Contoso marketing 2024-10-07T01:17:28Z #microsoft.graph.group
55ff55ff-aa66-bb77-cc88-99dd99dd99dd Pacific Admin Unit #microsoft.graph.administrativeUnit
다음 명령을 사용하여 사용자가 속한 엔터티를 나열합니다.
- Get-EntraUserAdministrativeUnit - 사용자가 속한 관리 단위 목록을 검색합니다.
- Get-EntraUserGroup - 사용자가 속한 그룹 목록을 검색합니다.
- Get-EntraUserRole - 사용자에게 할당된 디렉터리 역할 목록을 검색합니다.
사용자의 관리자 가져오기, 직접 보고서 및 사용자에게 관리자 할당
사용자의 관리자를 가져옵니다.
Connect-Entra -Scopes 'User.Read.All' Get-EntraUserManager -UserId 'SawyerM@contoso.com' | Select-Object Id, displayName, userPrincipalName, createdDateTime, accountEnabled, userType | Format-Table -AutoSize출력에는 사용자의 관리자가 표시됩니다.
id displayName userPrincipalName createdDateTime accountEnabled userType -- ----------- ----------------- --------------- -------------- -------- 11bb11bb-cc22-dd33-ee44-55ff55ff55ff Patti Fernandez PattiF@Contoso.com 10/7/2024 12:32:01 AM True Member특정 사용자에게 보고하는 사용자를 나열합니다.
Connect-Entra -Scopes 'User.Read','User.Read.All' Get-EntraUserDirectReport -UserId 'SawyerM@contoso.com' | Select-Object Id, displayName, userPrincipalName, createdDateTime, accountEnabled, userType | Format-Table -AutoSize출력에는 사용자의 직접 보고서가 표시됩니다.
id displayName userPrincipalName createdDateTime accountEnabled userType -- ----------- ----------------- --------------- -------------- -------- bbbbbbbb-1111-2222-3333-cccccccccccc Christie Cline ChristieC@Contoso.com 10/7/2024 12:32:25 AM True Member aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Isaiah Langer IsaiahL@Contoso.com 10/7/2024 12:33:16 AM True Member사용자에게 관리자를 할당합니다.
Connect-Entra -Scopes 'User.ReadWrite.All' Set-EntraUserManager -UserId 'SawyerM@contoso.com' -ManagerId 'AdeleV@contoso.com'-
-UserId- Microsoft Entra ID 사용자의 ID(UserPrincipalName 또는 User ObjectId)를 지정합니다. -
-ManagerId- 관리자로 할당할 Microsoft Entra ID 개체의 ID를 UserPrincipalName 또는 User ObjectId)로 지정합니다.
-
관리자가 없는 사용자 나열
이 예제에서는 관리자가 없는 사용자를 나열하여 정리를 위해 분리된 계정, 서비스 계정 또는 잘못 구성된 프로필을 식별하는 데 도움을 줍니다.
Connect-Entra -Scopes 'User.Read.All'
$allUsers = Get-EntraUser -All
$usersWithoutManagers = foreach ($user in $allUsers) {
$manager = Get-EntraUserManager -UserId $user.Id -ErrorAction SilentlyContinue
if (-not $manager) {
[PSCustomObject]@{
Id = $user.Id
DisplayName = $user.DisplayName
UserPrincipalName = $user.UserPrincipalName
UserType = $user.userType
AccountEnabled = $user.accountEnabled
CreatedDateTime = $user.createdDateTime
}
}
}
$usersWithoutManagers | Format-Table Id, DisplayName, UserPrincipalName, CreatedDateTime, UserType, AccountEnabled -AutoSize
출력에는 관리자가 없는 사용자가 나열됩니다.
Id DisplayName UserPrincipalName CreatedDateTime UserType AccountEnabled
-- ----------- ----------------- --------------- -------- --------------
cccccccc-2222-3333-4444-dddddddddddd New User NewUser@tenant.com 10/7/2024 2:24:26 PM Member True
bbbbbbbb-1111-2222-3333-cccccccccccc Sawyer Miller SawyerM@contoso.com 10/7/2024 12:33:36 AM Member True
비활성화된 사용자 나열
다음 예제에서는 비활성화된 계정 목록을 생성합니다.
Connect-Entra -Scopes 'User.ReadWrite.All'
Get-EntraUser -Filter "accountEnabled eq false" | Select-Object DisplayName, Id, Mail, UserPrincipalName
출력에는 비활성화된 사용자가 나열됩니다.
DisplayName Id Mail userPrincipalName
----------- -- ---- -----------------
Sawyer Miller hhhhhhhh-7777-8888-9999-iiiiiiiiiiii SawyerM@contoso.com
Kez Michael eeeeeeee-4444-5555-6666-ffffffffffff KezM@contoso.com