Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Query the Admins on multiple servers

Posted on 2010-09-07
9
Medium Priority
?
737 Views
Last Modified: 2012-08-13
I wanted to know if it is possible to create a script that will pull the admins on multiple servers and store the information in excel? I have admin rights on all servers, this can be done in Powershell or VBA.

Thank you
0
Comment
Question by:m_travis
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 33622096
This can be done in powershell, but now that I think about it, there are probably easier ways such as using AD functions.  Are you using AD?  Here's an blog post that talks about it, and some script tools that can help. Look for "Use PowerShell to Get Local Group Members from a Remote Computer" in the blog.

http://tasteofpowershell.blogspot.com/

Here's another way to do it and it puts it into excel:

http://www.vistax64.com/powershell/184570-getting-powershell-output-into-sql-table.html
0
 
LVL 1

Expert Comment

by:ldap389
ID: 33622528
As suggested by developedtester, if you have AD, you can use Restricted Groups Policy to pull admins on servers rather than scripting:

http://support.microsoft.com/kb/279301/en-us
http://www.windowsecurity.com/articles/Using-Restricted-Groups.html
http://www.ldap389.info/en/2010/05/12/restricted-groups-policy/




0
 
LVL 39

Accepted Solution

by:
Krzysztof Pytko earned 2000 total points
ID: 33624599
download psexec from SysInternals and use this syntax

psexec \\servername -u <administrator> -p <password> net "localgroup administrators >\\server\share\testfile.txt"

and then import text file into excel.

You can also prepare text file with servers , each name in separate line and then use

psexec @server_testfile.txt -u <administrator> -p <password> net "localgroup administrators >\\server\share\testfile.txt"
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33624605
sorry instead of > sign use >> Firts one overwrites your output line. Sorry once again for mistake

psexec \\servername -u <administrator> -p <password> net "localgroup administrators >>\\server\share\testfile.txt"
0
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 33627690
I think iSiek's comment will be the way to go, especially if you don't have AD.  (very nice iSiek)  Parsing the psexec output and putting it into excel can be done using powershell.  Here's a link to help with the excel part, and if you need help parsing, just let us know.

http://kentfinkle.com/PowershellAndExcel.aspx
0
 
LVL 1

Author Comment

by:m_travis
ID: 33682192
we do have AD
0
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 33701187
So this link:

http://www.myitforum.com/articles/40/view.asp?id=12263

has this command:

Get-QADUser -ldapFilter '(SamAccountName=*.admin)'|export-csv admins.csv

but you need this free addon:

http://www.quest.com/powershell/activeroles-server.aspx

The other link I gave can do it, but probably not as robustly as using the Quest addon.
0
 
LVL 1

Author Comment

by:m_travis
ID: 33791488
I would prefer if there was a way to do the query with using DOS or VB
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question