Restart-Xbox.ps1

function Restart-Xbox {
    <#
    .Synopsis
        Reboots the host console.
    .Description
        Reboots the host console.
    .Example
        # Restarts the current title
        Restart-Xbox
    .Example
        # Restarts the Xbox Cold
        Restart-Xbox Cold
    .Parameter Type
        The type of restart to perform
    .Parameter Console
        The xbox consoles to connect to
    #>

    param(
    [XDevkit.XboxRebootFlags]
    $Type = "Title",
    
    [Parameter(ValueFromPipelineByPropertyName=$true)]
    [Alias('DebugIPAddress')]
    [String[]]
    $Console
    )
        
    process {
        $ProcessBlock = {
            $xbox = $_
            $name = $xbox.Name            
            $ip = $xbox.DebugIPAddress            
            try {
                $args = $null, $null, $null, $Type
                $rebootMethod = $xbox.GetType().GetMethod("Reboot")
                $rebootMethod.Invoke($xbox, $args)
                New-Object PSObject -Property @{
                    RebootType = $Type
                    Console = $name
                    DebugIPAddress = $ip
                }       
            } catch {
                $errorCode = $_.Exception.InnerException.ErrorCode
                $xbox.XboxManager.TranslateError($errorCode)                
            }            
        }
        if (-not $console) {
            return Get-Xbox | ForEach-Object $ProcessBlock
        } else {        
            $Console | 
                Connect-Xbox | ForEach-Object $ProcessBlock
        }
    }    
}