none
Script for all Local Member Servers accounts with password never expires true RRS feed

  • Question

  • I have searched all over, I am fairly new to scripting in powershell. I am trying to get a script that would go out to active directory and get all server in domain. Once that is done it need to remotely access all member servers not DC's and bring back all account that are set to never expire weather it is a local id or domain id. Does anyone have something like this. Would also like it to be able to interrogate based on list also and export results in a csv file.
    Tuesday, November 29, 2016 7:07 PM

All replies

  • Pre-written scripts are here: https://gallery.technet.microsoft.com/

    We do not write scripts on request and the chances that someone has your exact script are minimal.


    \_(ツ)_/

    Tuesday, November 29, 2016 7:38 PM
    Moderator
  • Not tested, but based on a similar script I used:

    # Retrieve all member servers, computers with a server OS that are not Domain Controllers.
    $Servers = Get-ADComputer -LDAPFilter "(&(operatingSystem=*server*)(!(userAccountControl:1.2.840.113556.1.4.803:=8192)))"
    
    ForEach ($Server In $Servers)
        # Retrieve the NetBIOS name of the server.
        $NTName = $Server.sAMAccountName.Replace("$", "")
        # Bind to the computer object with the WinNT provider.
        $Computer = [ADSI]"WinNT://$NTName,computer"
        # Consider all local users.
        $Users = $Computer.psbase.Children | Where-Object {$_.psbase.schemaclassname -eq "user"}
        ForEach ($User in $Users)
        {
            $Name = $User.Name
            $Flags = $User.userFlags.Value
            If ($Flags -band 65536)
            {
                "User $User on server $NTName has password never expires"
            }
        }
    }
    


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Tuesday, November 29, 2016 8:01 PM
  • Hi,

    Please check that whether suggestions above are helpful to you.

    Best Regards,

    Amy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, December 14, 2016 2:21 PM
    Moderator