Managing multiple "old" AD computer objects

So we have implemented a naming convention where the techs just select a location and department during the imaging process for a  machine that is about to be deployed; during that process and the computers are automagically named something like "NYC-FIN-1234567"...
with 1234567 being the dell asset tag.... pretty nifty Johan(!)
However... the problem is that once that machine gets re-imaged at the same location and deployed to another team like the marketing folks  (ie."MKT")... it gets the name NYC-MKT-1234567...
the problem I am seeing is now we have multiple objects in AD with the same asset tag which is causing nightmares for licensing management... NYC-FIN-1234567 & NYC-MKT-1234567 respectively.
I am working on a PowerShell script that will trim the names down to their respective tags and then compare the list for duplicates - then check  and compare the duplicates properties like "created date" and make a determination and delete
the older object...
this checking for duplicates is proving to be a little more difficult and haven't even gotten to the evaluate section yet...  I am still working on my proficiency when it comes to more complex arrays.
am i going about this the right way or does anyone else have another approach to this conundrum?
scripting games '14 anyone :p

all good info!
Since our AD has less than 3000 workstation objects the 'scaling' is manageable... but could make it a little faster, but alas here is what i have with a couple of tweaks
i am skimming all computer objects in our 'workstation' OU... and dropping the first two prefixes, and then checking for machines that match... we were originally using "created date" but since we have workstations that have been imaged to say
a FIN dept and then to a MKT dept and then re-re-imaged back to FIN... the created date doesn't change so i switched to Modified date, and keep the newest one...
but also as another 'layer' of protection i test-path of the workstation (we run this middle of the day) before disabling it and moving it to a "temp" ou where we can let them sit for a couple weeks in case we had a false positive (thus the ping)
we can quickly restore that object... i also can just comment out the actual "move and disable command" so it generates me a nice list of machines that would have been deleted so i can do a 'sanity check' before deleting a bunch of vip's machiens
from AD :)
#Declare Domain and OU to be Scrubbed - and $dupou is the ou we can let them 'chillout' before deleting on the next run
$domain = "domain.com"
$OU = "OU=Workstations,DC=domain,DC=com"
$CleanupList = "c:\disabled.txt"
$dupOU = "OU=Duplicates,OU=INACTIVE,DC=domain,DC=com"
if (test-path $CleanupList) {Remove-Item $CleanupList}
$delOK = "c:\DelOk.txt"
if (test-path $delOK) {Remove-Item $delOK}
#this is the TEMPORARY throttle cap... so it will stop after it finds the amount defined by $cap (so we can phase it in)
$cap = 10000
$Global:i = 0
$sdate = (Get-Date)
Write-Output "AD Duplicate 'Scrubber' Script started on: "$sdate >> $CleanupList
Write-output "These Machines were disabled and moved to the Inactive\Duplicates OU in our domain" >> $CleanupList
Write-Output "--------------------------------------------------------------------------------------------------------------">> $CleanupList
$comps = (Get-ADComputer -filter * -Server $domain -SearchBase $OU).name
ForEach ($comp in $comps) {
if ($global:i -lt $cap) {
#trim length to just asset tags (last 7 digits)
$Length = $comp.Length
$var = $Length - 7
$tag = $comp.Substring($var,7)
Write-host -ForegroundColor yellow "Testing asset tag: $tag"
$x =(Get-ADComputer -Filter "name -like '*$tag'" -Properties DistinguishedName, Modified -Server $domain -SearchBase $OU |Sort-Object -Property Modified)
if ($x.count -gt 1) {
$y = ($x.count) -1
while ($y -ge 1 ) {
$z = $y - 1
$x.name[$z] >> $CleanupList
#added a ping feature to as another level of "protection"
if (Test-Connection $x.name[$z] -Count 2 -Quiet){
Write-Output $x.name[$z]" is Online... Skipping"
$x.name[$z] >> c:\WTF.txt
}Else {
#this line below this one is the one that moves and disables... comment out if testing with a # sign or remove when testing compelete
#Get-ADComputer $x.name[$z] | Move-ADObject -TargetPath $dupOU -PassThru | Disable-ADAccount
Write-Output $x.name[$z]" is Offline... should delete"
$global:i++
$x.name[$z] >> $delOK
write-host -ForegroundColor Cyan $x.name[$z]" Moved and Disabled - $global:i"
$y--
Write-host "------------"
Write-host -foregroundcolor cyan "$i Computer objects were Disabled and Moved to $dupOU :)"
#message in the body
$msg ="Please review the attached list to see the Duplicate machines that were moved and disabled via this script"
#Recipients
$mailTo = "shad acker <[email protected]>"
Send-MailMessage -SmtpServer smtp.domain.com -Attachments $delOK -Body $msg -to $mailTo -From "DuplicateFinder<[email protected]>" -Subject "Computer Duplicates Disabled" -Cc "who ever <[email protected]>"
not the prettiest or most efficinent but it seems to be working :)

Similar Messages

  • "managed by" attribute of computer object

    Hi all,
    I am working on a script to manage the computer's attribute "managed-by" through power shell. I have found the command Set-ADComputer "AAECNBJ003403L" -ManagedBy "dn_path_of_user" which does not seem to be a solution in
    my ad environment.
    In our environment, all the client machines are in one domain (machine.domain.com) and users from different domains (user1.domain.com ; user2.domain.com) logon to these machines ( all domains in same forest ). when I provide the DN path of the users which
    is "cn=user,dc=user1,dc=domain,dc=com" in the command Set-ADComputer "AAECNBJ003403L" -ManagedBy "dn_path_of_user" I get the error as follows 
     Identity info provided in the extended attribute: 'ManagedBy' could not be resolved. Reason: 'Cannot find an object with identity: 'cn=user,dc=user1,dc=domain,dc=com under: 'DC=machine,DC=domain,DC=com'.
    SO it is searching for the user object in machine.domain.com where the object does not exist. Please tell me if I can specify a user domain name in the command.

    I need to dig into my customer's environment to know why it works for them when they add the user of a different domain. Yes, we were in the process of domain migration which has been delayed due to some incompatible applications.
    We have also been using a script which is taking the input from a csv file and updating the managed by attribute of the machine. In the script we are specifying the domain  "user.domain.com" and it works for us when we need to update the attribute
    in bulk. But we also need the command for updating the attribute of the individual machine as per the end user request. Please see the script below if this can be taken into reference. 
     Import-CSV C:\Users\W9a0n3p9\Desktop\comp.csv |%{
    #Specify the search criteria
    $Computer = $_.Computername
    $samname = $_.Username
    $domain = "user.domain.com"
    #Get a list of domains in the forest and grab the DN of the one matching the above parameter.
    $forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    $domain = $forest.Domains | ? {$_.Name -eq $domain}
    $domainDN = $domain.GetDirectoryEntry().distinguishedName  
    Write-Output  "Found the remote domain, the full LDAP distinguished name is $DomainDN"
    #Create an LDAP searcher object and pass in the DN of the domain we wish to query
    $Searcher = New-Object System.DirectoryServices.DirectorySearcher([ADSI]"LDAP://$domainDN")
    #Pass in the ceriteria we are searching for.
    #In this case we're looking for users with a particular SAM name.
    $Searcher.filter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName= $samname))"  
    $results = $Searcher.Findall()
    #Loop through the results
    Foreach($result in $results){
        $User = $result.GetDirectoryEntry()
        $userDN =  $user.DistinguishedName
        Write-Output "Set the Owner for Computer $computer as $userDN"
        $A= Get-adcomputer $computer
        $A.managedby = "$userdn"
        Set-adcomputer -instance $A
    Regards,
    Maddy

  • Managing multiple collision detection between objects(not necessarily circles)

    Hi.
    I´d like to know if there´s any good tutorial, or if somebody knows, a way, to manage a multiple collision detection with pixel level detection, for objects, not necessarily circles, irregular objects.
    Any help?

    Yes, and what about the speeds of each object?
    I was thinking something like this:
    var  _currentObj1SpeedX = obj1.speedX
    var  _currentObj1SpeedY = obj1.speedY
    obj1.speedX = obj1.speedX - obj2.speedX
    obj1.speedY = obj1.speedY - obj2.speedY
    obj2.speedX = obj2.speedX -  _currentObj1SpeedX
    obj2.speedY = obj2.speedY -  _currentObj1SpeedY
    Is it right?

  • AMT Computer Object Creation in Out of Band Management

    Just configured our Out of Band Management / AMT settings and we're getting all our AMT systems provisioned successfully. I've noticed that now, in SCCM 2012, the AMT object that gets created are Computer objects in AD. Their objectCategory is
    CN=Computer,CN=Schema,CN=Configuration,DC=mydomain,DC=com
    Back in the SCCM 2007 days, They were Person objects in AD. We still have some in AD.
    CN=Person,CN=Schema,CN=Configuration,DC=mydomain,DC=com
    Is this the default setting or do I have the option to change it?
    Orange County District Attorney

    Since no one has answer this post, I recommend opening  a support case with CSS as they can work with you to solve this problem.
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • Managing multiple itunes accounts on a single computer

    I have an iPod and an iPad that use a single iTunes account on a certain PC. I have a second iPod that I have setup on a second computer which also has its own separate iTunes account (because at the time I didn't understand you can manage multiple devices from a single account/computer). This second iPod has iPod apps I have purchased from my second iTunes account. I would like to change this and manage my second iPod from my main computer (so everything lives in one place). When I hooked the second iPod up to my main computer I picked the option to "transfer purchases to this computer". It acted like it was doing it, but I noticed nothing transferred. I unplugged the device and plugged it back in, and a dialogue box told me this iPod contained 33 applications that were NOT authorized to play on this computer and would not transfer them. It said I needed to authorize the computer to do that. My PC is already authorized with my main account and I don't want to mess that up. Can I authorize my computer for my second itunes account and have it authorized for both? Am I allowed to take apps I've purchased for the ipod that is on account 1 and install any of those apps on the ipod that is associated with account 2? I've purchased all these apps, I just did not understand from the get go that there was no need for me to setup 2 completely different itunes accounts. The second iPod I am going to give to my young daughter as a toy, but I absolutely don't want to mess up my iPad and first iPod as I use them for work on a daily basis. Any help would be appreciated.

    +Can I authorize my computer for my second itunes account and have it authorized for both?+
    Yes. Sign out of the itunes store under the first account, then _sign back in_ with 2nd.
    +I just did not understand from the get go that there was no need for me to setup 2 completely different itunes accounts.+
    Don't worry, lots of people made this same mistake. It will be kind of a hassle remembering to authorize both accounts in the future, but it's manageable. You know that license agreement that comes up after an itunes update? I think you'll have to go in under both accounts and agree to it from now on.
    http://support.apple.com/kb/HT1848
    See this line?
    +If the iTunes Store purchases on your device were purchased with multiple accounts, you will need to authorize the computer for each one.+
    That's what I'm talking about.

  • Managing multiple iPods from one computer

    The existing posts re: managing multiple iPods/iTunes accounts from one computer don't seem to address my question. I have been sharing my iPod with the family, and want to get my son his own for his birthday. Can I manage both iPods from the same computer? Does the iTunes software have the ability to "recognize" which iPod unit is attached? I'm dying to get his music out of my iPod ...

    Can I manage both iPods from the same computer?
    Yes.
    I'm dying to get his music out of my iPod ...
    Create new playlist and put the music you want in it.
    Open iTunes prefs -> iPod and select Automatically update only selected playlists and pick this new playlist.

  • How to manage multiple ipads and iphones on the same computer

    Any advice on how to manage multiple iphones (iPhone 4S, iPhone 4 & iPhone 3G) along with an iPad & iPad 2 on the same computer?
    Thank you

    The article that AnaMusic references assumes that you sync automatically I believe. Turn off auto sync and select whatever you want to put on each device. As Philly said, it really is a snap. I have never synced automatically and I never selected iTunes to start up when my iDevices are connected. I want the control over all of that.
    Launch iTunes on your computer and go to Edit>Preferences>Devices>Prevent iPods, iPhones, and iPads from syncing automatically. Check that box and then quit iTunes.
    Connect your iPad to your computer, launch iTunes, click on your iPads name on left sidebar under the devices heading and then click on the summary tab in the iTunes window on the right. Select - Sync only checked songs and videos. If you really want to "live dangerously" - uncheck Open iTunes when this iPad is connected. Now you can control what you sync and when iTunes starts up. iTunes will not start up when you connect the iPad and it will not sync anything on its own.
    Go into each tab in iTunes, Info, Music, Apps, .... All of them - check what you want to sync in each section. After you have made all of your selections (and you have checked all of the headings - Sync Music, Sync Apps and so on) click on Apply in the lower right corner on iTunes and the sync will take place.
    Do this with each iDevice and iTunes will remember what you selected for each device the last time that you synced. You can make changes to this configuration any time that you want for each device and if you do just remember to click on Apply in the lower right corner of iTunes in order to apply the changes.

  • Managing multiple devices on 1 computer

    We recently purchased ipod shuffles for each of our kids. I have a ipod nano that i've had for years. How do I manage multiple devices through iTunes?

    Hi, welcome to Apple Discussions.
    *How to use multiple iPods with one computer*
    The Apple support document How to use multiple iPods with one computer suggests a number of ways. I use method two (Sync with selected playlists) with a slight twist. Rather than regular playlists I set the grouping field to indicate which users should receive which tracks and create smart playlists based on the content of this field.
    e.g.
    "Alice's Tracks" is "Grouping contains Alice" + "Kind contains audio"
    "Bob's Videos" is "Grouping contains Bob" + "Kind does not contain audio"
    Tracks that both Alice & Bob want on their iPods have the grouping set to "Alice/Bob"
    etc.
    I currently manage our family's five iPods using this system, each getting a different selection to suit their tastes and the capacity of their iPod. An advantage of using the grouping field is that it is stored in file tags (for non-wav audio files anyway) so that it is relatively easy to recreate the playlists should the iTunes library get trashed. Also useful if you move files about manually as playlist membership is preserved when you delete & re-import the tracks.
    tt2

  • Prestage Computer Object in Subdomain

    Trying to precreate a computer object in a subdomain. It works sometimes (1 in 15) with a "Directory Object Not Found" error. I'm doing this through a powershell workflow
    (for WAP/SMA - hence the credential call). The credential has full access on the target OU. The if statement is for multiple domains I have but shortened up for sake of cleanliness here.
    The best I can tell is it's some sort of error with how it's looking for the OU where the server should end up. Code below- anyone delt with this before?
    workflow Precreate-Object
    Param(
    [Parameter(Mandatory=$True)][String]$servername,
    [Parameter(Mandatory=$True)][String]$datacenter,
    [Parameter(Mandatory=$True)][String]$ou
    $PSUserCredAD = Get-AutomationPSCredential -Name "Automation Credential"
    if ($datacenter -like "Subdomain")
    $domaincontroller = "subdomain.location.domain.com"
    InlineScript{
    New-ADComputer -Name $using:servername -Path "$using:ou" -Server $using:domaincontroller -Credential $using:PSUserCredAD
    Full error below:
    8/11/2014 11:00:33 AM, Error: New-ADComputer : Directory object not found At Precreate-Object:28 char:28
    + + CategoryInfo : ObjectNotFound: (CN=Servername,CN=...domain,DC=com:String) [New-ADComputer], ADIdentityNotFoundException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Mic rosoft.ActiveDirectory.Management.Commands.NewADComputer

    Your error is explicit.  YOu are asking a specific dc for the info and it is saying it doesn't exist on the domain.  IIt is not saying no access or anything else.  The object does not exist as specified.  Fix the DN and it will likely
    work.
    ObjectNotFound: (CN=Servername,CN=...domain,DC=com:String)
    ¯\_(ツ)_/¯

  • Multiple IDs+One Computer=Wrong phone account.

    So, there are 3 of us in my house who have iPhones and we use one computer which means the same iTunes pops up everytime time we plug in our phone. But sometimes after unplugging our phones from the computer and we try to download an app on our phone it says one of the other Apple IDs that isn't mine. How do I get my Apple ID back on my phone?

    Your Apple ID is on your phone unless you actually signed out of it on the phone or restored it from one of the other devices backups.
    The issue is that content linked to one of the other accounts has been synced to your device.
    You really should read this article about how to manage multiple devices on a single computer.  Doing so with the same iTunes library under a single login is not an ideal choice.

  • How do I manage multiple itunes devices ?

    How do I manage multiple itunes devices with other family members on a single computer?
    I do not want to share libraries.

    There's a couple of options (other than using specified playlists or manual management out of a single library).
    The following document is worth checking through: 
    How to use multiple iPods, iPads, or iPhones with one computer

  • How can I Manage Multiple Users?

    My wife and I both want to organize and edit our digital photos with PSE10.  Up until now, I have managed all of our photos by myself, and I have synchronized all data on both of our computers (and backed up all of our data to an external harddrive).  Now that my wife also wants to organize and edit our photos on her computer, I am finding it difficult to synchronize the PSE Catalogs and photos on our two computers.  So, I am looking for a better procedure. 
    Should I (and can I) keep my PSE Catalog & Photos on: 
    (1) an External Harddrive (which would be connected to only one computer at a time, while that computer user is organizing and editing photos), or 
    (2) on a Home Network location where both users could access the photos for organizing and editing (with a "lockout" for photos which are being edited by the other computer user)? 
    Are there other good or better procedures for managing multiple users of PSE? 
    My computer is running Win7 Home Premium 64-bit. 
    My wife's computer is running Windows Vista Home Premium 32-bit.

    Thank all of you for your replies. 
    Re SOFTWARE CHOICES:
    I decided that my wife and I will each use different software on our different computers.
    I decided NOT to upgrade my wife's software from "Windows Live Photo Gallery" (WLPG) to "Adobe Photoshop Elements 10" (PSE).  After a detailed discussion of my wife's wishes, I discovered that she only wants to (1) move our pictures into folders, (2) cull the pix, and (3) create "Album" folders (with only our most memorable pix) to be printed as 8.5" x 11" pages for the Albums.  She wants me to crop, edit, add captions, and print the Album pages.  See the image at the bottom for our current Photo Mgmt Plan.
    I will continue to use "Lightroom" (Lr).
    Re SYCHRONIZATION: 
    I decided that we both can use the same picture files.  I use "GoodSync" to sychronize files between my computer and my wife's computer (and between my computer and my backup HDD). 
    My wife's "WLPG" does NOT appear to use a database.  My changes (including "Keyword" edits or adds) show up in her "WLPG" program, when picture files have been changed by myself in "Lr" and sychronized with her computer.
    After my wife adds folders and/or changes the folder contents, I sync her computer with mine.  I open her folders (which are now also on my computer) in "Lr", and "Import" any of her new and duplicate pictures into "Lr".  Surpisingly and thankfully, the pictures that have been moved to a new folder by my wife do NOT show up in "Lr" in the previous folder (i.e. I do NOT have to find and delete any "Missing" images which were in the previous folder location).
    Re MULTIPLE USERS OF A DATABASE:
    I do not need to use this now, but I read that "Lr" is designed to work with the "Lr" database (and pictures) on an external HDD.
    Thank all of you again for your very helpful replies.

  • How can I manage multiple iPads for different students?

    Problem: I need to manage multiple iPads for my students with special needs. I need to download different apps to different iPads and I'm not sure how to keep their apps separate but still keep ultimate control of the units (i.e. lock them from loading anything on the apps that we at the school district haven't approved).
    I need to be the only one doing updates, loading software, etc., and don't want to keep using my own personal iTunes account...any suggestions?

    If the presenter is using a computer and everyone else has an iPad this is very easy and free. Just use http://join.me and on the iPad just download their free app

  • Multiple iPods, same computer....HELP

    I know this question has probably been answered, but I have tried other things and nothing works.
    I have Windows XP, and I have my own account on it and my own iPod(4th gen, click wheel) and my sister has her own account and her own mini iPod. Our music is shared in the shared music folder on the computer.
    Problem is, how do we use multiple iPods on the same computer. I am having trouble because whenever I/we plug in our iPod to the computer, it does not load to iTunes and instead just shows up as something in the E drive. How can I make it recognize each iPod individually without hassle?
    Also, is there a way to not have everyone log out to update my iPod? I get a prompt that says everyone must log out before accessing iTunes. Any help would be great...thanks!

    There are basically two methods for managing multiple iPods on one computer. See here:
    Method 1 - Create different Windows users accounts for each iPod on this computer.
    Method 2 - Create a playlist in iTunes for each iPod.
    To make Method 2 work, connect one of your iPods, and click on it in the left-source panel.
    Under the "Music" tab, and set your option for a specific playlist(s) under the "Sync Music" option.
    Do the same with your other iPod; not connected at the same time as the other one, though.
    For more details on this matter, check out Apple's Support article about it:
    How to manage multiple iPods using one computer
    I hope that helps you.
    -Kylene

  • Managing multiple devices in a family - iCloud better using Mac or PC?

    Anyone using a Mac to manage multiple i devices? We're sharing an iTunes account in the family and are finding limitations using iCloud on our PC. Specifically, can you manage iCloud on each device from a Mac?

    The only practicable way to do this is for each person who has an iCloud account to have their own user account on the Mac, They can then sign into iCloud and keep their data separate from everyong else.
    It is possible to have a single user account and sign into one iCloud account in System Preferences>iCloud and then sign into subsequent ones in System Preferences>Mail, Contacts and Calendars, but if you do this with a number of accounts it will get messy, and everyone will see everyone else's data and emails.
    If you enable 'Fast use switching' you can have several user accounts running at once and simply switch between them (though of course this all takes processing power and RAM). Probably better for everyone to sign in and sign out to their user account when they want to use the Mac - that feels like everyone having their own computer.

Maybe you are looking for

  • Cannot start  domain in suse 9.3

    I'm tryin to start the domain1 in a Suse 9.3 computer with the command: asadmin start-domain domain1and I get this error in the console: Sep 19, 2005 5:23:52 PM com.sun.enterprise.util.ASenvPropertyReader setSystemProperties SEVERE: property_reader.u

  • Init Load showing in yellow state.

    Hi all, I am trying to do init for SRM data source to ODS object. The init load is showing  yellow state (0-0 records). There is no data available in SRM related to this data source. Can anyone please tell me why it is in yellow state instead of gree

  • I am getting the Error as "Returned Content XMl is Empty" in SAP Jco Config

    Hi, I am facing the problem in SAP Jco Config in SAP_JCo_Interface Action, while searching the BAPI (I am Using search Pattern as BAPI*) I am getting the error like following "Returned Content XMl is Empty". this URL refer the same problem ... Re: Re

  • Sending object between client server with some class without serializable

    Hi friend, I need to send the object from server to client via ObjectInputStream and ObjectOutputStream, however, in these objects, some are implements by others, no source code provided, which haven't implement serizlizable, so does anyone can tell

  • Unable to get help from Adobe regarding Creative Cloud

    How can I actually get help administering my Creative Cloud team?  The system is throwing me an error when I try to invite team members and the link to contact customer support drives me to a non-technical call center where the person was actually ru