Link to home
Start Free TrialLog in
Avatar of adamtrask
adamtrask

asked on

Moving users inside active directory using powerShell command

Good morning experts,

I am trying to learn all that I can PowerShell for active directory by asking questions since I can not find a book on the topic:

Presently, I need to know (in the simplest command possible) how to move one user from an Active Directory folder to another. Say I need to move a disabled user to a folder called DisabledUsers.

I looked for a "move" command but did not find one. Therefore, I am assuming that this has to be done in two stages, first copy the user to DisabledUsers and then remove him/her from wherever they are. Am I correct in this assumption?
Please advise with an example. Thanks.
SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada 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
Avatar of adamtrask
adamtrask

ASKER

David, thank you very much for your response on a Sunday...

I am having difficulty understanding the job of the if statement in the foreach loop:

if ( !($disableduser.SamAccountName -like "Guest") -and !($disableduser.SamAccountName -like "krbtgt"))

Translating the above to plain English it tells me the following:  if the disabled user's samAccountName is not the same as "guest" and if that name is different from "krbtgt" then the moving process begins.

What does "Guest" and "krbtgt" represent... ?

Thanks
ASKER CERTIFIED SOLUTION
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
I've requested that this question be closed as follows:

Accepted answer: 0 points for adamtrask's comment #a40694785

for the following reason:

Thank you very much. That's what I needed. I am sorry if my questions are not as succinct as they should be, but that is because I am a new hand trying to grasp too many things at the same time.
Thanks a lot
Guest and krbtgt are system defined users default is set to disabled and should not be touched.
Thank you both... I am not sure what I did to generate the request to close the question
Thank you again