WEDL_AssignedAccess

此 Windows Management Instrumentation (WMI) 提供者類別會設定指派存取權的設定。

語法

class WEDL_AssignedAccess {
    [Key] string UserSID;
    [Read, Write] string AppUserModelId;
    [Read] sint32 Status;
};

成員

下表列出屬於這個類別的任何方法和屬性。

方法

這個類別不包含任何方法。

屬性

屬性 資料類型 限定詞 描述
UserSID string [key] 您要作為指派存取帳戶的使用者帳戶 (SID) 安全性識別碼。
AppUserModelId string [read, write] 要針對指派的存取帳戶啟動的 Windows 應用程式 (AUMID) 應用程式使用者模型識別碼。
狀態 Boolean 指出指派存取設定的目前狀態
描述
0 已設定有效的帳戶,但未指定 Windows 應用程式。 未啟用受指派的存取權。
1 已啟用受指派的存取權。
0x100 UserSID 錯誤:找不到帳戶。
0x103 UserSID 錯誤:帳戶設定檔不存在。
0x200 AppUserModelID 錯誤:找不到 Windows 應用程式。
0x201 工作排程器錯誤:無法排程工作。 請確定工作排程器服務正在執行。
0xffffffff 未指定的錯誤。

備註

已指派存取權的變更不會影響目前登入的任何會話;您必須登出並重新登入。

範例

下列Windows PowerShell腳本示範如何使用這個類別來設定指派的存取帳戶。

#
#---Define variables---
#

$COMPUTER = "localhost"
$NAMESPACE = "root\standardcimv2\embedded"

# Define the assigned access account. 
# To use a different account, change $AssignedAccessAccount to a user account that is present on your device.

$AssignedAccessAccount = "KioskAccount"

# Define the Windows app to launch, in this example, use the Application Model User ID (AUMID) for Windows Calculator.
# To use a different Windows app, change $AppAUMID to the AUMID of the Windows app to launch.
# The Windows app must be installed for the account.

$AppAUMID = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"

#
#---Define helper functions---
#

function Get-UsernameSID($AccountName) {

# This function retrieves the SID for a user account on a machine.
# This function does not check to verify that the user account actually exists.

    $NTUserObject = New-Object System.Security.Principal.NTAccount($AccountName)
    $NTUserSID = $NTUserObject.Translate([System.Security.Principal.SecurityIdentifier])

    return $NTUserSID.Value
}

#
#---Set up the new assigned access account---
#

# Get the SID for the assigned access account.

$AssignedAccessUserSID = Get-UsernameSID($AssignedAccessAccount)

# Check to see if an assigned access account is already set up, and if so, clear it.

$AssignedAccessConfig = get-WMIObject -namespace $NAMESPACE -computer $COMPUTER -class WEDL_AssignedAccess

if ($AssignedAccessConfig) {

# Configuration already exists.  Delete it so that we can create a new one, since only one assigned access account can be set up at a time.

    $AssignedAccessConfig.delete();

}

# Configure assigned access to launch the specified Windows app for the specified account.

Set-WmiInstance -class WEDL_AssignedAccess -ComputerName $COMPUTER -Namespace $NAMESPACE -Arguments @{
        UserSID = $AssignedAccessUserSID;
        AppUserModelId = $AppAUMID
        } | Out-Null;

# Confirm that the settings were created properly.

$AssignedAccessConfig = get-WMIObject -namespace $NAMESPACE -computer $COMPUTER -class WEDL_AssignedAccess

if ($AssignedAccessConfig) {

    "Set up assigned access for the " + $AssignedAccessAccount + " account."
    "  UserSID = " + $AssignedAccessConfig.UserSid
    "  AppModelId = " + $AssignedAccessConfig.AppUserModelId

} else {

    "Could not set up assigned access account."
}

規格需求

Windows 版本 支援
Windows 首頁 No
Windows 專業版 No
Windows 企業版
Windows 教育版
Windows IoT 企業版 是的