Connect-XboxController.ps1

function Connect-XboxController {
    <#
    .Synopsis
        Simulates the physical connected presence of an Xbox 360 controller.
    .Description
        Simulates the physical connected presence of an Xbox 360 controller.
    .Example
        Connect-XboxController
    .Parameter Player
        The Number of the Player (1-4)
    #>

    param(
    [ValidateRange(1, 4)]
    [int]$Player
    )
    $null = $xbdm::DmAutomationBindController($player - 1, 0)
    $Result = ($xbdm)::DmAutomationConnectController($player - 1)
    if ($Result) {
        Write-Error ($xbdm)::DmTranslateError($Result)
    }
    $null = $xbdm::DmAutomationUnbindController($player - 1)
}