Solved

update notes field in DL

Posted on 2014-09-24
17
148 Views
Last Modified: 2014-09-30
Hi,

I have this code;

import-module activedirectory
GC C:\temp\group.txt | ?{$_}|%{
set-group -Notes "Created - 24/08/2014  
Required - permanent
Owners - user1,user2”
}

Can you please correct this code so that it can see my txt file named as group.txt which contains list of my Distribution groups needs updating in Notes field.

I have tested this single line of code and it worked fine and now need to do over 100 of DLs.

Set-Group –identity G_test –Notes “For chess lovers!”
0
Comment
Question by:kuzum
[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
  • 11
  • 6
17 Comments
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40341196
Have oh tried the get-content method in power shell?

http://technet.microsoft.com/en-us/library/ee176843.aspx

It will be a bit easer to use
0
 

Author Comment

by:kuzum
ID: 40341266
did iyou mean this

import-module activedirectory
GC C:\temp\group.txt | ?{$_}|%{ foreach-object {set-group -Notes "Created - 24/08/2014  
Required - Permanent  
Owners - user1, user2”
}
}
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40341275
What message do you get when you run what you have?
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:kuzum
ID: 40341323
An empty pipe element is not allowed.
At line:2 char:33
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40341330
This should work
GC C:\temp\group.txt | % {Set-ADGroup $_ -replace @{info="Created - 24/08/2014"}}
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40341333
The above was run using powershell command Set-ADGroup rather than set-group. Not sure what server you are running this from.
0
 

Author Comment

by:kuzum
ID: 40341412
thanks, running it on my windows 7 machine, also any reason why SEt-AD group? I did a test and works perfect?
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40342618
I did my test for you from a server 2008 domain controller. What ever works for you.  There will be differences in the version of powershell modules
0
 

Author Comment

by:kuzum
ID: 40349604
thanks, I have to run it on my windows 7 machine, but test it on DC 2008 and had the same error

Set-ADGroup : Cannot find an object with identity: 'XXXX' under: 'DC=mydomain,DC=domain,DC=com'.

Is there any way you amend my original code to work againts my txt file? Because I am not having any issues with that.
" @{info"  is  shown as "notes" field. are we sure about this?  I could be wrong so apoligies in advanced

thanks
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40349618
Can you post the text file? It should just have the name of the group in list format.  What happens if you run on the server?

Can you post the exact command you are running?
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40349635
My tests were done with a simple text file with a list of normal group names. Running the command from the active directory for powershell shortcut on a 2008 r2 server. The command was on one line.  The @notes thing is needed as the noted field can't be directly accessed using the set Ad-group command.   What version of exchange are you using too?
0
 

Author Comment

by:kuzum
ID: 40349652
2010
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40349654
Ok. Same as me.
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40349659
Result of Command
This is what it looks like running on server.
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40349670
ok I know what you are doing now.

You are using the powershell for exchange.

In that case, this works

GC C:\temp\group.txt | Set-group  -Notes "Created - 24/08/2014"
0
 

Author Comment

by:kuzum
ID: 40350434
Ok thanks, I got it working on a single DL in my txt file but had issues for the whole list and it is because of the spaces in the list. can you please change this avoid space between DLs. they are listed as;

dl name1

dlname2   etc.

GC C:\temp\group.txt | ?{$_}%{Set-ADGroup $_ -replace @{info="Created - 23/07/2012
Required - Permanent
Owners - user1, user2"}}
0
 
LVL 12

Accepted Solution

by:
Steven Wells earned 500 total points
ID: 40350943
Ok, lets treat this with two commands.

1. Open Powershell for Exchange 2010

2. run this command to create a new file with no spaces or empty lines.

 
(gc C:\TEMP\Group.txt) | Foreach {$_.TrimEnd()} | where {$_ -ne ""} | Set-Content C:\temp\inputfile.txt

Open in new window


3. Then run this command to use the inputfile.txt, which will have correctly formatted lines.

GC C:\temp\inputfile.txt | set-group -Notes "What ever you want your notes to be "

Open in new window


Ensure that all your groups actually exist.

This should work correctly.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 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