Function Disable-Computer {
    <#
    .SYNOPSIS
        Disables an active computer account in DRA.

    .DESCRIPTION
        This function disables one or more active computer accounts in the DRA environment by setting the 'IsDisabled' property to true.

    .PARAMETER ComputerName
        The name(s) of the computer(s) to disable.

    .PARAMETER DraServer
        The FQDN of the DRA server. Defaults to "mcguire.dra.us.af.mil".

    .EXAMPLE
        Disable-Computer -ComputerName 'COMPUTER1', 'COMPUTER2'
        Disables the accounts for COMPUTER1 and COMPUTER2.

    .EXAMPLE
        'COMPUTER1' | Disable-Computer -WhatIf
        Shows what would happen if the computer account were disabled, without actually doing it.
    #>
    [CmdletBinding(SupportsShouldProcess=$true)]
    param(
        [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
        [string[]]$ComputerName,

        [Parameter(Position=1)]
        [string]$DraServer = "mcguire.dra.us.af.mil"
    )

    Begin {
        $ouPath = ",OU=McGuire AFB Computers,OU=McGuire AFB,OU=AFCONUSWEST,OU=Bases,DC=AREA52,DC=AFNOAPPS,DC=USAF,DC=MIL"
        $i = 1
        $total = $ComputerName.Count
    }

    Process {
        foreach ($computer in $ComputerName) {
            $percentComplete = ($i / $total) * 100
            Show-ProgressBar -Activity "Disabling $computer" -PercentComplete $percentComplete

            $identifier = "cn=$computer$ouPath"
            Write-Verbose "Attempting to disable computer with identifier: $identifier"

            if ($pscmdlet.ShouldProcess($identifier, "Disable Computer Account")) {
                try {
                    Set-DRAComputer -ErrorAction Stop `
                        -Domain $env:USERDNSDOMAIN `
                        –DRARestServer $DraServer `
                        -DRARestPort 8755 `
                        –DRAHostServer $DraServer `
                        –DRAHostPort 11192 `
                        -Identifier $identifier `
                        -IsDisabled $true `
                        -Force
                    
                    Write-Verbose "Successfully disabled computer: $computer"
                }
                catch {
                    Write-Warning "Could not disable computer '$computer'. Error: $($_.Exception.Message)"
                }
            }
            $i++
        }
    }
    
    End {
        Show-ProgressBar -Activity "Operation Complete" -PercentComplete 100
    }
}
