PowerShell을 사용하여 Microsoft 365 사용자 계정 차단
이 문서는 Microsoft 365 Enterprise와 Office 365 Enterprise에 모두 적용됩니다.
Microsoft 365 계정에 대한 액세스를 차단하면 모든 사용자가 해당 계정을 사용하여 로그인하고 Microsoft 365 조직의 서비스 및 데이터에 액세스하지 못하게 됩니다. PowerShell을 사용하여 개별 또는 여러 사용자 계정에 대한 액세스를 차단할 수 있습니다.
Graph 모듈용 Azure Active Directory PowerShell 사용하기
개별 사용자 계정에 대한 액세스 차단
다음 구문을 사용하여 개별 사용자 계정을 차단합니다.
Set-AzureADUser -ObjectID <sign-in name of the user account> -AccountEnabled $false
참고
Set-AzureAD cmdlet의 -ObjectID 매개 변수는 계정 로그인 이름(사용자 계정 이름이라고도 함) 또는 계정의 개체 ID를 허용합니다.
이 예제에서는 사용자 계정 fabricec@litwareinc.com 대한 액세스를 차단합니다.
Set-AzureADUser -ObjectID fabricec@litwareinc.com -AccountEnabled $false
사용자 계정을 차단 해제하려면 다음 명령을 실행합니다.
Set-AzureADUser -ObjectID fabricec@litwareinc.com -AccountEnabled $true
사용자의 표시 이름에 따라 사용자 계정 UPN을 표시하려면 다음 명령을 사용합니다.
$userName="<display name>"
Write-Host (Get-AzureADUser | where {$_.DisplayName -eq $userName}).UserPrincipalName
이 예제에서는 사용자 Caleb Sills 에 대한 사용자 계정 UPN을 표시합니다.
$userName="Caleb Sills"
Write-Host (Get-AzureADUser | where {$_.DisplayName -eq $userName}).UserPrincipalName
사용자의 표시 이름에 따라 계정을 차단하려면 다음 명령을 사용합니다.
$userName="<display name>"
Set-AzureADUser -ObjectID (Get-AzureADUser | where {$_.DisplayName -eq $userName}).UserPrincipalName -AccountEnabled $false
사용자 계정의 차단된 상태를 확인하려면 다음 명령을 사용합니다.
Get-AzureADUser -ObjectID <UPN of user account> | Select DisplayName,AccountEnabled
여러 사용자 계정 차단
여러 사용자 계정에 대한 액세스를 차단하려면 다음과 같이 각 줄에 하나의 계정 로그인 이름이 포함된 텍스트 파일을 만듭니다.
akol@contoso.com
tjohnston@contoso.com
kakers@contoso.com
다음 명령에서 예제 텍스트 파일은 C:\My Documents\Accounts.txt. 이 파일 이름을 텍스트 파일의 경로 및 파일 이름으로 바꿉 있습니다.
텍스트 파일에 나열 된 계정에 대 한 액세스를 차단 하려면 다음 명령을 실행 합니다.
Get-Content "C:\My Documents\Accounts.txt" | ForEach {Set-AzureADUser -ObjectID $_ -AccountEnabled $false}
텍스트 파일에 나열된 계정의 차단을 해제하려면 다음 명령을 실행합니다.
Get-Content "C:\My Documents\Accounts.txt" | ForEach {Set-AzureADUser -ObjectID $_ -AccountEnabled $true}
Windows PowerShell용 Microsoft Azure Active Directory 모듈 사용하기
개별 사용자 계정 차단
개별 사용자 계정에 대한 액세스를 차단하려면 다음 구문을 사용합니다.
Set-MsolUser -UserPrincipalName <sign-in name of user account> -BlockCredential $true
참고
PowerShell Core는 이름에 Msol 이 있는 Windows PowerShell 모듈 및 cmdlet에 대한 Microsoft Azure Active Directory 모듈을 지원하지 않습니다. Windows PowerShell 이러한 cmdlet을 실행해야 합니다.
이 예제에서는 사용자 계정 fabricec@ litwareinc.com 대한 액세스를 차단합니다.
Set-MsolUser -UserPrincipalName fabricec@litwareinc.com -BlockCredential $true
사용자 계정 차단 해제 하려면 다음 명령을 실행 합니다.
Set-MsolUser -UserPrincipalName <sign-in name of user account> -BlockCredential $false
사용자 계정의 차단된 상태를 확인하려면 다음 명령을 실행합니다.
Get-MsolUser -UserPrincipalName <sign-in name of user account> | Select DisplayName,BlockCredential
여러 사용자 계정에 대한 액세스 차단
먼저 다음과 같이 각 줄에 하나의 계정이 포함된 텍스트 파일을 만듭니다.
akol@contoso.com
tjohnston@contoso.com
kakers@contoso.com
다음 명령에서 예제 텍스트 파일은 C:\My Documents\Accounts.txt. 이 파일 이름을 텍스트 파일의 경로 및 파일 이름으로 바꿉 있습니다.
텍스트 파일에 나열된 계정에 대한 액세스를 차단하려면 다음 명령을 실행합니다.
Get-Content "C:\My Documents\Accounts.txt" | ForEach { Set-MsolUser -UserPrincipalName $_ -BlockCredential $true }
텍스트 파일에 나열 된 계정 차단 해제 하려면 다음 명령을 실행 합니다.
Get-Content "C:\My Documents\Accounts.txt" | ForEach { Set-MsolUser -UserPrincipalName $_ -BlockCredential $false }