はじめに
ひょんなことからMac
でPowerShell
を使ってOffice365
の操作を試みることがあったのでメモ
過去の記事を探ったところ、できなさそうな雰囲気はある
-
MacにPowerShellをインストールするが・・・
-
ログインはできるようだが、その後には作業ができなかった。
との記載有り
-
-
MacでPowerShell
- コメントに
ちなみにOffice365へのPowerShell(Get-MsolUserとか)はまだ、使えないようです。Install-Module -Name AzureADがエラーになりました(´;ω;`)
との記載有り
- コメントに
導入編
公式ドキュメントmacOS への PowerShell Core のインストールを参考に、brew
でPowerSHell
をインストールする
$ brew cask install powershell
インストール後、pwsh
コマンドでPowerShell
を起動できるので、公式ドキュメントOffice 365 PowerShell への接続の手順 1: 必要なソフトウェアをインストールするを参考に各種モジュールをインストールする。
$ pwsh
PS /Users/UserName>
PS /Users/UserName> Install-Module -Name AzureAD
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure
you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
手順 2: Office 365 サブスクリプション用の Azure AD に接続するに従い、Azure AD
に接続を試みる
PS /Users/UserName> Connect-AzureAD
Connect-AzureAD: The term 'Connect-AzureAD' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
おや、インストールに失敗する・・・。
どうやら2020/03/11現在、Mac
にインストールできるPowerShell 7.0.0
でもOffice365
の操作はできない模様。
Get-Credential
は実行できるが、それ以外はできない。
はじめにに記載の通り、ログインはできるけどそれ以外の操作はできないんですね・・・。
PS /Users/t.setoguchi> $Cred = Get-Credential
PowerShell credential request
Enter your credentials.
User: admin@sampledayo.com
Password for user admin@sampledayo.com: ************
結論
未だにMac
のPowerShell
ではOffice365
は操作できないということが解った。
今後のMac
版PowerShell
のリリースに期待。