need assistance with script

need some assistance. I've installed the quest AD commandlets, and am trying to run this script as a .PS1
this is copied from the .chm help file that comes with the commandlets. however, i cannot get this to run:

/code snippet attached.

thx in advance


$pw = Read-Host "Enter password" -AsSecureString
connect-qadService -service 'localhost' -proxy -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw
Import-Csv C:\temp\data.csv | % { new-qadGroup-ParentContainer 'OU=Distribution,OU=Groups,DC=mydomain,DC=com' -name $_. 'group name' -samAccountName $_. 'group name' -grouptype $_. 'Distribution' -groupscope $_. 'Universal' }
disconnect-qadService

Open in new window

siber1Asked:
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.

siber1Author Commented:
i've corrected some of the script, /see below
however, now i am seeing this error when running:
New-QADGroup : Cannot bind parameter 'GroupType'. Cannot convert the "@{group name=testgrp3; group type=Distribution; g
roup scope=Universal}" value of type "System.Management.Automation.PSCustomObject" to type "Quest.ActiveRoles.ArsPowerS
hellSnapIn.GroupType".

any assistance would be much appreciated

S.
$pw = Read-Host "Enter password" -AsSecureString
connect-qadService -service 'localhost' -proxy -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw
Import-Csv C:\temp\data.csv | % { new-qadGroup -ParentContainer 'mydomain.com/groups/distribution' -name $_. 'group name' -samAccountName $_. 'group name' -grouptype $_. 'group type' -groupscope $_. 'group scope'  }
disconnect-qadService

Open in new window

0
soostibiCommented:
You have unnecessary spaces between $_ and the period. The correct syntax. As I do not have your data file, I can not test it, but hopefully it will work.
$pw = Read-Host "Enter password" -AsSecureString  
connect-qadService -service 'localhost' -proxy -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw  
Import-Csv C:\temp\data.csv | % { new-qadGroup -ParentContainer 'mydomain.com/groups/distribution' -name $_.'group name' -samAccountName $_.'group name' -grouptype $_.'group type' -groupscope $_.'group scope'  }  
disconnect-qadService

Open in new window

0
siber1Author Commented:
Hi soostibi, thanks very much that cleared it!
i am still seeing this error at the beginning of the script: [although it does run now and complete]
any idea how i can resolve that error.

it appears to have a problem with this line of the code:
connect-qadService -service 'localhost' -proxy -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw


At C:\temp\bulkgroupcreation.ps1:44 char:19
+ connect-qadService <<<<  -service 'localhost' -proxy -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw  
    + CategoryInfo          : NotSpecified: (:) [Connect-QADService], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Quest.ActiveRoles.ArsPowerShellSnapIn.Cmdlets.ConnectCmdlet
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

soostibiCommented:
Try to omit the -proxy parameter:


connect-qadService -service 'localhost' -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw

Open in new window

0
siber1Author Commented:
yes that seems to work if i omit the -proxy parameter and replace 'localhost' with the fqdn of one of our domain controllers.
just wondering why the -proxy switch doesnt work? it complains of invalid syntax:
Connect-QADService : Invalid syntax (Exception from HRESULT: 0x800401E4 (MK_E_SYNTAX))
0
siber1Author Commented:
thanks again, i'm fine with just not using the -proxy switch.
would you happen to know what switch i can use to add members to the new groups that i can now create with this command?
0
soostibiCommented:
The -proxy is used if you have ActiveRoles Server Quest software installed.

I refined the code below. This is the real use of the connect-qadservice, if you save and reuse the connection object.

You can add members by this command:
Add-QADGroupMember -Identity groupname -Member username -Connection $connection
$pw = Read-Host "Enter password" -AsSecureString    
$connection = connect-qadService -service 'localhost' -proxy -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw    
Import-Csv C:\temp\data.csv | % { new-qadGroup -ParentContainer 'mydomain.com/groups/distribution' -name $_.'group name' -samAccountName $_.'group name' -grouptype $_.'group type' -groupscope $_.'group scope' -connection $connection }    
disconnect-qadService $connection

Open in new window

0

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
siber1Author Commented:
thx, just tested and i get this error:
New-QADGroup : Cannot validate argument on parameter 'Connection'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again

it is complaining about this part of the script:
new-qadGroup -ParentContainer 'mydomain.com/groups/distribution' -name $_.'group name' -samAccountName $_.'group name' -grouptype $_.'group type' -groupscope $_.'group scope' -connection $connection }




0
soostibiCommented:
If you do not run it as part of the previous script I posted previously, then omit the '-connection $connection' part.
My second line contains the connection definition.
0
siber1Author Commented:
ok yes, that works fine now. thx
i really appreciate your assistance. still trying to learn the quest commandlets.
my last question related to the code you posted to add members to groups:

can you provide the code that would pull group membership from a .csv for multiple groups, and add members to the groups?

many thanks again

S.
Add-QADGroupMember -Identity groupname -Member username -Connection $connection

Open in new window

0
siber1Author Commented:
thanks, just what i was looking for
0
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
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.