Parsing Powershell data from Get-ADReplicationUpToDatenessVectorTable

This topic contains 7 replies, has 4 voices, and was last updated by  postanote 1 month ago.

  • Author
    Posts
  • #99186

    dar
    Participant

    So I am using Get-ADReplicationUpToDatenessVectorTable
    It returns something something like whats below, just for every DC, even old and non-existing:
    LastReplicationSuccess : 12/21/2017 5:29:13 PM
    Partition : CN=Schema,CN=Configuration,DC=YOURDCHERE
    PartitionGuid : a6229360-894f-4c6c-aa4b-63737372866c
    Partner : CN=NTDS Settings,CN=YOUROTHERDCHERE
    PartnerInvocationId : daf3888f-762b-4ae3-8cc0-0934b00aa0e6
    Server : YOURDCHERE
    UsnFilter : 24426112

    What I want to do is take all that data, then filter out the blocks that show NO partner data. So "Partner: "

    Then I want to look for LastReplicationSuccess and compare it to todays data. If its more then 1 day off from today do something.

    Problem is I am not sure how to parse the data properly to be able to do this.

    Anyone have any ideas?

  • #99187

    Joel Sallow
    Participant

    You're looking for Where-Object, I think. You can roll both filter steps into a single query.

    Get-ADReplicationUpToDatenessVectorTable |
        Where-Object {
            -not $_.Partner -and
            $_.LastReplicationSuccess -lt (Get-Date).AddDays(-1)
        } | ForEach-Object {
            # Do something with each object that passes the conditions.
        }

    As an example. May need some further tweaking. 🙂

  • #99201

    dar
    Participant

    Thats great. Thank you. That solves the date problem easy.
    Let just take it without the date.
    I need store all the output of Get-ADReplicationUpToDatenessVectorTable into a variable without the junks with the null partner field.

    Any Ideas how I would go about doing that? I keep trying but failing. Hopefully I am wording this correctly.

  • #99204

    Joel Sallow
    Participant

    Strip out the date check and remove the ForEach-Object, and store it into a variable.

    $var = # everything else 
  • #99207

    dar
    Participant

    Ok. I am noob.

    Obviously not like this because it doesnt work.
    $var = Get-ADReplicationUpToDatenessVectorTable |Where-Object { -not $_.Partner }

    • #99208

      Jon
      Participant
      Get-ADReplicationUpToDatenessVectorTable |Where {$_.partner -ne $null}

      That will give you all the results where partner has a value

  • #99211

    dar
    Participant

    Thank you.
    I also just figured out part of my problem was I was running: Import-Module ActiveDirectory on a computer without rsat :facepalm:
    I switched computers and everything works great now. :derp:

    Thank you very much for your help. I learned alot 🙂

  • #99220

    postanote
    Participant

    dar –

    You also don't need to install RSAT to use the ADDS tools on virtually any system.
    You just use implicit remoting to any DC, and proxy the cmdlets to the target.
    The cmdlet run from the remote system, and are gone once you close the session.

    Use PowerShell Active Directory Cmdlets Without Installing Any Software
    'blogs.technet.microsoft.com/heyscriptingguy/2011/10/04/use-powershell-active-directory-cmdlets-without-installing-any-software'

    Using PowerShell for Remote Server Administration in Windows 10 RTM without the RSAT tools
    'mikefrobbins.com/2015/08/05/using-powershell-for-remote-server-administration-in-windows-10-rtm-without-the-rsat-tools'

    So, you can fix a block in your code to check for RSAT and if it is not there use implict remoting. Liek this discussion

    Use Get-ADObject without installing RSAT
    'powershell.org/forums/topic/use-get-adobject-without-installing-rsat'

You must be logged in to reply to this topic.