처음부터 Powershell을 통해 Office365 Exchange에 로그인

처음부터 Powershell을 통해 Office365 Exchange에 로그인

나는 위에 아무 것도 설치되지 않은 새로 설치된 일반 powershell에서 그렇게하려고 시도했지만 공식적인 방법은 단순히 패키지 관리자 누락, 존재하지 않는 패키지 공급자, 명령 누락 및 기타 유사한 메시지에 대한 오류로 이어지는 것 같습니다. . (Microsoft 사이트에는 Install-Module ExchangeOnlineManagement필요한 모든 것이 간단하게 명시되어 있습니다.)

간단히 말해서, 이를 수행하는 실제 방법은 최종적으로 명령을 실행할 수 있도록 Powershell에 상호 의존적인 프로그램을 완전히 설치하는 것입니다 Install-Module ExchangeOnlineManagement. 이에 대한 지침은 Microsoft 사이트 전체에 분산되어 있으며 이를 수행하려면 12개 정도의 다양한 오류를 디버깅해야 하며 이는 시간이 많이 걸리는 프로세스입니다.

은 무엇입니까?완벽한일반 Powershell에서 Windows 시스템의 Office-365 Exchange Online에 연결할 수 있는 Powershell로 이동하는 단계는 무엇입니까?


답변1

사용 가능한 모듈과 cmdlet은 PowerShell 버전에 따라 다릅니다. 실행 중인 WinOS나 실행 중인 PowerShell 버전을 말하는 것이 아닙니다.

Windows에 PowerShell을 설치할 이유가 없습니다..기본적으로 거기에 있습니다, OS의 일부이기 때문입니다. 시작 메뉴를 사용하여 콘솔 호스트 또는 ISE(통합 스크립팅 환경)를 실행하면 됩니다. 그러나 레거시 Windows를 사용하는 경우 Windows Powershell 버전을 최신 버전으로 업그레이드하지 않으면 레거시 PowerShell을 사용하게 됩니다.

PowerShell 버전 간의 차이점

따라서 powershell.exe 또는 powershell_ise.exe가 실행 파일입니다.

설치를 위한 유일한 다른 옵션은 크로스 플랫폼 PowerShell Core를 설치하는 것입니다.(당신이 추구하는 것에 필수는 아니지만 선택 사항이며 동시에 사용할 수도 있습니다.)

PSCore를 설치해도 Windows PowerShell이 ​​업그레이드되거나 대체되지 않습니다., 이는 OS의 일부입니다. 나란히 서있는 모델인데..

pwsh.exe

... PSCore용 실행 파일입니다.

그런 다음 PowerShell 도움말 파일을 업데이트합니다.

Update-Help -Force -ErrorAction SilentlyContinue

..., 그런 다음 다음을 사용합니다.

Find-Module

... 명령만으로 패키지 관리 또는 특정 모듈을 업데이트할 수 있습니다.

Find-Module -Name 'ExchangeOnlineManagement' | 
Install-Module -Force

... 아니면 그냥 실행해 보세요...

Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber

... 수동으로 패키지 관리자를 업데이트합니다.

마지막으로 필요하거나 원하는 모듈을 설치하고 PowerShell 프로필을 사용하여 자동으로 로드되도록 합니다. 프로필에 이...

# Required for use with web SSL sites
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::
SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

... 배포되는 모든 스크립트뿐만 아니라 거기에도 있어야 합니다.

O365/M365에서 무엇이든 사용하려면 먼저 서비스에 로그인해야 합니다.

단일 PowerShell 창에서 모든 Microsoft 365 서비스에 연결

https://docs.microsoft.com/en-us/microsoft-365/enterprise/connect-to-all-microsoft-365-services-in-a-single-windows-powershell-window?view=o365-worldwide

$orgName="<for example, litwareinc for litwareinc.onmicrosoft.com>"
$acctName="<UPN of the account, such as [email protected]>"
$credential = Get-Credential -UserName $acctName -Message "Type the account's password."

#Azure Active Directory
Connect-AzureAD -Credential $credential

#SharePoint Online
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -credential $credential

#Skype for Business Online
Import-Module MicrosoftTeams
Connect-MicrosoftTeams -Credential $credential

#Exchange Online
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -ShowProgress $true

#Security & Compliance Center
Connect-IPPSSession -UserPrincipalName $acctName

#Teams
Import-Module MicrosoftTeams
Connect-MicrosoftTeams -Credential $credential

답변2

몇 번의 시행착오를 거쳐 저는 이렇게 할 수 있었습니다. (비록 그렇게 하는 것이 얼마나 안전하고 올바른지는 확실하지 않지만, 적절한 지식이 단편화되어 있기 때문에 중복되는 단계가 있는지는 확실하지 않지만):

시작한다:

첫 번째는 으로 powershell 버전을 확인하는 것입니다 Get-Host. 버전은 최소한 5.0. 그렇지 않은 경우 .msu해당 설치 프로그램을 다운로드하고 실행하여 최신 패키지를 설치하십시오 . 그런 다음 다음을 실행하십시오.

# Powershell defaults to TLS1.1, which was deprecated. 
# Thus by default its package management functions ship broken. Force it to use TLS1.2 by setting:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Find-PackageProvider -Name "NuGet" -AllVersions
# Select the latest version
Install-PackageProvider -Name "NuGet" -RequiredVersion "2.8.5.208" -Force
# Check with 
Get-PackageProvider
# Register the repo 
Register-PSRepository -Default -Verbose
# Check with 
Get-PSRepository
# Check which version pops up in the error when running 
Install-Module PowerShellGet
# Then run the command to update PowerShellGet (replace the version number with the latest from the previous command): 
Install-Module PowerShellGet -RequiredVersion 2.2.5
# Finally: 
Install-Module ExchangeOnlineManagement
# Next, enable running scripts with: 
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# Import
Import-Module ExchangeOnlineManagement

답변3

Windows 서버/클라이언트 버전이 다음인지 확인하세요.지원되는 운영 체제, 귀하의 서버/클라이언트는 다음을 충족합니다.EXO V2 모듈의 전제 조건(EXO V2 모듈에 지원되는 운영 체제):

여기에 이미지 설명을 입력하세요

그런 다음 EXO V2 모듈을 설치합니다.

  1. 설치 또는 업데이트PowerShellGet 모듈(TLS 1.2를 사용하고 있는지 확인하세요)

  2. 다음 명령을 사용하여 EXO V2 모듈을 설치합니다.Install-Module -Name ExchangeOnlineManagement

Office 365 개체를 관리하기 위해 PowerShell에서 EXO V2 모듈을 사용하는 것을 제외하고 다음을 사용할 수도 있습니다.Exchange Online PowerShell에 연결하기 위한 기본 인증(그 전에는전제 조건주목해야 합니다.)

관련 정보