Set-XboxTitle.ps1

function Set-XboxTitle {
    <#
    .Synopsis
        Tells the system software which title to launch after the console is rebooted.
    .Description
        Tells the system software which title to launch after the console is rebooted with the DMBOOT_WAIT flag.
    .Example
        Set-XboxTitle "media:\Gears Of War" -reboot
    .Parameter Path
        Path to the title
    .Parameter CommandLineArguments
        The command line arguments to the title
    .Parameter Reboot
        If set, will reboot immediately.
    #>

    param(
        $Path,
        $CommandLineArguments,
        [Switch]$Reboot,
        [Parameter(ValueFromPipelineByPropertyName=$true)]
        [Alias('Name')]
        [String[]]
        $Console
    )
    
    process {
        $directory = $path.Substring(0, $path.LastIndexOf("\") + 1)    
        $title = $path.Substring($path.LastIndexOf("\") + 1)
        foreach ($c in $console) {
            if (-not $c) {
                $result = $xbdm::DmSetTitle(
                        $directory, 
                        $title, 
                        $CommandLineArguments)
                if ($Result -ne $script:XbdmSuccess) {
                    Write-Error ($xbdm)::DmTranslateError($Result)
                } else {
                    New-Object PSObject -Property @{
                        Title = $Title
                        CommandLineArguments = $CommandLineArguments
                    }
                }
                if ($reboot) {
                    Restart-Xbox
                }            
            } else {
                foreach ($xbox in (Connect-Xbox $c)) {
                    $result = $xbdm::DmSetTitle(
                            $directory, 
                            $title, 
                            $CommandLineArguments)
                    if ($Result -ne $script:XbdmSuccess) {
                        Write-Error ($xbdm)::DmTranslateError($Result)
                    } else {
                        New-Object PSObject -Property @{
                            Console = $xbox.Name
                            Title = $Title
                            CommandLineArguments = $CommandLineArguments
                        }
                    }
                    if ($reboot) {
                        $xbox | Restart-Xbox | Out-Null
                    }                            
                }
            }
        }

    }     
}