No worries Mike. Glad it's sorted.
> On 8 Oct 2014, at 00:56, Murray, Mike <[email protected]> wrote: > > OK, my bad. I had a freaking typo in the OU name! It’s working now. Thanks > for helping me narrow it down, Paul! > > From: [email protected] [mailto:[email protected]] > On Behalf Of Paul Winstanley > Sent: Tuesday, October 7, 2014 4:26 PM > To: [email protected] > Subject: Re: [mssms] PowerShell experts - help, please > > Mike, > > Error - The operation could not be performed because the object's parent is > either uninstantiated or deleted > Cause - The deleted object's parent, usually an Organizational Unit, has been > deleted and must be restored first. > > Really? Do the OU's exist? > > Type in: > > [adsi]::Exists("LDAP://ou=Disabled PC & User,dc=csuchico,dc=edu") > [adsi]::Exists("LDAP://ou=Computers-GPO,dc=csuchico,dc=edu") > > Do you get a return of True for both? > > On Wed, Oct 8, 2014 at 12:09 AM, Murray, Mike <[email protected]> wrote: > PS C:\Users\mmurray> $ADComputer = Get-ADComputer S39638 -Properties > Description > > PS C:\Users\mmurray> write-host $ADComputer > CN=S39638,OU=Computers-GPO,DC=csuchico,DC=edu > > PS C:\Users\mmurray> Move-ADObject $ADComputer -targetpath "ou=Disabled PC & > User,dc=csuchico,dc=edu" > Move-ADObject : The operation could not be performed because the object's > parent is either uninstantiated or deleted > At line:1 char:1 > + Move-ADObject $ADComputer -targetpath "ou=Disabled PC & > User,dc=csuchico,dc=edu" > + > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + CategoryInfo : NotSpecified: > (CN=S39638,OU=Co...csuchico,DC=edu:ADComputer) [Move-ADObject], ADException > + FullyQualifiedErrorId : > ActiveDirectoryServer:8329,Microsoft.ActiveDirectory.Management.Commands.MoveADObject > > > > From: [email protected] [mailto:[email protected]] > On Behalf Of Paul Winstanley > Sent: Tuesday, October 7, 2014 4:05 PM > To: [email protected] > Subject: Re: [mssms] PowerShell experts - help, please > > Mike how about running the move command now after those > > Move-ADObject $ADcomputer -targetpath "ou=Disabled PC & > User,dc=csuchico,dc=edu" > > Does that succeed? > > > On Wed, Oct 8, 2014 at 12:02 AM, Murray, Mike <[email protected]> wrote: > Looks fine when I run that manually. > > PS C:\Users\mmurray> $ADComputer = Get-ADComputer S52477 -Properties > Description > > PS C:\Users\mmurray> write-host $ADComputer > > CN=S52477,OU=ITSS,OU=Departments,DC=csuchico,DC=edu > > PS C:\Users\mmurray> > > > From: [email protected] [mailto:[email protected]] > On Behalf Of Paul Winstanley > Sent: Tuesday, October 7, 2014 4:00 PM > To: [email protected] > Subject: Re: [mssms] PowerShell experts - help, please > > Mike, > > Code seems ok. If you run this manually on one object what do you get? > > So type in > > $ADComputer = Get-ADComputer <enter a hostname> -Properties Description > > Then do a write-host $ADComputer and check you have the correct CN for your > object. > > Then run: > > Move-ADObject $ADcomputer -targetpath "ou=Disabled PC & > User,dc=csuchico,dc=edu" > > On Tue, Oct 7, 2014 at 11:25 PM, Murray, Mike <[email protected]> wrote: > When I run the script. Here’s the entire script (modified from this post): > > $Today = Get-Date > $Desc = "ITSS - Delete on: " + $Today.AddDays(90) > > $Computers = Get-Content c:\Scripts\computers.txt > > ForEach ($Computer in $Computers) > > { $ADComputer = $null > > $ADComputer = Get-ADComputer $Computer -Properties Description > > If ($ADComputer) > > { Add-Content c:\Scripts\computers.log -Value "$Today - Found $Computer, > disabled and moved to Disabled - PC & User OU" > > Set-ADComputer $ADComputer -Description $Desc -Enabled $false > > Move-ADObject $ADcomputer -targetpath "ou=Disabled PC & > User,dc=csuchico,dc=edu" > > } > > Else > > { Add-Content c:\Scripts\computers.log -Value "$Today - $Computer not in > Active Directory" > > } > > } > > > > From: [email protected] [mailto:[email protected]] > On Behalf Of Paul Winstanley > Sent: Tuesday, October 7, 2014 3:19 PM > To: [email protected] > Subject: Re: [mssms] PowerShell experts - help, please > > When do you get this error Mike? > > On Tue, Oct 7, 2014 at 11:17 PM, Murray, Mike <[email protected]> wrote: > Error: > > Move-ADObject : The operation could not be performed because the object's > parent is either uninstantiated or deleted > > From: [email protected] [mailto:[email protected]] > On Behalf Of David O'Brien > Sent: Tuesday, October 7, 2014 2:47 PM > To: [email protected] > Subject: RE: [mssms] PowerShell experts - help, please > > Does > Move-ADObject $Computer -targetpath “ou=Disabled PC `& > User,dc=csuchico,dc=edu” > > Work? Haven’t tested it though. > > Cheers > David > > From: [email protected] [mailto:[email protected]] > On Behalf Of Murray, Mike > Sent: Wednesday, 8 October 2014 8:34 AM > To: [email protected] > Subject: [mssms] PowerShell experts - help, please > > I just about finished a script that disables and moves computers in AD based > on a text file input. However, whoever named our Disabled OU did me no > favors. It’s called “Disabled PC & User”. If I use the PS command below, it > errors with “The ampersand (&) character is not allowed. The & operator is > reserved for future use…”. I’ve tried escaping the “&” with quotes, double > quotes, etc., still no luck. Can someone help? > > Move-ADObject $Computer -targetpath “ou=Disabled PC & User,dc=csuchico,dc=edu” > > > Best Regards, > > Mike Murray > Desktop Management Coordinator - IT Support Services > California State University, Chico > 530.898.4357 > [email protected] > > > > > > > > > > > > > > > >

