다음을 통해 공유


Microsoft Entra 개인 네트워크 커넥터에 대한 무인 설치 스크립트 만들기

이 문서는 Microsoft Entra 개인 네트워크 커넥터의 무인 설치 및 등록을 가능하게 하는 Windows PowerShell 스크립트를 만드는 데 도움이 됩니다.

무인 설치는 다음과 같은 경우에 유용합니다.

  • 사용자 인터페이스를 사용하도록 설정하지 않은 Windows 서버에 커넥터를 설치하거나 원격 데스크톱을 사용하여 액세스할 수 없습니다.
  • 한 번에 여러 커넥터를 설치하고 등록합니다.
  • 커넥터 설치 및 등록을 다른 절차의 일부분으로 통합합니다.
  • 커넥터 비트를 포함하지만 등록되지 않은 표준 서버 이미지를 만듭니다.

개인 네트워크 커넥터가 작동하려면 Microsoft Entra ID로 등록해야 합니다. 등록은 커넥터를 설치할 때 사용자 인터페이스에서 수행되지만 PowerShell을 사용하여 프로세스를 자동화할 수 있습니다.

무인 설치를 위한 두 단계가 있습니다. 먼저 커넥터를 설치합니다. 둘째, Microsoft Entra ID로 커넥터를 등록합니다.

Important

Microsoft Azure Government 클라우드용 커넥터를 설치하는 경우 필수 조건설치 단계를 검토합니다. Microsoft Azure Government 클라우드에서는 설치를 실행하기 위해 다양한 URL 집합과 추가 매개 변수에 대한 액세스를 사용하도록 설정해야 합니다.

커넥터 설치

등록 없이 커넥터를 설치하려면 다음 단계를 사용합니다.

  1. 명령 프롬프트가 엽니다.

  2. 다음 명령을 실행합니다. /q 플래그는 자동 설치를 의미합니다. 자동 설치는 최종 사용자 사용권 계약에 동의할지 묻는 메시지가 표시되지 않습니다.

    MicrosoftEntraPrivateNetworkConnectorInstaller.exe REGISTERCONNECTOR="false" /q
    

Microsoft Entra ID로 커넥터 등록

커넥터를 등록하는 데 사용할 수 있는 두 가지 방법이 있습니다.

  • Windows PowerShell 자격 증명 개체를 사용하여 커넥터를 등록합니다.
  • 오프라인에서 만든 토큰을 사용하여 커넥터를 등록합니다.

Windows PowerShell 자격 증명 개체를 사용하여 커넥터 등록

  1. 디렉터리에 대한 관리 사용자 이름 및 암호를 포함하는 Windows PowerShell 자격 증명 개체 $cred를 만듭니다. <username>, <password><tenantid>을(를) 바꿔 다음 명령을 실행합니다.

    $User = "<username>"
    $PlainPassword = '<password>'
    $TenantId = '<tenantid>'
    $SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
    $cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $SecurePassword
    
  2. C:\Program Files\Microsoft Entra private network connector(으)로 이동하여 만든 $cred 개체를 사용하여 다음 스크립트를 실행합니다.

    .\RegisterConnector.ps1 -modulePath "C:\Program Files\Microsoft Entra private network connector\Modules\" -moduleName "MicrosoftEntraPrivateNetworkConnectorPSModule" -Authenticationmode Credentials -Usercredentials $cred -Feature ApplicationProxy -TenantId $TenantId
    
  3. 스크립트에는 중요한 자격 증명 정보가 포함되어 있습니다. 스크립트를 안전한 위치에 저장합니다.

