Solved

Powershell - details output file .

Posted on 2014-01-07
5
251 Views
Last Modified: 2014-01-17
I normally dont need to do this on such a large scale but I need to add a group to about 4,000 servers . The script below works fine with just a couple .. can someome help me modify this so it outputs a file with information if it did add the group or it could not connect to the server ?

GC Servers.txt | %{

$domain="MyDomain"
$group = "MyGroup"

([adsi]"WinNT://$_/Administrators,group").Add("WinNT://$domain/$group,group")
}
0
Comment
Question by:MilesLogan
  • 2
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39763851
You can accomplish this very easily using Restricted Groups in Group Policy. This is a computer policy but no reboot required. Wait for group policy to refresh and the AD group will be added to all of the servers/workstations you specify for this GPO.

Restricted Groups GPO - http://community.spiceworks.com/how_to/show/2123-add-an-active-directory-group-to-the-local-administrator-group-of-workstation-s

Will.
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39763856
Hi Spec01 .. right .. I appreciate that information but I cant use a GPO on these .
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39769524
I have done some modification but not tested... :-) . Check and see if it gives you the expected result.
$ErrorActionPreference = "Stop"
GC Servers.txt | %{
$Serv = $_
$domain="MyDomain"
$group = "Guests"
	Try {
	([adsi]"WinNT://$Serv/Administrators,group").Add("WinNT://$domain/$group,group")
	"" | Select @{N="Server";e={$Serv}},@{N="Status";e={"Success"}}
	}
	Catch{
	"" | Select @{N="Server";e={$Serv}},@{N="Status";e={"Failed"}}
	}
}

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39788937
Hi Subsun .. This worked great ! thanks again !

Sorry for the delay ..
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39789197
No problem.. :-)
0

Join & Write a Comment

Suggested Solutions

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Resolve DNS query failed errors for Exchange
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now