호환 모드에서 레거시 스크립트 실행

이 문서에서는 호환성 모드를 사용하여 Microsoft Entra PowerShell에서 레거시 Azure AD PowerShell 스크립트를 실행하여 최소한의 변경으로 원활한 스크립트 마이그레이션을 사용하도록 설정하는 방법을 알아봅니다. 이 프로세스를 사용하면 기존 자동화 워크플로를 유지하면서 새 모듈로 원활하게 전환하여 업데이트된 도구의 지속적인 효율성과 규정 준수를 보장할 수 있습니다.

Microsoft Entra PowerShell은 98%가 넘는 Azure AD PowerShell 모듈과의 호환성을 제공합니다. 호환 모드에서는 Enable-EntraAzureADAlias 명령을 사용하여 Microsoft Entra PowerShell에서 최소한의 수정만으로 기존 Azure AD PowerShell 스크립트를 실행할 수 있습니다. Microsoft Entra PowerShell에서 Azure AD PowerShell 및 MSOnline cmdlet에 해당하는 명령을 찾으려면 Azure AD PowerShell에서 Microsoft Entra PowerShell로의 cmdlet 매핑을 사용하세요.

Enable-EntraAzureADAlias 호환성 모드 사용

cmdlet은 Enable-EntraAzureADAlias 별칭을 통해 호환성 모드를 사용하도록 설정합니다. 기본적으로 Enable-EntraAzureADAlias 현재 Microsoft Entra PowerShell 세션에 대한 호환성 별칭만 사용하도록 설정합니다. 자세한 내용은 Enable-EntraAzureADAlias 참조 설명서를 참조하세요.

기존 AzureAD PowerShell 스크립트와 함께 Microsoft Entra PowerShell을 사용하려면 Connect-AzureAD 명령을 제공된 세 줄로 바꾸세요. 이 세 줄은 마이그레이션된 AzureAD PowerShell 스크립트의 시작입니다.

Import-Module -Name Microsoft.Entra.Applications
Connect-Entra -Scopes 'Application.Read.All' #Replaces Connect-AzureAD for auth
Enable-EntraAzureADAlias #enable aliasing
Get-AzureADApplication -Top 2

예시

이 예제에서는 Microsoft Entra PowerShell을 사용하여 만료되는 비밀이 있는 앱을 내보내는 스크립트를 실행합니다. 이 예제에서는 Microsoft Entra PowerShell 모듈이 이미 설치되어 있다고 가정합니다.

다음 예제 스크립트는 원래 AzureAD PowerShell 스크립트입니다.

Connect-AzureAD
$applications = Get-AzureADApplication -All $true
$Logs = @()
Write-Host "I would like to see the Applications with the Secrets and Certificates that expire in the next X amount of Days? <<Replace X with the number of days. The answer should be ONLY in Numbers>>" -ForegroundColor Green
$Days = Read-Host

Write-Host "Would you like to see Applications with already expired secrets or certificates as well? <<Answer with [Yes] [No]>>" -ForegroundColor Green
$alreadyExpired = Read-Host

$now = Get-Date

foreach ($app in $applications) {
    $appName = $app.DisplayName
    $appID = $app.objectid
    $applID = $app.AppId
    $appCreds = Get-AzureADApplication -ObjectId $appID | Select-Object -Property PasswordCredentials, KeyCredentials
    $secret = $appCreds.PasswordCredentials
    $cert = $appCreds.KeyCredentials

참고: 이 코드 조각은 가독성을 위해 단축됩니다. 자세한 내용은 전체 샘플을 참조하세요.

Microsoft Entra PowerShell 모듈에서 스크립트를 사용하려면 cmdlet을 Connect-AzureAD 코드 조각에 제공된 세 줄로 바꿉다. 전체 스크립트를 다시 작성할 필요는 없습니다.

다음 스크립트는 마이그레이션된 스크립트입니다.

Import-Module -Name Microsoft.Entra.Users
Connect-Entra #Replaces Connect-AzureAD for auth
Enable-EntraAzureADAlias #Activate aliasing

$applications = Get-AzureADApplication -All $true
$logs = @()
Write-Host "I would like to see the Applications with the Secrets and Certificates that expire in the next X amount of Days? <<Replace X with the number of days. The answer should be ONLY in Numbers>>" -ForegroundColor Green
$days = Read-Host
Write-Host "Would you like to see Applications with already expired secrets or certificates as well? <<Answer with [Yes] [No]>>" -ForegroundColor Green
$alreadyExpired = Read-Host
$now = Get-Date
foreach ($app in $applications) {
    $appName = $app.DisplayName
    $appID = $app.Objectid
    $applID = $app.AppId
    $appCreds = Get-AzureADApplication -ObjectId $appID | Select-Object -Property PasswordCredentials, KeyCredentials
    $secret = $appCreds.PasswordCredentials
    $cert = $appCreds.KeyCredentials

참고: 이 코드 조각은 가독성을 위해 단축됩니다. 자세한 내용은 수정된 전체 샘플을 참조하세요.

Test-EntraScript 명령과의 호환성 테스트

Test-EntraScript cmdlet은 Azure AD PowerShell 명령이 있는 스크립트가 Microsoft Entra PowerShell 모듈에서 작동하는지 확인합니다. 호환성 문제가 있는 경우 줄 번호, 문제 유형, 호환되지 않는 명령 및 특정 코드 조각을 포함하여 해당 항목이 나열됩니다.

알려진 문제

Azure AD PowerShell 모듈에서 Microsoft Entra PowerShell로 마이그레이션하는 경우 몇 가지 알려진 문제가 발생할 수 있습니다.

  • 매개 변수 -Filter 가 제대로 작동하지 않을 수 있습니다.
  • 매개 변수 -SearchString 가 제대로 작동하지 않을 수 있습니다.
  • 출력 개체는 AzureAD 출력 개체와 약간 다를 수 있습니다.