Function Enable-Computer {
    <#
    .SYNOPSIS
        Enables a disabled computer account in DRA.

    .DESCRIPTION
        This function enables one or more disabled computer accounts in the DRA environment.

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

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

    .EXAMPLE
        Enable-Computer -ComputerName 'COMPUTER1', 'COMPUTER2'
        Enables the accounts for COMPUTER1 and COMPUTER2.

    .EXAMPLE
        'COMPUTER1' | Enable-Computer -Verbose
        Enables a computer account passed via the pipeline and shows verbose output.
    #>
    [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 "Enabling $computer" -PercentComplete $percentComplete
            
            $identifier = "cn=$computer$ouPath"
            Write-Verbose "Attempting to enable computer with identifier: $identifier"

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