QuestOne PowerShell

I'm trying to use :
http://mikefrobbins.com/2012/10/04/use-powershell-to-copy-the-group-membership-of-one-active-directory-user-to-another-active-directory-user-account/

But when I enter :
Get-QADUser 'username' |
, next line goes to >>

Then no other commands work -

Should be :
Get-QADUser 'username' |
Get-QADMemberOf


How can I use this software correct?
Thanks
LVL 4
mvalencia2003Asked:
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.

mvalencia2003Author Commented:
or this one =

Get-QADUser 'username' |
Get-QADMemberOf |
Add-QADGroupMember -Member 'username'

after first line , next line goes to :
>>
0
becraigCommented:
you are piping the command when you use "|" so powershell is waiting for something else .

Just run the command without the "|"


If you are at the powershell prompt use the pipes on the same line:
E.g

Get-QADUser 'username' | Get-QADMemberOf |Add-QADGroupMember -Member 'username'
0
mvalencia2003Author Commented:
got error =
Add-QADGroupMember : Access is denied.
At line:1 char:63
+ Get-QADUser 'username'| Get-QADMemberOf |Add-QADGroupMember <<<<  -Member 'username'
    + CategoryInfo          : NotSpecified: (:) [Add-QADGroupMember], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Quest.ActiveRoles.ArsPowerShellSnapIn.Commands.AddGro
   upMemberCmdlet2
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.

becraigCommented:
This indicates you do not have permissions to modify the group you are trying to make changes to.

I would suggest you start another question to troubleshoot issue with any potential ACL issues on your AD objects.
0
becraigCommented:
Can you try running this as administrator and see if you get a different response ?
0
mvalencia2003Author Commented:
on powershell I shift + right click and selected run as a different user , logged on with Admin AD account -

still get error : Add-QADGroupMember : Access is denied.
0
becraigCommented:
Can you share the exact command you are running.
0
mvalencia2003Author Commented:
Get-QADUser 'username' | Get-QADMemberOf | Add-QADGroupMember -Member 'username'
0
mvalencia2003Author Commented:
error =

Add-QADGroupMember : Access is denied.
At line:1 char:64
+ Get-QADUser 'username' | Get-QADMemberOf | Add-QADGroupMember <<<<  -Member 'username'
    + CategoryInfo          : NotSpecified: (:) [Add-QADGroupMember], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Quest.ActiveRoles.ArsPowerShellSnapIn.Commands.AddGro
   upMemberCmdlet2
0
becraigCommented:
Hmmm
This would be the correct syntax
Add-QADGroupMember -Identity 'groupname' -Member 'username'

What exactly are you doing here, it looks like you are getting the properties for a user:
Get-QADUser 'username'
Then getting the groups that user is a member of:
Get-QADMemberOf

Then I am not sure on the last step since you are Adding the user now to what group ?
There is no group specified here...
Add-QADGroupMember  -Member 'username'

If you are trying to add another user tho those groups, then you would do this:

Get-QADUser 'username' | Get-QADMemberOf |  % {Add-QADGroupMember -Identity $_ -Member '<newusername>'}

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
mvalencia2003Author Commented:
gave 16 of these :

Add-QADGroupMember : Cannot resolve directory object for the given identity: '<newusername>'.
At line:1 char:68
+ Get-QADUser 'username' | Get-QADMemberOf |  % {Add-QADGroupMember <<<<  -Identity $_ -Member '<newusername>'}
    + CategoryInfo          : NotSpecified: (:) [Add-QADGroupMember], ObjectNotFoundException
    + FullyQualifiedErrorId : Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.ObjectNotFoundException,Quest.Acti
   veRoles.ArsPowerShellSnapIn.Commands.AddGroupMemberCmdlet2
0
becraigCommented:
identity: '<newusername>' HAS to be the user you now want to add to those groups.

Please take a look at the page you are referencing this from.

You are taking the membership from one group and adding another user to those groups, there are also a lot of other concerns eg:
where name -ne 'domain users'

you will also have to add that to your script, so your script will be
$user1 = "<some user>"; $user2 = "<Some other user>"; Get-QADUser $user1|Get-QADMemberOf |where name -ne 'domain users' | Add-QADGroupMember -Member $user2

Open in new window



This is pretty much what the page references.
You NEED to provide the user input values.
0
mvalencia2003Author Commented:
Thanks
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.