온-프레미스 사서함에 기본 제공 보안 추가 기능을 사용하는 경우 이 문서의 스크립트를 사용하여 관리하는 여러 조직에서 구성 설정을 확인(수정 및 구성)할 수 있습니다.
온-프레미스 사서함에 대한 기본 제공 보안 추가 기능을 사용하여 여러 조직에서 스크립트 또는 cmdlet을 실행하려면
아직 설치하지 않은 경우 Exchange Online PowerShell 모듈을 설치합니다.
Microsoft Excel 또는 다른 스프레드시트 앱을 사용하여 다음 세부 정보가 포함된 .csv 파일을 만듭니다.
-
UserName 열: 클라우드에 연결하는 데 사용하는 계정입니다(예:
admin@contoso.onmicrosoft.com). -
Cmdlet 열: 실행할 cmdlet 또는 명령(예:
Get-AcceptedDomain또는Get-AcceptedDomain | Format-Table Name)입니다.
.csv 파일은 다음과 같습니다.
UserName,Cmdlet admin@contoso.onmicrosoft.com,Get-AcceptedDomain | Format-Table Name admin@fabrikam.onmicrosoft.com,Get-AcceptedDomain | Format-Table Name-
UserName 열: 클라우드에 연결하는 데 사용하는 계정입니다(예:
.csv 파일을 찾기 쉬운 위치에 저장합니다(예: c:\scripts\inputfile.csv).
RunCmdletOnMultipleTenants.ps1 스크립트를 메모장 또는 다른 텍스트 편집기에 복사한 다음 찾기 쉬운 위치(예: c:\scripts)에 파일을 저장합니다.
다음 구문을 사용하여 스크립트를 실행합니다.
& "<file path>\RunCmdletOnMultipleTenants.ps1" "<file path>\inputfile.csv"다음은 예입니다.
& "c:\scripts\RunCmdletOnMultipleTenants.ps1" "c:\scripts\inputfile.csv"스크립트는 로그인하여 각 클라우드 organization 실행됩니다.
RunCmdletOnMultipleTenants.ps1
# This script runs Windows PowerShell cmdlets on multiple tenants.
#
# Usage: RunCmdletOnMultipleTenants.ps1 inputfile.csv
#
# .csv input file sample:
#
# UserName,Cmdlet
# admin@contoso.onmicrosoft.com,Get-AcceptedDomain | FT Name
# admin@fabrikam.onmicrosoft.com,Get-AcceptedDomain | FT Name
# Get the .csv file name as an argument to this script.
$FilePath = $args[0]
# Import the UserName and Cmdlet values from the .csv file.
$CompanyList = Import-CSV $FilePath
# Load the Exchange Online PowerShell module
Import-Module ExchangeOnlineManagement
# Loop through each entry from the .csv file.
ForEach ($Company in $CompanyList) {
# Get the current entry's UserName.
$UserName = $Company.UserName
# Get the current entry's Cmdlet.
$Cmdlet = $Company.Cmdlet
# Connect to Exchange Online PowerShell by using the current entry's UserName. Prompt for the password.
Connect-ExchangeOnline -UserPrincipalName $UserName
# Here's where the script to be run on the tenant goes.
# In this example, the cmdlet in the .csv file runs.
Invoke-Expression $Cmdlet
# End the current PowerShell session.
Disconnect-ExchangeOnline -Confirm:$false
}