Function to test if AD computers are online

I’m very new to Powershell, and I’m attempting to create a function which will test if AD computers are online using the Get-AD cmdlet. This function works, but I would like it to show the name of the AD computer beside its online/offline status. Any help with this would be greatly appreciated. Gist URL below.

Without looking at you gist location first. Know that there are several pre-built script for you to leverage to do this on this site forum, in the MS PowerShellGallery, TechNet, MSDN and the MS Scripting Guy’s blog. Review and tweak as needed vs going from scratch, well, unless you are doing this for a learning experience. even with that, looking at how others do this is still educational.
Query AD for Computers and Use Ping to Determine Status - Scripting Blog

Try this as a starting point

Get-ADComputer -Filter * |
foreach {
  $props = [ordered]@{
    ComputerName = $_.Name
    Online = (Test-Connection -ComputerName $_.Name -Count 1 -Quiet)

  New-Object -TypeName PsObject -Property $props

It’ll give output like this

ComputerName Online
------------ ------
W16DC01        True
W16AS01        True
W16DSC01       True
W10PRV01      False
W16RMT01       True
W1709CN01      True
W16CN01        True
W17035CN01     True

Hello Richard,

Sorry, to hijack the thread.
I know that [String] or any other data type declares the variable.
But, what does [Ordered] do?, my guess would be that it ordered somehow?

Maybe you have a link where i can find more info.

Thanks in Advance


Moving to correct forum.