Unregister-PSSessionConfiguration
登録されたセッション構成をコンピューターから削除します。
構文
Unregister-PSSessionConfiguration
[-Name] <String>
[-Force]
[-NoServiceRestart]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
説明
このコマンドレットは、Windows プラットフォームでのみ使用できます。
このコマンドレットは Unregister-PSSessionConfiguration
、登録済みのセッション構成をコンピューターから削除します。 このコマンドレットは、システム管理者がユーザーのカスタマイズされたセッション構成を管理できるように設計されています。
変更を有効にするには、 Unregister-PSSessionConfiguration
WinRM サービスを再起動します。 再起動を防ぐには、NoServiceRestart パラメーターを指定します。
既定 Microsoft.PowerShell
の構成または Microsoft.PowerShell32
セッション構成を誤って削除した場合は、コマンドレットを Enable-PSRemoting
使用して復元します。 詳細については、「about_Session_Configurations」を参照してください。
例
例 1: セッション構成を削除する
次の使用例は、 MaintenanceShell
コンピューターからセッション構成を削除します。
Unregister-PSSessionConfiguration -Name "MaintenanceShell"
例 2: セッション構成を削除し、WinRM サービスを再起動する
この例では、構成を MaintenanceShell
削除し、WinRM サービスを再起動します。 Force パラメーターは、プロンプトを表示せずに WinRM サービスを再起動するすべてのユーザー メッセージを抑制します。
Unregister-PSSessionConfiguration -Name MaintenanceShell -Force
例 3: すべてのセッション構成を削除する
この例では、コンピューター上のすべてのセッション構成を削除する 2 つの方法を示します。 どちらのコマンドも同じ効果を持ち、同じ意味で使用できます。
Unregister-PSSessionConfiguration -Name *
Get-PSSessionConfiguration -Name * | Unregister-PSSessionConfiguration
例 4: 再起動なしで登録を解除する
この例では、NoServiceRestart パラメーターを使用して、コンピューター上のセッションを中断するサービスの再起動を防ぐ効果を示します。
PS> Unregister-PSSessionConfiguration -Name "MaintenanceShell" -NoServiceRestart
PS> Get-PSSessionConfiguration -Name "MaintenanceShell"
Get-PSSessionConfiguration -Name MaintenanceShell : No Session Configuration matches criteria "MaintenanceShell".
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
PS> New-PSSession -ConfigurationName "MaintenanceShell"
Id Name ComputerName State Configuration Availability
-- ---- ------------ ----- ------------- ------------
1 Session1 localhost Opened MaintenanceShell Available
PS> Restart-Service winrm
PS> New-PSSession -ConfigurationName MaintenanceShell
[localhost] Connecting to remote server failed with the following error message :
The WS-Management service cannot process the request.
The resource URI (http://schemas.microsoft.com/powershell/MaintenanceShell) was not found in the WS-Management catalog.
The catalog contains the metadata that describes resources, or logical endpoints.
For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
セッション Unregister-PSSessionConfiguration
構成を MaintenanceShell
削除します。
ただし、コマンドは NoServiceRestart パラメーターを使用するため、WinRM サービスは再起動されず、変更はまだ完全には有効ではありません。
次に、セッションを Get-PSSessionConfiguration
取得 MaintenanceShell
しようとします。 セッションは WS-Management リソース テーブルから削除されているため、 Get-PSSessionConfiguration
返すことができません。
このコマンドレットは New-PSSession
、構成を使用してセッションを MaintenanceShell
作成します。 このコマンドは成功します。 次に、WinRM サービスを再起動します。
最後に、コマンドレットは New-PSSession
構成を使用するセッションの作成を MaintenanceShell
試みます。 今回は、WinRM サービスの再起動時に MaintenanceShell
構成が削除されたため、セッションは失敗します。
パラメーター
-Confirm
コマンドレットの実行前に確認を求めるメッセージが表示されます。
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
コマンドレットが確認を求めず、プロンプトを表示せずに WinRM サービスを再起動することを示します。 サービスを再起動すると、構成の変更が有効になります。
再起動を防ぎ、再起動プロンプトを表示しないようにするには、NoServiceRestart パラメーターを使用します。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
削除するセッション構成の名前を指定します。 1 つのセッション構成名または構成名パターンを入力します。 ワイルドカード文字を使用できます。 このパラメーターは必須です。
セッション構成をパイプ処理することもできます Unregister-PSSessionConfiguration
。
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | True |
-NoServiceRestart
このコマンドレットが WinRM サービスを再起動せず、サービスの再起動を求めるメッセージを表示しないことを示します。
既定では、コマンドを Unregister-PSSessionConfiguration
実行すると、変更を有効にするために WinRM サービスを再起動するように求められます。 WinRM サービスが再起動されるまで、ユーザーは未登録のセッション構成を使用できますが、 Get-PSSessionConfiguration
見つかりません。
プロンプトを表示せずに WinRM サービスを再起動するには、Force パラメーターを指定します。 WinRM サービスを手動で再起動するには、コマンドレットを Restart-Service
使用します。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
コマンドレットの実行時に発生する内容を示します。 このコマンドレットは実行されません。
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
入力
Microsoft.PowerShell.Commands.PSSessionConfigurationCommands
セッション構成オブジェクトをこのコマンドレットにパイプできます。
出力
None
このコマンドレットは、出力を返しません。
メモ
このコマンドレットは、Windows プラットフォームでのみ使用できます。
このコマンドレットを実行するには、[管理者として実行] オプションを使用して PowerShell を起動する必要があります。
関連リンク
- Disable-PSSessionConfiguration
- Enable-PSSessionConfiguration
- Get-PSSessionConfiguration
- New-PSSessionConfigurationFile
- New-PSSessionOption
- Register-PSSessionConfiguration
- Set-PSSessionConfiguration
- Test-PSSessionConfigurationFile
- Unregister-PSSessionConfiguration
- WSMan プロバイダー
- about_Session_Configurations
- about_Session_Configuration_Files
PowerShell
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示