Set-Xbox.ps1

function Set-Xbox
{
    param(
    [Parameter(ValueFromPipelineByPropertyName=$true)]
    [Alias('DebugIPAddress')]
    [string[]]
    $Console,
    
    [XDevKit.XboxDumpMode]
    $DumpMode,
    
    [XDevKit.XboxEventDeferFlags]
    $EventDeferFlags,
    
    [ValidateSet("NTSC-M","NTSC-J","PAL-I","VGA")]
    [String]
    $VideoFormat,        
    
    [Switch]
    $WideScreen,
    
    # The resolution to display. If the video format
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [ValidateSet("PAL60", "480p", "720p", "1080i", "1080p", "640x480", "848x480", "1024x768","1280x720", "1280x1024", "1360x768", "1440x900", "1680x1050", "1920x1080")]
    $VideoResolution = "1920x1080",
    
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Xbps.XboxLocaleId]
    $Language = "English",
    
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Switch]
    $DisableBootAnimation,
    
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Switch]
    $EnableBootAnimation,    
    
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Switch]
    $UseWiFi,

    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Switch]
    $UseNIC,
    
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Switch]
    $DisableHardDrive,
    
    # Changes the memory configuration (requires XDK-GB hardware) to Enable 1GB RAM
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Switch]
    $EnableUpperMemory,
    
    # Changes the memory configuration (requires XDK-GB hardware) to Disable the upper 512MB RAM
    [Parameter(ParameterSetName='UsingXbSetConfig')]
    [Switch]
    $DisableUpperMemory
    )
    
    process {
        $processBlock = {            
            $xbox = $_
            $changed = @{}
            $changed.Console = $xbox.Name
            $changed.DebugIPAddress = $xbox.DebugIPAddress
            if ($psBoundParameters["DumpMode"]) {                
                try {
                    $oldDumpMode = $xbox.DumpMode
                    $xbox.DumpMode = $DumpMode                    
                    $changed.DumpMode = "$oldDumpMode -> $DumpMode"
                } catch {
                    Write-Error $_
                }                
            }         
            if ($psBoundParameters["EventDeferFlags"]) {                
                try {
                    $oldEventDeferFlags = $xbox.EventDeferFlags
                    $xbox.EventDeferFlags = $EventDeferFlags                    
                    $changed.EventDeferFlags = "$oldEventDeferFlags -> $EventDeferFlags"
                } catch {
                    Write-Error $_
                }                
            }         
            if ($psCmdlet.ParameterSetName -eq "UsingXbSetConfig") {
                # These changes require an xbox developer kit console restart
                $xbSetConfigFile = Get-ChildItem $env:XEDK -Recurse -Filter xbsetcfg.exe |
                    Select-Object -First 1 
                $xbSetConfigParameters = @("/X $($xbox.DebugIPAddress)")
                if ($EnableBootAnimation) {
                    $xbSetConfigParameters += "/BOOTANIM on"
                } elseif ($DisableBootAnimation) {
                    $xbSetConfigParameters += "/BOOTANIM off"
                }
                if ($psBoundParameters.Language) {
                    $language = $psBoundParameters.Language
                    $languageId = [string]::Format("{0,1:X}", $Language).TrimStart("0")
                    $xbSetConfigParameters  += "/LANG $languageId"
                }                
                $oldDefault =  $xbox.XboxManager.DefaultConsole
                Invoke-Expression "& '$($xbSetConfigFile.Fullname)' $xbSetConfigParameters"
                $xbox.XboxManager.DefaultConsole = $oldDefault 
                $null = $xbox | Restart-Xbox Cold
            }            

            New-Object PSObject -Property $Changed
        }
        if (-not $console) {
            Get-Xbox | 
                ForEach-Object -Process $processBlock 
        } else {
            foreach ($c in $console) {
                Connect-Xbox -Console $c | ForEach-Object -Process $processBlock 
            }
        }
    }
}