Help Required on this Script

Welcome Forums General PowerShell Q&A Help Required on this Script

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

 
Participant
3 years, 6 months ago.

  • Author
    Posts
  • #27611

    Participant
    Points: 0
    Rank: Member

    $domain = [directoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
    $result = $domain.FindAllDomainControllers() | select-object name,IPaddress,currenttime
    $result

    When i run this code the output of current time in DC is showing 1 hour difference
    I am trying to get my Domain controller time information

  • #27613

    Participant
    Points: 0
    Rank: Member

    If you are showing a 1 hour time difference check that all of your machines – client and DC are in the correct time zone AND that there isn't any differences in the daylight savings time settings. I'd suspect that one or more machines aren't set correctly to manage daylight savings changes

    Any reason you're not using the AD cmdlets rather than .NET classes?

  • #27629

    Participant
    Points: 0
    Rank: Member

    Richard, thanks for your quick response
    daylight settings and times are set correctly
    If you could let me know the AD cmdlet for similar to .NET classes that would be so helpful

  • #27643

    Participant
    Points: 428
    Helping Hand
    Rank: Contributor

    Check out Get-ADDomainController. I don't know how the the .NET method is providing the time, but you could try a script like this one and just replace the Get-ADComputer with the Get-ADDomainController and valid the timezones across all of the systems.

  • #27667

    Participant
    Points: 0
    Rank: Member

    Thank You Rob

The topic ‘Help Required on this Script’ is closed to new replies.