June 10, 2019 at 10:25 pm
Hi
Could you please provide a PowerShell script to loop through multiple servers and get the list of local administrators of all servers?
invoke-command {net localgroup administrators} -comp <servername>
The above powershell command lists from one server.
please provide a script to run on multiple servers.
Thanks
San
June 10, 2019 at 10:39 pm
If you do a quick search on google, you will find a lot of examples - my first page has over a dozen links with examples:
Search of: run powershell command on multiple servers
Sue
June 16, 2019 at 8:16 pm
You know you can provide a comma separated list to the -computername parameter, right?
Type the NETBIOS name, IP address, or fully qualified domain name of one or more computers in a comma-separated list. To specify the local computer, type the computer name, localhost, or a dot (.).
Joie Andrew
"Since 1982"
June 17, 2019 at 1:12 pm
To answer the logically next expected question...
https://www.google.com/search?&q=save+powershell+output+to+table+in+sql+server
Of course, I don't have a code example for this because I don't use PowerShell to do such things, especially since the list of my servers is stored in SQL Server to begin with. Although a lot of people frown on it because of misunderstanding, basic lack of knowledge on the subject, and visceral fear, I use xp_CmdShell for this type of thing.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply