- <#
- .SYNOPSIS
- This script restarts the DNS Service on a Remote System
- .DESCRIPTION
- This script uses WMI to reach out and restart the DNS
- DNS service on a remote machine. in my home environment,
- I find the DNS service on the home DC fails and needs
- to be restarted - this script works!
- .NOTES
- File Name : Restart-DNS.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2009/10/restart-dnsps1.html
- .EXAMPLE
- PSH [C:\foo]: .\Restart-DNS.ps1
- Restarting DNS Service on: Cookham1
- DNS Service stopped
- DNS Service started
- #>
- ##
- # Start Script
- ##
- # Set server to reset and display our intention
- $Server = "Cookham1"
- "Restarting DNS Service on: $Server"
- # Get DNS service
- $dns = gwmi win32_service -computer $Server | where {$_.name -eq "DNS"}
- # Now stop it
- $ret = $dns.stopservice()
- if ($ret.returnvalue -eq 0) {"DNS Service stopped"}
- else {"DNS Service not stopped"}
- # And now restart it
- $ret = $dns.startservice()
- if ($ret.returnvalue -eq 0) {"DNS Service started"}
- else {"DNS Service not started"}
- # End of Script
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Showing posts with label dns. Show all posts
Showing posts with label dns. Show all posts
Thursday, 29 October 2009
Restart-DNS.ps1
Labels:
dns,
powershell,
PowerShell scripts,
PowerShell V2,
wmi
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
Labels:
dns,
ocs,
powershell,
PowerShell scripts,
scripts
Subscribe to:
Posts (Atom)