Purti Bajaj
asked on
Modifying description of multiple AD groups via powershell.
Hello,
I am Purti Bajaj , and i need one script which update my description for multiple groups in active directory.
I am importing csv file but even though i m getting "object not found error".
Below are the sample of script which i m using.
$file = Import-Csv C:\temp\group1.csv
foreach ($line in $file){
set-adgroup '$($line.Groupname)' -Description '$($line.Description)'
}
Kindly look into this and do the needful.
Thanks in Advance!!!!
I am Purti Bajaj , and i need one script which update my description for multiple groups in active directory.
I am importing csv file but even though i m getting "object not found error".
Below are the sample of script which i m using.
$file = Import-Csv C:\temp\group1.csv
foreach ($line in $file){
set-adgroup '$($line.Groupname)' -Description '$($line.Description)'
}
Kindly look into this and do the needful.
Thanks in Advance!!!!
ASKER
Thanks for your quick response!!
Even i m using double quote too, its not working.
Kindly help .
Even i m using double quote too, its not working.
Kindly help .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$file = Import-Csv C:\temp\group1.csv
ForEach ($line in $file) {
Set-ADGroup $line.Groupname -Description $line.Description
}
But i m getting below error:
Set-ADGroup : Cannot validate argument on parameter 'Identity'. The argument is null. Provide a valid value for the
argument, and then try running the command again.
Please post your CSV
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Any feedback?
The initial error was definitely that Set-ADGroup was searching for the literal string [b]$($line.Groupname)[/b].
The second error can only result from an incorrect csv.
The second error can only result from an incorrect csv.
You need to use double quotes instead.
Open in new window
That said, since you're only using the values from the csv, without adding anything to the string,, you can use the variables just as they are:Open in new window
And please use [code][]/code] tags (see the toolbar above the input field) when posting code.