Michael Leonard
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
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
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
ASKER
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.InteropServ ices.COMEx ception,Qu est.Active Roles.ArsP owerShellS napIn.Cmdl ets.Connec tCmdlet
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.
+ connect-qadService <<<< -service 'localhost' -proxy -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw
+ CategoryInfo : NotSpecified: (:) [Connect-QADService], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServ
Try to omit the -proxy parameter:
connect-qadService -service 'localhost' -ConnectionAccount 'mydomain\admin' -ConnectionPassword $pw
ASKER
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))
just wondering why the -proxy switch doesnt work? it complains of invalid syntax:
Connect-QADService : Invalid syntax (Exception from HRESULT: 0x800401E4 (MK_E_SYNTAX))
ASKER
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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/distr ibution' -name $_.'group name' -samAccountName $_.'group name' -grouptype $_.'group type' -groupscope $_.'group scope' -connection $connection }
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/distr
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.
My second line contains the connection definition.
ASKER
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.
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
ASKER
thanks, just what i was looking for
ASKER
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.Automat
hellSnapIn.GroupType".
any assistance would be much appreciated
S.
Open in new window