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 8592239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:42:29+00:00 2026-06-11T23:42:29+00:00

I have what should be a simple script that will connect to all the

  • 0

I have what should be a simple script that will connect to all the servers in a domain and build a table of all the services running on each server. However, when I try to automate the script to grab all the servers in a foreach loop I get an RPC error. If the $name variable is replaced with the server DNS name everything works as expected. I’ve checked the firewall and DCOM services on my system (win7) and the servers (2000 – 2008R2) and these are all enabled or disabled appropriately. So, I’m thinking something in the script is broke. I’m still learning powershell, so any tips are appreciated.

Here is the script so far.
$servernames = get-adobject -Filter ‘ObjectClass -eq “Computer” ‘ -Searchbase “OU=Servers,DC=E,DC=BENEFIS,DC=ORG”

 foreach ($name in $servernames) {
        Get-WMIObject win32_service -computername $name -Property      SystemName,Name,StartName,StartMode | 
        Format-table SystemName, Name, Startname >c:\serverservices.txt }
  • 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-06-11T23:42:30+00:00Added an answer on June 11, 2026 at 11:42 pm

    Each object you get back have a name property so you need to pass its value to the ComputerName parameter. In addition, to get computer object use the Get-ADComputer cmdlet, you also need to specify the Append switch when you export to the file otherwise content will be overwritten and what you’ll see finally is the output of the last computer only.

    $servernames = Get-ADComputer -SearchBase "OU=Servers,DC=E,DC=BENEFIS,DC=ORG" -Filter *
    
    foreach ($name in $servernames) 
    {
            Get-WMIObject win32_service -computername $name.Name -Property SystemName,Name,StartName,StartMode |
            Format-table SystemName, Name, Startname | Out-File c:\serverservices.txt -Append
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple python script that should scan a text file, which
I am trying to make a simple script that will remove all unnecessary whitespace
I have a computational geometry problem that I feel should have a relatively simple
I have CMS with a script that is executed for each file that is
I'm building a fairly simple PHP script that will need to send some emails
I have a JS script that will be hosted on my server and that
I have a simple reporting script that takes 5-10 minutes to run. It's triggered
I have a script that should be triggered by editing my spreadsheet, but I
I have what should be a simple issue: On my newest rendition of http://www.derekbeck.com/1775
Hey guys I have what should be a simple question, but I am new

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.