AD Connection - Powershell

Welcome Forums General PowerShell Q&A AD Connection - Powershell

This topic contains 4 replies, has 4 voices, and was last updated by

1 year, 10 months ago.

  • Author
  • #69652

    Points: 0
    Rank: Member

    Hi there,

    I have a script which runs a report on all accounts in AD and returns results on accounts which haven't been logged in to in the last 30 days.

    This works fine however, I would like to run this report against a different domain. Is there something I can enter at the beginning of my script which allows me to authenticate against another domain at all?

    I've tried Set-Location using the domains distinguished name but it returns a message saying it does not exist.

  • #69684

    Points: 0
    Rank: Member

    Try using the -Server parameter and use the FQDN of a server in the other domain.

  • #69690

    Points: 364
    Helping Hand
    Rank: Contributor

    Well you could just google/"favourite search engine" it 🙂

    A believe this was the first link in the list that I got:

    Connect to other domain

    So basically you could use New-PSDrive to make the connection to the second domain.
    Hope that helps.

    Edit: not sure what happened to the link.

  • #69733

    Points: 16
    Rank: Member

    Use this:

    $DC = Get-ADDomainController -Discover -DomainName '' -NextClosestSite | Select -ExpandProperty Hostname
    $Users = Get-ADusers -Server $DC -filter '*'
  • #70062

    Points: 0
    Rank: Member

    Thanks for the posts guys.
    I will give these a try and let you know how I get on.

The topic ‘AD Connection - Powershell’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort