Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell - details output file .

Posted on 2014-01-07
5
Medium Priority
?
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

721 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