Combing 2 scripts

I have 2 scripts as follows:

Get-Content C:\Data\GetDescription\ComputerList.txt | Get-ADComputer -Property Name,Description |`
 Select -Property Name,Description |`
 Export-CSV C:\Data\GetDescription\ComputerList-Description.csv -NoTypeInformation -Encoding UTF8

Get-Content C:\Data\PingTest\ComputerList.txt | ForEach-Object{
$pingstatus = ""
IF (Test-Connection -BufferSize 32 -Count 1 -ComputerName $_ -Quiet) {
        $pingstatus = "Online"
} Else {
        $pingstatus = "Offline"
}

New-Object -TypeName PSObject -Property @{
      Computer = $_
      Status = $pingstatus }
} | Export-Csv C:\Data\PingTest\ComputerList-PingResults.csv -NoTypeInformation -Encoding UTF8

One gets the AD Description of the computers in the computer list. First column is name of computer and second column is the description.

The other does a test-connection and outputs the results. First column is name of computer and second column is the result of test-connection.

I want to combine them so that I have 3 columns. Name Description Result of Test-Connection.

These are my first 2 scripts and I mostly found all the code searching on Google, so I barely qualify as a beginner. Any tips on combining them?

Chad,
Welcome to the forum. :wave:t4:

The most common way of combining the results of more than one query is to use a [PSCustomObject].

$InputComputerList = Get-Content -Path 'C:\Data\GetDescription\ComputerList.txt'
$Result =
foreach ($ComputerName in $InputComputerList) {
    $ADComputer = Get-ADComputer -Identity $ComputerName -Properties Description
    [PSCustomObject]@{
        Name        = $ADComputer.Name
        Description = $ADComputer.Description
        Online      = Test-Connection -ComputerName $ComputerName -Count 1 -Quiet
    }
}
$Result

Of course you can pipe the $Result to whatever further step you want. :wink: