Jump to content


  • 0
danzi

Move Computer to OU in a multidomain environment

Question

Hi Gurus,

I have been using Onevinn's TSCommander by the brilliant Johann, but it fails in an environment where I have a forest with 2 subdomains. Got ~90 DCs, trust is full,  but since the ConfigMgr site server is in Domain A, when I image computers in Domain B, the MoveToOU server-side script won't find a distinguished name - I think the built-in underlying scripts were never meant to work in such a scenario. Onevinn's Event log says, trying to find DN for the computer... but fails, so no OU move, nor addToADGroup, nothing works...

Trying to run a custom script, but I have no other ideas than running (get-adforest).domains | % {get-adcomputer <computer> -server $_} to grab the device... probably it's something trivial though... 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I contacted Johan and here's his reply

Hmm, I have actually done this once.... He will have to run a ds-Query against Global Catalog, as opposed to Ldap..... Or pay me to give him a custom TSCommander, including him signing a paper that he's responsible for not having several computers with the same samAccountName in multiple Domains ;)

 

Share this post


Link to post
Share on other sites

  • 0

Haha, nice! :) Well site codes are used so computer names are 100% unique due to the conventions in place.

 

$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$OU = $tsenv.Value('OSDDomainOUName')

$targetdomain = $tsenv.Value('OSDDomainName')
$imaged_device = $tsenv.Value('OSDcomputerName')
$ErrorActionPreference = 'SilentlyContinue'

function getcmp($computer){
    $CompResultList = @()
    $DomainList = @("domainA","domainB")
     foreach($Domain in $DomainList)
      {
        if (!(get-adcomputer -identity $computer -Server $Domain -ErrorAction SilentlyContinue))
        {continue}
        $CompResultList += get-adcomputer -identity $imaged_device -Server $Domain
    }
    
    return $CompResultList
 }  
get-adcomputer $(getcmp -computer $imaged_device).name -server $targetdomain |  Move-ADObject -TargetPath $OU -server $targetdomain

is import module for AD missing?

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.