samiam41
asked on
Move AD objects listed in text file from PS script
Hey Experts!! I am crafting a way for inactive/dormant AD objects to be moved from their OU to an "Inactive" OU. The objects would be moved if they are listed in a text file using Powershell's Move-ADObject. Can anyone provide the command and syntax for this? Thanks Experts.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. Testing now.
ASKER
Not sure what I am doing wrong here but I keep getting this error:
I checked my PS version and got this:
CLRVersion 2.0.50727.5466
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
Thoughts?
The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, scri
pt file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:39
+ GC c:\tools\staleadpc.log | Get-ADUser <<<< | Move-ADObject -targetpath 'ou=
x,ou=xx,dc=xxx,dc=xxxx,dc=xxxx,dc=xy '
+ CategoryInfo : ObjectNotFound: (Get-ADUser:String) [], CommandN
otFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\me> GC c:\tools\staleadpc.log | Get-ADUser | Move-ADObject -
targetpath 'ou=x,ou=xx,dc=xxx,dc=xxxx,dc=xxxx,dc=xy'
I checked my PS version and got this:
CLRVersion 2.0.50727.5466
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
Thoughts?
ASKER
I ran the Get-Module -Listavailable
Manifest ActiveDirectory {}
Manifest AppLocker {}
Manifest BitsTransfer {}
Manifest GroupPolicy {}
Manifest PSDiagnostics {}
Manifest TroubleshootingPack {}
Manifest ActiveDirectory {}
Manifest AppLocker {}
Manifest BitsTransfer {}
Manifest GroupPolicy {}
Manifest PSDiagnostics {}
Manifest TroubleshootingPack {}
ASKER
Never mind, I just ran Import-Module ActiveDirectory and I got a new error so that other error has been resolved.. Updates coming up.
ASKER
Works just as I needed! Thanks.
Nice!!..
The term 'Get-ADUser' is not recognized as the name of a cmdletnormally means ActiveDirectory module is not loaded so PowerShell is not recognizing the commands Get-ADUser or Move-ADObject.
http://gallery.technet.microsoft.com/scriptcenter/PowerShell-to-Disable-c55a8862