Function Get-Computer {
    <#
    .SYNOPSIS
        Retrieves computer object information from DRA.

    .DESCRIPTION
        This function queries the DRA (Directory and Resource Administrator) environment for one or more computer objects and returns their properties. It can accept multiple computer names as an array or via the pipeline.

    .PARAMETER ComputerName
        The name(s) of the computer(s) to retrieve. Do not include the FQDN.

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

    .EXAMPLE
        Get-Computer -ComputerName 'COMPUTER1', 'COMPUTER2'
        Retrieves information for COMPUTER1 and COMPUTER2.

    .EXAMPLE
        'COMPUTER1', 'COMPUTER2' | Get-DraComputer -Verbose
        Retrieves information for two computers passed via the pipeline and shows verbose output.

    .INPUTS
        System.String
        You can pipe computer names to this function.

    .OUTPUTS
        NetIQ.DRA.Admin.PowerShell.Computer.ComputerObject
        Returns a DRA computer object for each computer found.
    #>
    [CmdletBinding()]
    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"
        Write-Verbose "Processing computers in OU Path: $ouPath"
        $i = 1
        $total = $ComputerName.Count
    }

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

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

            try {
                Get-DRAComputer -ErrorAction Stop `
                    -Domain $env:USERDNSDOMAIN `
                    –DRARestServer $DraServer `
                    -DRARestPort 8755 `
                    –DRAHostServer $DraServer `
                    –DRAHostPort 11192 `
                    -Identifier $identifier `
                    -Force
            }
            catch {
                Write-Warning "Could not find or retrieve computer: '$computer'. Error: $($_.Exception.Message)"
            }
            $i++
        }
    }

    End {
        # Clean up progress bar
        Show-ProgressBar -Activity "Operation Complete" -PercentComplete 100
    }
}
