Office365オレンジバージョンの頃(Exchange Server 2010)のPowerShellコマンド整理です。ブルーバージョン(Exchange Server 2013)になって、機能も大幅に増加したりしているため、若干違っているかもしれないけれど、整理です。
※サービスリクエストに質問した内容を忘れずにまとめた備忘録となります。
通常のWindows が持っているコマンドをすべて利用できるわけではございません。
※Office365用のPowerShellは下記URLからインストールしましょう。
http://onlinehelp.microsoft.com/ja-jp/office365-enterprises/hh124998.aspx
▼コマンドプロンプトでProxy設定(Proxyがある場合。1回のみ)
netsh winhttp import proxy source=ie
▼PowerShell起動:
Microsoft Online Servicesモジュールから、もしくは下記コマンドプロンプトから
powershell.exe -NoExit -Command “Import-Module MSOnline”
▼ログイン
$LiveCred = Get-Credential
▼Office365接続の確認
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
〔参考URL〕http://help.outlook.com/ja-jp/140/cc952755.aspx
▼Office365で利用できるコマンドをインポート
Import-PSSession $Session
▼セッションを終了するコマンド
Remove-PSSession $Session
———準備終了———–
▼メールアドレスが非表示なのか表示なのかを確認
Get-MailBox -Identity contoso@contoso.com | Select PrimarySmtpAddress,HiddenFromAddressListsEnabled
▼配布グループを非表示にする
Set-DistributionGroup -Identity target@domain.com -HiddenFromAddressListsEnabled $True
▽配布グループを表示にする
Set-DistributionGroup -Identity target@domain.com -HiddenFromAddressListsEnabled $False
▼メールアドレスに紐づけられているユーザ情報を取得
Get-mailboxPermission -identity target@domain.com | fl > c:tmptarget.txt
▼ターゲットメールに対しフル権限付与(user or 配布グループ)
Add-MailboxPermission target@domain.com -User kansa@domain.com -AccessRights FullAccess
※権限付与を剥奪する場合は、同一コマンドを入力
▽読み取り専用
Add-MailBoxPermission -identity target@domain.com -User kansa@domain.com -AccessRights ReadPermission
※AccessRights パラメーター
FullAccess
SendAs
ExternalAccount
DeleteItem
ReadPermission
ChangePermission
ChangeOwner
▼メールを送信可能にする権限
Add-RecipientPermission target@domain.com -Trustee kansa@domain.com -AccessRights SendAs
▼配布グループ(group7@domain.com)のユーザ登録状況を確認
Get-distributiongroupmember -identity Group7|select displayname, primarySmtpAddress| Export-Csv -encoding UTF8 c:tmpuser.csv
▼登録されているユーザーを確認するコマンド
Get-mailbox -RecipientTypeDetails UserMailbox |select DisplayName,PrimarySMTPAddress | Export-Csv -encoding UTF8 c:tmpuser.csv
▽登録されているアイテムすべてを確認するコマンド
Get-mailbox |select DisplayName,PrimarySMTPAddress,RecipientTypeDetails | Export-Csv -encoding UTF8 c:tmpuser.csv
▼アイテム保持ポリシーを適用する。
<1名に設定する場合>
※ユーザー [target@domain.com] にアイテム保持ポリシー [Policy1] を割り当てる場合、下記のコマンドを実行します。
Set-Mailbox -Identity target@domain.com -RetentionPolicy Policy1
<全ユーザーを対象とする場合>
※全ユーザーにアイテム保持ポリシー [Policy1] を割り当てる場合、下記のコマンドを実行します。
$identities = Get-Mailbox | Select Identity
$identities | %{Set-Mailbox -Identity $_.Identity -RetentionPolicy Policy1}
★管理フォルダーアシスタントの実行
管理フォルダーアシスタントは、10MB 以上のメールボックスのサイズを持つユーザーを対象に 7 日に一度ずつ実行される
が、PowerShell の下記のコマンドで強制的に実行することが可能。
<1名に設定する場合>
Start-ManagedFolderAssistant -Identity target@domain.com
<全ユーザーを対象する場合>
$identities = Get-Mailbox | Select Identity
$identities | %{Start-ManagedFolderAssistant -Identity $_.Identity}