오프라인에서 만든 토큰을 사용하여 커넥터 등록

  1. 이 코드 조각 또는 PowerShell cmdlet의 값을 이용하여 AuthenticationContext 클래스를 사용하는 오프라인 토큰을 만듭니다.

    C# 사용:

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using Microsoft.Identity.Client;
    
    class Program
    {
       #region constants
       /// <summary>
       /// The AAD authentication endpoint uri
       /// </summary>
       static readonly string AadAuthenticationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize";
    
       /// <summary>
       /// The application ID of the connector in AAD
       /// </summary>
       static readonly string ConnectorAppId = "55747057-9b5d-4bd4-b387-abf52a8bd489";
    
       /// <summary>
       /// The AppIdUri of the registration service in AAD
       /// </summary>
       static readonly string RegistrationServiceAppIdUri = "https://proxy.cloudwebappproxy.net/registerapp/user_impersonation";
    
       #endregion
    
       #region private members
       private string token;
       private string tenantID;
       #endregion
    
       public void GetAuthenticationToken()
       {
          IPublicClientApplication clientApp = PublicClientApplicationBuilder
             .Create(ConnectorAppId)
             .WithDefaultRedirectUri() // will automatically use the default Uri for native app
             .WithAuthority(AadAuthenticationEndpoint)
             .Build();
    
          AuthenticationResult authResult = null;
    
          IAccount account = null;
    
          IEnumerable<string> scopes = new string[] { RegistrationServiceAppIdUri };
    
          try
          {
          authResult = await clientApp.AcquireTokenSilent(scopes, account).ExecuteAsync();
          }
          catch (MsalUiRequiredException ex)
          {
          authResult = await clientApp.AcquireTokenInteractive(scopes).ExecuteAsync();
          }
    
          if (authResult == null || string.IsNullOrEmpty(authResult.AccessToken) || string.IsNullOrEmpty(authResult.TenantId))
          {
          Trace.TraceError("Authentication result, token or tenant id returned are null");
          throw new InvalidOperationException("Authentication result, token or tenant id returned are null");
          }
    
          token = authResult.AccessToken;
          tenantID = authResult.TenantId;
       }
    }
    

    PowerShell 사용:

    # Load MSAL (Tested with version 4.7.1) 
    
    Add-Type -Path "..\MSAL\Microsoft.Identity.Client.dll"
    
    # The AAD authentication endpoint uri
    
    $authority = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
    
    #The application ID of the connector in AAD
    
    $connectorAppId = "55747057-9b5d-4bd4-b387-abf52a8bd489";
    
    #The AppIdUri of the registration service in AAD
    $registrationServiceAppIdUri = "https://proxy.cloudwebappproxy.net/registerapp/user_impersonation"
    
    # Define the resources and scopes you want to call
    
    $scopes = New-Object System.Collections.ObjectModel.Collection["string"] 
    
    $scopes.Add($registrationServiceAppIdUri)
    
    $app = [Microsoft.Identity.Client.PublicClientApplicationBuilder]::Create($connectorAppId).WithAuthority($authority).WithDefaultRedirectUri().Build()
    
    [Microsoft.Identity.Client.IAccount] $account = $null
    
    # Acquiring the token
    
    $authResult = $null
    
    $authResult = $app.AcquireTokenInteractive($scopes).WithAccount($account).ExecuteAsync().ConfigureAwait($false).GetAwaiter().GetResult()
    
    # Check AuthN result
    If (($authResult) -and ($authResult.AccessToken) -and ($authResult.TenantId)) {
    
       $token = $authResult.AccessToken
       $tenantId = $authResult.TenantId
    
       Write-Output "Success: Authentication result returned."
    }
    Else {
    
       Write-Output "Error: Authentication result, token or tenant id returned with null."
    
    } 
    
  2. 토큰이 있으면 토큰을 사용하여 SecureString을(를) 만듭니다.

    $SecureToken = $Token | ConvertTo-SecureString -AsPlainText -Force
    
  3. 다음 Windows PowerShell 명령을 실행하여 <tenant GUID>를 디렉터리 ID로 바꿉니다.

    .\RegisterConnector.ps1 -modulePath "C:\Program Files\Microsoft Entra private network connector\Modules\" -moduleName "MicrosoftEntraPrivateNetworkConnectorPSModule" -Authenticationmode Token -Token $SecureToken -TenantId <tenant GUID> -Feature ApplicationProxy
    
  4. 중요한 자격 증명 정보를 포함하기 때문에 스크립트 또는 코드를 안전한 위치에 저장합니다.

다음 단계