WEDL_AssignedAccessWEDL_AssignedAccess

這個 Windows Management Instrumentation (WMI) 提供者類別設定指派存取權的設定。This Windows Management Instrumentation (WMI) provider class configures settings for assigned access.

語法Syntax

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

成員Members

下表列出所有的方法和屬性,屬於這個類別。The following tables list any methods and properties that belong to this class.

方法Methods

這個類別會包含任何方法。This class contains no methods.

屬性Properties

屬性Property 資料類型Data type 限定詞Qualifiers 描述Description

UserSIDUserSID

字串string

[key][key]

您想要做為指派的存取帳戶的使用者帳戶的安全性識別碼 (SID)。The security identifier (SID) for the user account that you want to use as the assigned access account.

AppUserModelIdAppUserModelId

字串string

[讀取]、 [寫入][read, write]

應用程式使用者模型識別碼 (AUMID) Windows 應用程式的啟動指派存取權的帳戶。The Application User Model ID (AUMID) of the Windows app to launch for the assigned access account.

狀態Status

布林值Boolean

none

指出 「 已指派的存取 」 設定的目前狀態:Indicates the current status of the assigned access configuration:

Value 描述Description

00

有效的帳戶已設定,但沒有任何 Windows 應用程式指定。A valid account is configured, but no Windows app is specified. 指派存取權不會啟用。Assigned access is not enabled.

11

已啟用指派的存取。Assigned access is enabled.

0x1000x100

UserSID 錯誤: 找不到帳戶。UserSID error: cannot find the account.

0x1030x103

UserSID 錯誤: 帳戶設定檔不存在。UserSID error: the account profile does not exist.

0x2000x200

AppUserModelID 錯誤: 找不到 Windows 應用程式。AppUserModelID error: cannot find the Windows app.

0x2010x201

工作排程器錯誤:無法排程工作。Task Scheduler error: Could not schedule task. 請確定工作排程器服務正在執行。Make sure that the Task Scheduler service is running.

0xffffffff0xffffffff

未指定的錯誤。Unspecified error.

備註Remarks

若要指派存取權的變更不會影響目前登入; 任何工作階段您必須登出再重新登入。Changes to assigned access do not affect any sessions that are currently signed in; you must sign out and sign back in.

範例Example

下列 Windows PowerShell 指令碼會示範如何使用這個類別來設定存取帳戶。The following Windows PowerShell script demonstrates how to use this class to set up an assigned access account.

#
#---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."
}

需求Requirements

Windows EditionWindows Edition 支援Supported
Windows 10 HomeWindows 10 Home No
Windows 10 專業版Windows 10 Pro Yes
Windows 10 企業版Windows 10 Enterprise Yes
Windows 10 教育版Windows 10 Education Yes