Uncategorized

DNS Details Export

Thanks to : http://www.lebleuet.net

How to generate statistics of your DNS server with powershell

On 6 January 2016, in DNS, IT Procedure, Powershell, Programming, by Himselff

Here is a litle script i’ve build by digging through differents article to match what i needed :

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

#Extracting the date

$day = get-date -Format dd

$month = get-date -format MM

$year = get-date -format yy

$hour = get-date -Format hh

$min = get-date -Format mm

$today = $day+$month+$year+”-“+$hour+$min

$myFile = “c:\DATA\stats” + $today + “.txt”

 

#Getting stats from each zone and send all to the text file

Get-DnsServerZone | select zonename | Get-DnsServerStatistics > $myFile

 

#Sending stats file per email

$PSEmailServer = “email server IP”

Send-MailMessage -From “dnsserver@domain.com” -To “who need the report@domain.com” -Subject $Today” DNS Stats” -Attachments $myFile

First save that into a .ps1 file and then run that through a schedule task with that batch file

@ECHO OFF
PowerShell.exe -Command “& ‘getstats.ps1’”
PAUSE

 

Advertisements
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s