取得電腦上已註冊的工作階段設定。

語法

Get-PSSessionConfiguration [[-Name] <string[]>] [<CommonParameters>]

描述

Get-PSSessionConfiguration Cmdlet 會取得已經在本機電腦上註冊的工作階段設定。這是進階的 Cmdlet,適合系統管理員用來管理使用者的自訂工作階段設定。

若要建立和註冊工作階段設定,請使用 Register-PSSessionConfiguration Cmdlet。

參數

-Name <string[]>

只取得具有指定之名稱或名稱模式的工作階段設定。請輸入一個或多個工作階段設定名稱。允許使用萬用字元。

必要?

false

位置?

1

預設值

All session configurations on the local computer

接受管線輸入?

false

接受萬用字元?

true

<CommonParameters>

這個 Cmdlet 支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。如需詳細資訊,請參閱 about_Commonparameters.

輸入和輸出

輸入型別是可經由管道輸出至 Cmdlet 的物件型別。傳回型別則是 Cmdlet 所傳回的物件型別。

輸入

您無法經由管道將輸入輸出至這個 Cmdlet。

輸出

Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration

附註

若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項開啟 Windows PowerShell。

若要檢視電腦上的工作階段設定,您必須是該電腦上 Administrators 群組的成員。

若要在遠端電腦上執行 Get-PSSessionConfiguration 命令,本機電腦的用戶端設定 (使用 Enable-WSManCredSSP Cmdlet) 以及遠端電腦的服務設定都必須啟用認證安全性服務提供者 (CredSSP) 驗證,而且您必須在建立遠端工作階段時使用 Authentication 參數的 CredSSP 值。否則,系統會拒絕存取。

範例 1

C:\PS>get-pssessionconfiguration

描述
-----------
這個命令會取得電腦上的工作階段設定。






範例 2

C:\PS>get-pssessionconfiguration -name Microsoft*

Name                      PSVersion  StartupScript        Permission
----                      ---------  -------------        ----------
microsoft.powershell      2.0                             BUILTIN\Administrators AccessAll...
microsoft.powershell32    2.0                             BUILTIN\Administrators AccessAll...

描述
-----------
這個命令會使用 Get-PSSessionConfiguration 的 Name 參數,只取得名稱以 "Microsoft" 為開頭的工作階段設定。

這個命令會取得 Windows PowerShell 隨附的兩個預設工作階段設定。






範例 3

C:\PS>Get-PSSessionConfiguration -name microsoft.powershell | get-member



   TypeName: Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration

