共用方式為


ConvertFrom-SddlString

將 SDDL 字串轉換為自訂物件。

語法

Default (預設值)

ConvertFrom-SddlString
    [-Sddl] <String>
    [-Type <Object>]
    [<CommonParameters>]

Description

ConvertFrom-SddlString Cmdlet 會將安全性描述元定義語言字串轉換成具有下列屬性的自定義 PSCustomObject 物件:Owner、Group、DiscretionaryAcl、SystemAcl 和 RawDescriptor。

擁有者、群組、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 參數,因此傳回的訪問許可權適用於登錄。

範例 4:將 Active Directory 訪問許可權 SDDL 轉換為 PSCustomObject

$user = [ADSI]"LDAP://CN=username,CN=Users,DC=domain,DC=com"
ConvertFrom-SddlString $user.psbase.ObjectSecurity.Sddl -Type ActiveDirectoryRights

第一個命令會使用 Active Directory 服務介面 (ADSI) 來取得用戶物件,並將它儲存在 變數中。

第二個命令會使用 ConvertFrom-SddlString Cmdlet 來取得 SDDL 字串的文字表示法,該字串包含在代表安全性描述元之 物件的 Sddl 屬性中。

它會使用 -Type 參數來指定 SDDL 字串代表 Active Directory 安全性描述元。

參數

-Sddl

指定字串,表示 SDDL 語法中的安全性描述元。

參數屬性

類型:String
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:0
必要:True
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Type

指定 SDDL 字串所代表的許可權類型。

此參數可接受的值為:

  • FileSystemRights
  • 註冊表許可權
  • ActiveDirectory許可權
  • MutexRights
  • 信號量許可權
  • CryptoKeyRights
  • EventWaitHandleRights 事件等待句柄許可權

根據預設,Cmdlet 會使用文件系統許可權。

PowerShell Core 不支援 CryptoKeyRights 和 ActiveDirectoryRights。

參數屬性

類型:Object
預設值: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