Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7630643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:09:15+00:00 2026-05-31T06:09:15+00:00

I have an aprox 1000 line-script which loops through all servers in AD. The

  • 0

I have an aprox 1000 line-script which loops through all servers in AD.
The script pings each server and does a bunch of WMI-querys if ping=ok.
My script stores the results in a hashtable that I output to a CSV at the end of the script.
This works, but it is sloooow.. We are talking close to two hours. I’ve been looking into doing this more efficient and I think -asjob sounds like a good idea.

But can I do this as concurrent jobs? Would my server handle the load? And is -asjob the way to do it?

Hoping for some input while I’m waiting for my script to run it’s cycle..

EDIT

My opinion is that the script waits for test-connection (ping) to return true or false. I would like to run multiple pings at the same time.

EDIT 2

(NOTE: I Have started a separate question as I feel my original question has been answered. I include my current code anyways as this has been requested. Thank you everyone for pitching in! new question here!)

Thank you everybody for the help so far! I’ve been asked to list my code to provide a real-world example of what I am trying to do.

This is a small, but valid excerpt from my code:

# List 4 servers (for testing)
$servers = Get-QADComputer -sizelimit 4 -WarningAction SilentlyContinue -OSName *server*,*hyper*

# Create list
$serverlistlist = @()

# Loop servers
foreach($server in $servers) {

    # Fetch IP
    $ipaddress = [System.Net.Dns]::GetHostAddresses($Server.name)| select-object IPAddressToString -expandproperty IPAddressToString

    # Gather OSName through WMI
    $OSName = (Get-WmiObject Win32_OperatingSystem -ComputerName $server.name ).caption

    # Ping the server
    if (Test-Connection -ComputerName $server.name -count 1 -Quiet ) {
        $reachable = "Yes"
    }

    # Save info about server
    $serverInfo = New-Object -TypeName PSObject -Property @{
        SystemName = ($server.name).ToLower()
        IPAddress = $IPAddress
        OSName = $OSName
    }
    $serverlistlist += $serverinfo | Select-Object SystemName,IPAddress,OSName
}

Notes:
I am outputting $serverlist to a csv-file at the end of the script
I list aprox 500 servers in my full script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:09:16+00:00Added an answer on May 31, 2026 at 6:09 am

    I would recommend writing a function that handles all of your server validation (ping, WMI, etc.), and then wrap that up in a Start-Job command. To avoid overloading your server’s resources, I’d suggest wrapping some sort of “job manager” around your task.

    foreach ($Server in $ServerList) {
        while ((Get-Job -State Running).Count -ge 20) {
           Start-Sleep -Seconds 5;
        }
        # Start-Job here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so here's the thing: I have a linq query which loads approx. 1000
I have a large Oracle database ( 720,000 records aprox) where each record has
I have a method which is fired once every 30 seconds aprox. that I
I have Server A and Server B which exchanges some data. Server A on
I have a website that has approx 1000 different strings in a mysql database
I have approx 10M rows of data across 20 tables, which I process once
Have two folders with approx. 150 java property files. In a shell script, how
I have been given the tasks of speccing a mobile application, which will need
I have a set of points which are contained within the rectangle. I'd like
My server has my SQL version of 5.0.91-community, now i have to store a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.