Function to test if AD computers are online

Welcome Forums General PowerShell Q&A Function to test if AD computers are online

This topic contains 4 replies, has 5 voices, and was last updated by

1 year, 3 months ago.

  • Author
  • #85016

    Points: 0
    Rank: Member

    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.

  • #85018

    Points: 1,141
    Helping Hand
    Rank: Community Hero

    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.


  • #85109

    Points: 0
    Rank: Member

    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
  • #85147

    Points: -18
    Rank: Member

    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


  • #85198

    Points: 22
    Rank: Member

    Moving to correct forum.

The topic ‘Function to test if AD computers are online’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort