1.リモート接続

(1) サーバ側での準備(サーバ)

管理者にてログインし、「Windows PowerShell」から以下のコマンドを実行します。
Enable-PSRemoting

(2)コマンド実行(クライアント)

「Windows PowerShell」から以下のコマンドを実行します。
Enter-PSSession リモートコンピュータ名
→サーバ内でコマンドが実行できることを確認します(dir・・・等)

終了時は以下のコマンドを実行します。
Exit-PSSession(もしくはExit)


2.ActiveDirectoryへの接続


(1)初期構成

「Windows PowerShell」から以下のコマンドを実行します。
Set-ExecutionPolicy RemoteSigned

「サーバーマネージャー」により、以下の機能を追加します。
リモートサーバー管理ツール>役割管理ツール>
AD DS および AD LDS ツール>Windows PowerShell 用 Active Directory モジュール 

「Windows PowerShell」から以下のコマンドを実行します。
Import-Module ActiveDirectory

(2) コマンドを実行します。

パスワードの有効期限を過ぎたユーザを検索する
Search-ADAccount –PasswordExpired -UsersOnly 

パスワードが無期限のユーザを検索する
Search-ADAccount -PasswordNeverExpires

3.ExchangeServer2010への接続


(1)初期構成(クライアント側)

「Windows PowerShell」から以下のコマンドを実行します。
Set-ExecutionPolicy RemoteSigned
※コマンドの実行に失敗したらPowerShellを起動する際に右クリックし、管理者権限で起動する。

(2)サーバ側での権限付与(ExchangeServer側)

Administratorでログオンし、「Exchange Management Shell」から以下のコマンドを実行します。
Set-User <権限を付与したいユーザーアカウント> -RemotePowerShellEnabled $True

(3)コマンド実行(クライアント側)

「Windows PowerShell」から以下のコマンドを実行します。
$UserCredential = Get-Credential
パスワード入力画面が表示されますので、上記のユーザ名とパスワードを入力します。
なお、ユーザ名は以下の形式で入力します。
user01@ドメイン名(もしくはドメイン名\user01)

続いて以下のコマンドを入力します。(改行を含まず1行で入力してください)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange
-ConnectionUri http://ex-hubcas01.contoso.com/PowerShell/ -Authentication Kerberos
-Credential $UserCredential

続いて以下のコマンドでExchangeServerに接続します。
Import-PSSession $Session

接続が完了したら、Exchange管理シェルで実行するコマンドを入力してみます。
Get-Mailbox
最終更新:2011年10月27日 00:53