Link to home
Start Free TrialLog in
Avatar of Michael Leonard
Michael LeonardFlag for United States of America

asked on

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

Avatar of Michael Leonard
Michael Leonard
Flag of United States of America image

ASKER

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

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

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
Try to omit the -proxy parameter:


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

Open in new window

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))
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?
ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 }




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

thanks, just what i was looking for