Came across a unique request to get primary, secondary, and tertiary DNS values for multiple computers/servers across the domain. I started writing the script and got what I wanted. Now this started off as just to query for DNS Server information, but then I thought to add other pieces to get myself a good Network…
Tag: get
Get All DCs in the Entire Forest
Getting a know a new environment for a new client and I a quickly needed information about all domain controllers in the entire forest. Wrote a small little script to provide me all the information I needed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Import-Module ActiveDirectory function Get-AllDCsInForest{ [CmdletBinding()] param( [string]$ReferenceDomain = $env:USERDOMAIN ) $ForestObj = Get-ADForest -Server $ReferenceDomain foreach($Domain in $ForestObj.Domains) { Get-ADDomainController -Filter * -Server $Domain | select Domain,HostName,Site, IPv4Address, OperatingSystem, OperatingSystemVersion } } Get-AllDCsInForest| Export-Csv -Path C:\Scripts\AllDcs.txt -NoTypeInformation |
Resolve IP Addresses from List of Host Names
If you have a list of hostnames/servers that you need IP addresses for its cumbersome to ping each server and get the ip address. PowerShell to the rescue! To do this we need a file called Server.txt with each server’s hostname on each line. I am storing the file in D:\Data\Servers.txt. Once we run the…
Connecting to a remote domain controller using PowerShell
Covering one of the basic day to day task if you are a Windows Administrator; connecting to the domain controller. Â I try to minimize logging onto servers as much as possible. Â Your thought should be around connecting to the server remotely and doing the work as needed instead of natively logging on to it. I…
Get PasswordAge for users in a particular domain
In Office365 if you have more than one domain in a subscription, there are times where you may want to get the password age for users of that domain. In my case to check which users are covered and meeting policy and get the users addressed.
1 |
Get-MsolUser -All -DomainName "yourdomainname.com" | select DisplayName, LastPasswordChangeTimeStamp,@{Name=â€PasswordAgeâ€;Expression={(Get-Date)-$_.LastPasswordChangeTimeStamp}} |
The output will be similar to: