ConvertFrom-SddlString
將 SDDL 字串轉換成自訂物件。
語法
All
ConvertFrom-SddlString
[-Sddl] <String>
[-Type <AccessRightTypeNames>]
[<CommonParameters>]
Description
此 Cmdlet 只能在 Windows 平臺上使用。
此 ConvertFrom-SddlString cmdlet 將安全描述符定義語言字串轉換為具有以下屬性的 自訂 PSCustomObject 物件:擁有者、群組、DiscretionaryAcl、SystemAcl 及 RawDescriptor。
Owner、Group、DiscretionaryAcl 和 SystemAcl 屬性包含可讀的文字表示,說明 SDDL 字串中指定的存取權限。
此 cmdlet 於 PowerShell 5.0 中引入。
範例
範例 1:將檔案系統存取權限 SDDL 轉換為 PSCustomObject
$acl = Get-Acl -Path C:\Windows
ConvertFrom-SddlString -Sddl $acl.Sddl
第一個指令使用 Get-Acl cmdlet 取得 C:\Windows 資料夾的安全描述符,並將其儲存在變數中。
第二個指令使用 ConvertFrom-SddlString cmdlet 取得 SDDL 字串的文字表示,該字串包含於代表安全描述符物件的 Sddl 屬性中。
範例 2:將登錄檔存取權限 SDDL 轉換為 PSCustomObject
$acl = Get-Acl HKLM:\SOFTWARE\Microsoft\
ConvertFrom-SddlString -Sddl $acl.Sddl -Type RegistryRights
第一個指令使用 Get-Acl cmdlet 取得金鑰的安全描述符 HKLM:\SOFTWARE\Microsoft\ ,並將其儲存在變數中。
第二個指令使用 ConvertFrom-SddlString cmdlet 取得 SDDL 字串的文字表示,該字串包含於代表安全描述符物件的 Sddl 屬性中。
它使用參數 -Type 來指定 SDDL 字串代表登錄安全描述符。
範例 3:透過使用 ConvertFrom-SddlString(有或不包含 '-Type')參數,將登錄檔存取權限 SDDL 轉換為 PSCustomObject
$acl = Get-Acl -Path HKLM:\SOFTWARE\Microsoft\
ConvertFrom-SddlString -Sddl $acl.Sddl |
ForEach-Object {$_.DiscretionaryAcl[0]}
BUILTIN\Administrators: AccessAllowed (ChangePermissions, CreateDirectories, Delete, ExecuteKey,
FullControl, GenericExecute, GenericWrite, ListDirectory, ReadExtendedAttributes, ReadPermissions,
TakeOwnership, Traverse, WriteData, WriteExtendedAttributes, WriteKey)
ConvertFrom-SddlString -Sddl $acl.Sddl -Type RegistryRights |
ForEach-Object {$_.DiscretionaryAcl[0]}
BUILTIN\Administrators: AccessAllowed (ChangePermissions, CreateLink, CreateSubKey, Delete,
EnumerateSubKeys, ExecuteKey, FullControl, GenericExecute, GenericWrite, Notify, QueryValues,
ReadPermissions, SetValue, TakeOwnership, WriteKey)
第一個指令使用 Get-Acl cmdlet 取得金鑰的安全描述符 HKLM:\SOFTWARE\Microsoft\ ,並將其儲存在變數中。
第二個指令使用 ConvertFrom-SddlString cmdlet 取得 SDDL 字串的文字表示,該字串包含於代表安全描述符物件的 Sddl 屬性中。
它沒有使用這個 -Type 參數,所以顯示的存取權限是針對檔案系統的。
第三個指令使用 ConvertFrom-SddlString cmdlet -Type 與參數,因此回傳的存取權限是用於登錄檔。
參數
-Sddl
指定代表 SDDL 語法中安全描述符的字串。
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Type
指定 SDDL 字串所代表的權利類型。
此參數可接受的值為:
- 檔案系統權利
- 登記權利
- ActiveDirectoryRights
- Mutex權利
- 信號板權利
- 密碼金鑰權利
- 事件等待權限
預設情況下,指令匣會使用檔案系統權限。
PowerShell v6 及以上版本不支援 CryptoKeyRights 和 ActiveDirectoryRights。
參數屬性
| 類型: | Microsoft.PowerShell.Commands.ConvertFromSddlStringCommand+AccessRightTypeNames |
| 預設值: | None |
| 接受的值: | FileSystemRights, RegistryRights, ActiveDirectoryRights, MutexRights, SemaphoreRights, CryptoKeyRights, EventWaitHandleRights |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸入
String
你可以把 SDDL 字串接到這個 cmdlet。
備註
此 Cmdlet 僅適用於 Windows 平臺。