Showing posts with label dns. Show all posts
Showing posts with label dns. Show all posts

Thursday, 29 October 2009

Restart-DNS.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script restarts the DNS Service on a Remote System 
  4. .DESCRIPTION 
  5.     This script uses WMI to reach out and restart the DNS 
  6.     DNS service on a remote machine. in my home environment, 
  7.     I find the DNS service on the home DC fails and needs  
  8.     to be restarted - this script works! 
  9. .NOTES 
  10.     File Name  : Restart-DNS.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell V2 
  13. .LINK 
  14.     This script posted to: 
  15.         http://pshscripts.blogspot.com/2009/10/restart-dnsps1.html
  16. .EXAMPLE 
  17.     PSH [C:\foo]: .\Restart-DNS.ps1 
  18.     Restarting DNS Service on: Cookham1 
  19.     DNS Service stopped 
  20.     DNS Service started 
  21. #> 
  22. ## 
  23. # Start Script 
  24. ## 
  25.  
  26. # Set server to reset and display our intention 
  27. $Server = "Cookham1" 
  28. "Restarting DNS Service on: $Server" 
  29.   
  30. # Get DNS service 
  31. $dns = gwmi win32_service -computer $Server  | where {$_.name -eq "DNS"} 
  32.   
  33. # Now stop it 
  34. $ret = $dns.stopservice() 
  35. if ($ret.returnvalue -eq 0) {"DNS Service stopped"} 
  36. else {"DNS Service not stopped"} 
  37.   
  38. # And now restart it 
  39. $ret = $dns.startservice() 
  40. if ($ret.returnvalue -eq 0) {"DNS Service started"} 
  41. else {"DNS Service not started"} 
  42.   
  43. # End of Script 
Technorati Tags: ,,,,

Saturday, 19 July 2008

Get-DomainFromAOR.ps1

<#
.SYNOPSIS
    Gets the target domain from the AOR and displays result    
.DESCRIPTION
    Defines an AOR, then uses PowerShell to get domain from AOR.
    See http://cacorner.blogspot.com/2008/07/microsoft-office-communicator-auto.html
    for the details behind this mini-script.   
.NOTES
    File Name  : Get-DomainFromAOR.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V2 CTP3
.LINK
    See blog posting at:
    http://pshscripts.blogspot.com/2008/07/get-domainfromaorps1.html
.EXAMPLE
    PS C:\Foo> .\get-domainfromaor.ps1
    AOR           : sip:tfl@gktrain.net
    Target Domain : gktrain.net
#>

##
# Start of Script
##

# Determine AOR, then get domain
$AOR = "sip:tfl@gktrain.net"
$domain = ($aor.split("@"))[1]

# Display the results
"AOR           : {0}" -f $aor
"Target Domain : {0}" -f $domain