Created
January 23, 2019 01:39
-
-
Save ebibibi/cc5a65b50d066ce4900a028a77248f54 to your computer and use it in GitHub Desktop.
スクリプトにパスワードまで生で記載する形のExchange Onlineへの接続スクリプト(セキュリティには注意)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Exchange OnlineへのPowerShell接続(※多要素認証には非対応) | |
| # | |
| # 1. O365組織の管理者のIDとパスワードを生で記載する | |
| # 2. 管理者として実行したPowerShellに貼り付ける | |
| # 3. 作業する | |
| # 4. 作業が終わったら Remove-Session $Session を実行する | |
| # | |
| # 参考:https://docs.microsoft.com/ja-jp/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps | |
| Set-ExecutionPolicy RemoteSigned | |
| $ID = "xxxxx@xxxxx.onmicrosoft.com" # ID | |
| $PlainPassword = 'xxxxxxx' # Password | |
| #-------------------- | |
| $SecurePassword = ConvertTo-SecureString –String $PlainPassword –AsPlainText -Force | |
| $Credential = New-Object System.Management.Automation.PSCredential($ID, $SecurePassword) | |
| $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection | |
| Import-PSSession $Session -DisableNameChecking | |
| #-------------------- | |
| # 作業終了後 | |
| #-------------------- | |
| Remove-Session $Session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment