Add-XboxUser.ps1

function Add-XboxUser {
    <#
    .Synopsis
        Adds a user to the XBox
    .Description
        Adds a user to the list of those authorized to establish a secure connection
    .Example
        Add-XboxUser jamesbru -manage
    .Parameter UserName
        Name identifying the user to be added.
    .Parameter Read
        The user named has read privileges.
    .Parameter Write
        The user named has write privileges.
    .Parameter Control
        The user named can control the debug monitor
    .Parameter Configure
        The user named can configure the development console
    .Parameter Manage
        The user named can manage user accounts.
    #>

    param(
    [Parameter(ValueFromPipelineByPropertyName=$true)]
    [Alias('DebugIpAddress')]
    [String[]]$Console,
    [string]$UserName,
    [switch]$Read,
    [switch]$Write,
    [switch]$Control,
    [switch]$Configure,
    [switch]$Manage
    )
    $Access = 0
    if ($read) { $access = $access -bor [DMPL.Priv]"Read" } 
    if ($Write) { $access = $access -bor [DMPL.Priv]"Write" } 
    if ($Control) { $access = $access -bor [DMPL.Priv]"Control" } 
    if ($Configure) { $access = $access -bor [DMPL.Priv]"Configure" } 
    if ($Manage) { $access = $access -bor [DMPL.Priv]"Manage" } 
    ($xbdm)::DmAddUser($UserName, $Access)
}