Sunday, 19 September 2010

Provision-LyncDnsRecords.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script creates the DNS entries needed for a Lync 2010 SE deployment. 
  4. .DESCRIPTION 
  5.     This script creates a couple of wrapper functions to create DNS A and SRV records, then 
  6.     calls those functions to create the needed A and SRV records for a simple 
  7.     Lync 2010 SE deployment. 
  8. .NOTES 
  9.     File Name  : Provision-LyncDnsRecords.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://pshscripts.blogspot.com/2010/09/provision-lync-dnsrecordsps1.html 
  15.      
  16. #> 
  17. function Get-DnsARecord { 
  18. Get-WmiObject -ComputerName DC1 -Namespace 'root\MicrosoftDNS' -class MicrosoftDNS_AType  -filter "ContainerName ='reskit.org'" | ft ownername, ipaddress -AutoSize  
  19. Set-Alias gda get-DNSARecord 
  20.   
  21. function New-DnsARecord { 
  22. param
  23. $zone = "reskit.org"
  24. $name = "Testxxx.reskit.org"
  25. $address = "131.107.2.200",  
  26. $server = "dc1.reskit.org"
  27. $class = 1, 
  28. $ttl = 3600 
  29. # get class, and create the record 
  30. $rec = [WmiClass]"\\DC1\root\MicrosoftDNS:MicrosoftDNS_AType" 
  31. $result = $rec.CreateInstanceFromPropertydata($server, $zone, $name, $class, $ttl, $address
  32. }  
  33.    
  34. function Get-DnsSrvRecord { 
  35. Get-WmiObject -ComputerName DC1 -Namespace 'root\MicrosoftDNS' -class MicrosoftDNS_SrvType  -filter "ContainerName ='reskit.org'" |  
  36.    ft ownername,port,srvdomainname -AutoSize 
  37. Set-Alias gds get-DNSsrvRecord 
  38.  
  39. function New-DnsSrvRecord { 
  40. param
  41. $zone = "reskit.org"
  42. $name = "SRVFake.reskit.org"
  43. $target = "se.reskit.org"
  44. $port   = 9999, 
  45. $priority = 0, 
  46. $weight = 0, 
  47. $server = "dc1.reskit.org"
  48. $class = 1, 
  49. $ttl = 3600 
  50. $rec = [WmiClass]"\\DC1\root\MicrosoftDNS:MicrosoftDNS_SRVType" 
  51.  
  52. $result = $rec.CreateInstanceFromPropertydata($server, $zone, $name, $class, $ttl, $priority, $weight, $port, $target
  53.  
  54. # Create the needed records 
  55.  
  56. # The machines 
  57. # DC - Domain Controller, CA, IIS 
  58. New-DNSARecord reskit.org dc1.reskit.org        10.100.100.25 
  59. # SE - SE Server 
  60. New-DNSARecord reskit.org dc1.reskit.org        10.100.100.20 
  61. # Monitoring Server 
  62. New-DNSARecord reskit.org monitor.reskit.org    10.100.100.210 
  63. # Archive Server 
  64. New-DNSARecord reskit.org archive.reskit.org    10.100.100.220 
  65. # Reverse Proxy - Inside edge 
  66. New-DNSARecord reskit.org proxy.reskit.org      10.100.100.200 
  67. # Edge Consolidated - Inside edge 
  68. New-DNSARecord reskit.org edge.reskit.org       10.100.100.201 
  69.  
  70. # Services 
  71. # Dialin URL 
  72. New-DNSARecord reskit.org dialin.reskit.org     10.100.100.20 
  73. # Meeting URL 
  74. New-DNSARecord reskit.org meet.reskit.org       10.100.100.20 
  75. # Administration URL 
  76. New-DNSARecord reskit.org admin.reskit.org      10.100.100.20 
  77. # Web Services external URL 
  78. New-DNSARecord reskit.org external.reskit.org   10.100.100.200 
  79. New-DNSARecord reskit.org external1.reskit.org  10.100.100.200 
  80.  
  81. # Client Autodiscover SRV 
  82. New-DnsSrvRecord reskit.org _SipInternalTls._tcp.reskit.org se.reskit.org 5061  
  83.  
  84. # Display A records 
  85. gda  
  86.  
  87. # Display Srv Records 
  88. gds  

No comments: