Powershell - details output file .

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 | %{

$group = "MyGroup"

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
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

MilesLoganAuthor Commented:
Hi Spec01 .. right .. I appreciate that information but I cant use a GPO on these .
Subash SundharanIT Infrastructure Architect Commented:
I have done some modification but not tested... :-) . Check and see if it gives you the expected result.
$ErrorActionPreference = "Stop"
GC Servers.txt | %{
$Serv = $_
$group = "Guests"
	Try {
	"" | Select @{N="Server";e={$Serv}},@{N="Status";e={"Success"}}
	"" | Select @{N="Server";e={$Serv}},@{N="Status";e={"Failed"}}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MilesLoganAuthor Commented:
Hi Subsun .. This worked great ! thanks again !

Sorry for the delay ..
Subash SundharanIT Infrastructure Architect Commented:
No problem.. :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.