Name                   MemberType     Definition
----                   ----------     ----------
Equals                 Method         bool Equals(System.Object obj)
GetHashCode            Method         int GetHashCode()
GetType                Method         type GetType()
ToString               Method         string ToString()
Capability             NoteProperty   System.Object[] Capability=System.Object[]
ExactMatch             NoteProperty   System.String ExactMatch=False
Filename               NoteProperty   System.String Filename=%windir%\system32\pwrshplugin.dll
lang                   NoteProperty   System.String lang=en-US
Name                   NoteProperty   System.String Name=microsoft.powershell
PSVersion              NoteProperty   System.String PSVersion=2.0
ResourceUri            NoteProperty   System.String ResourceUri=https://schemas.microsoft.com/powershell/microsoft.powershell
SDKVersion             NoteProperty   System.String SDKVersion=1
SecurityDescriptorSddl NoteProperty   System.String SecurityDescriptorSddl=O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
SupportsOptions        NoteProperty   System.String SupportsOptions=true
Uri                    NoteProperty   System.String Uri=https://schemas.microsoft.com/powershell/microsoft.powershell
xmlns                  NoteProperty   System.String xmlns=https://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
XmlRenderingType       NoteProperty   System.String XmlRenderingType=text
Permission             ScriptProperty System.Object Permission {get=trap { continue; }...


C:\PS> Get-PSSessionConfiguration -name microsoft.powershell | format-list -property *


Name                   : microsoft.powershell
Filename               : %windir%\system32\pwrshplugin.dll
SDKVersion             : 1
XmlRenderingType       : text
lang                   : en-US
PSVersion              : 2.0
ResourceUri            : https://schemas.microsoft.com/powershell/microsoft.powershell
SupportsOptions        : true
Capability             : {Shell}
Uri                    : https://schemas.microsoft.com/powershell/microsoft.powershell
SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
ExactMatch             : False
xmlns                  : https://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
Permission             : BUILTIN\Administrators AccessAllowed

描述
-----------
這些命令會檢查 Get-PSSessionConfiguration 所傳回的 PSSessionConfiguration 物件。

第一個命令會使用 Get-PSSessionConfiguration Cmdlet 取得 Microsoft.PowerShell 預設設定。

第二個命令會使用管線運算子 (|),將 Get-PSSessionConfiguration 所傳回的物件傳送給 Get-Member Cmdlet。輸出將顯示該物件的屬性和方法。

第三個命令會將同一個物件傳送給 Format-List Cmdlet。值為 * (全部) 的 Property 參數會指示 Format-List 以清單顯示該物件的所有屬性和屬性值。

這個命令的輸出具有非常有用的資訊,包括實作設定類型之 .dll 的位置、所建立之端點的資源統一資源識別項 (URI),以及設定的安全性描述元定義語言 (SDDL)。






範例 4

C:\PS>dir wsman:\localhost\plugin

   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin

Name                      Type                 Keys
----                      ----                 ----
Event Forwarding Plugin   Container            {Name=Event Forwarding Plugin}
MaintenanceShell          Container            {Name=MaintenanceShell}
microsoft.powershell      Container            {Name=microsoft.powershell}
microsoft.powershell32    Container            {Name=microsoft.powershell32}
WMI Provider              Container            {Name=WMI Provider}

描述
-----------
這個命令會在 WSMan: 提供者磁碟機中使用 Get-ChildItem Cmdlet (別名為 dir),以便查看 Plugin 節點的內容。

這是另一種在電腦上查看工作階段設定的方式。

PlugIn 節點包含 ContainerElement 物件 (Microsoft.WSMan.Management.WSManConfigContainerElement),而這些物件代表已註冊的 Windows PowerShell 工作階段設定,以及 WS-Management 的其他外掛程式。






範例 5

C:\PS>enable-wsmanCredSSP -delegate server02

C:\PS> connect-wsman server02

C:\PS> set-item wsman:\server02*\service\auth\credSSP -value $true

C:\PS> invoke-command -scriptblock {Get-PSSessionConfiguration} -computername Server02 -authentication CredSSP -credential Domain01\Admin01 

Name                      PSVersion  StartupScript        Permission                          PSComputerName
----                      ---------  -------------        ----------                          --------------
microsoft.powershell      2.0                             BUILTIN\Administrators AccessAll... server02.corp.fabrikam.com
microsoft.powershell32    2.0                             BUILTIN\Administrators AccessAll... server02.corp.fabrikam.com
MyX86Shell                2.0        c:\test\x86Shell.ps1 BUILTIN\Administrators AccessAll... server02.corp.fabrikam.com

描述
-----------
這個範例會示範如何在遠端電腦上執行 Get-PSSessionConfiguration 命令。此命令要求本機電腦的用戶端設定以及遠端電腦的服務設定都必須啟用 CredSSP 委派。若要執行這個範例中的命令,您必須是本機電腦和遠端電腦上 Administrators 群組的成員。

第一個命令會使用 Enable-WSManCredSSP Cmdlet 來啟用從 Server01 本機電腦到 Server02 遠端電腦的 CredSSP 委派。這個命令會設定本機電腦的 CredSSP 用戶端設定。

第二個命令會使用 Connect-WSMan Cmdlet 來連線到 Server02 電腦。這個動作會將 Server02 電腦的節點新增至本機電腦的 WSMan: 磁碟機,讓您檢視和變更 Server02 電腦的 WS-Management 設定。

第三個命令會使用 Set-Item Cmdlet,將 Server02 電腦之 Service 節點中的 CredSSP 項目值變更為 True。這個命令會設定遠端電腦的服務設定。

第四個命令會使用 Invoke-Command Cmdlet,在 Server02 電腦上執行 Get-PSSessionConfiguration 命令。此命令會使用 Credential 參數,而且它會使用 Authentication 參數搭配 CredSSP 值。






範例 6

C:\PS>(get-PSSessionConfiguration -name CustomShell).resourceURI

https://schemas.microsoft.com/powershell/microsoft.CustomShell

描述
-----------
這個命令會使用 Get-PSSessionConfiguration Cmdlet 來取得工作階段設定的資源 URI。

這個命令可用來設定 $PSSessionConfigurationName 喜好設定變數的值 (採用資源 URI)。

$PSSessionConfiguationName 變數會指定當您建立工作階段時使用的預設設定。雖然這個變數是在本機電腦上設定,不過它會指定遠端電腦上的設定。如需 $PSSessionConfiguration 變數的詳細資訊,請參閱 about_Preference_Variables。






請參閱




目錄