<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results for 'app:weblogs' matching tag 'DNS server'</title><link>http://powershell.com/cs/search/SearchResults.aspx?q=app:weblogs&amp;tag=DNS+server&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tag 'DNS server'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>Use PowerShell 3.0 to Clear the Client DNS Cache on Workstations</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2012/08/23/use-powershell-3-0-to-clear-the-client-dns-cache-on-workstations.aspx</link><pubDate>Thu, 23 Aug 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:18562</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;: Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell 3.0 to clear the client DNS cache on workstations.&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. One of the things I love about Windows PowerShell 3.0 in Windows 8 is the number of cmdlets available. These cmdlets make it possible to perform literally hundreds of tasks from within Windows PowerShell. Thus, I rarely leave Windows PowerShell, go to Start, and type to bring up whatever GUI tool I might have needed in times past.&lt;/p&gt;
&lt;p&gt;To be perfectly honest, I never used the GUI to clear the DNS cache on my local computer; nor did I ever use the GUI to register that client in DNS. The cool thing is that there are now cmdlets to perform this rather pedestrian task. In the past, I used &lt;b&gt;ipconfig&lt;/b&gt; to flush the DNS cache and to register my computer with DNS. Of course, when switches were added to &lt;b&gt;ipconfig&lt;/b&gt;, I always wondered why exactly they belong with &lt;b&gt;ipconfig&lt;/b&gt;&lt;i&gt;, &lt;/i&gt;other than the fact that it was a pretty handy place to add the functionality.&lt;/p&gt;
&lt;p&gt;Of course trying to talk a NOOB through this process on the phone is always a challenge. The two commands, flushing the DNS cache and registering the computer in DNS, do not have to go together. The first command removes entries from the DNS resolver cache, and therefore forces the computer to retrieve up-to-date information from DNS.&lt;/p&gt;
&lt;p&gt;I run this command at least once a week&amp;mdash;for example, when I wake up early in the morning and check to ensure that the day&amp;rsquo;s Hey, Scripting Guy! Blog posted on time and correctly. At times I go to the blog, and the new entry does not appear to have posted. Rather than getting all in a tizzy, I have learned that for some reason, cleaning out old entries in my DNS cache resolves the issue. In the past, I used &lt;b&gt;ipconfig /flushdns&lt;/b&gt; to perform that task. I also figure that as long as things need updating, I may as well ensure that my computer information is registerd properly in DNS. This is a preventive action, rather than a corrective task.&lt;/p&gt;
&lt;h2&gt;Flushing DNS cache and registering DNS across the network&lt;/h2&gt;
&lt;p&gt;Because flushing the DNS cache and registering DNS clients is a task that I perform on a routine basis, I decided to take a couple of minutes to knock out a script to perform this action. The first thing I do is import the Active Directory module. Then I use the &lt;b&gt;Get-ADComputer&lt;/b&gt; cmdlet to find the name of all computers on the network running Windows 8. These three lines of code are shown here.&lt;/p&gt;
&lt;p&gt;Import-Module activedirectory&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$c = Get-ADComputer -Filter * -Properties operatingsystem |&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; where operatingsystem -match 8&lt;/p&gt;
&lt;p&gt;Now I use the &lt;b&gt;Invoke-Command&lt;/b&gt; cmdlet to run the &lt;b&gt;Clear-DNSClientCache&lt;/b&gt; and the &lt;b&gt;Register-DNSClient&lt;/b&gt; cmdlets on remote machines running Windows 8. This command is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Invoke-Command -cn $c.name -SCRIPT {&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; Clear-DnsClientCache&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; Register-DnsClient }&lt;/p&gt;
&lt;p&gt;Here is the complete script:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;ClearDNSCacheAndRegister.ps1&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Import-Module activedirectory&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$c = Get-ADComputer -Filter * -Properties operatingsystem |&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; where operatingsystem -match 8&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Invoke-Command -cn $c.name -SCRIPT {&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; Clear-DnsClientCache&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; Register-DnsClient }&lt;/p&gt;
&lt;p&gt;Well, that is about all there is to using Windows PowerShell 3.0 and Windows 8 to flush the DNS cache and to register the client in DNS. More cool Windows PowerShell stuff will continue tomorrow.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3515699" width="1" height="1" alt="" /&gt;</description></item><item><title>Use PowerShell to Troubleshoot Active Directory Integrated DNS</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2012/03/11/use-powershell-to-troubleshoot-active-directory-integrated-dns.aspx</link><pubDate>Sun, 11 Mar 2012 06:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:15270</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;: Microsoft Scripting Guy, Ed Wilson, talks about troubleshooting the status of Active Directory integrated DNS servers.&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. The first ever PowerShell Saturday that was held in Columbus, Ohio was a tremendous success. It was really great to see people who I had literally not seen for five or six years, and to meet new people for the first time ever. People came from nearly a dozen states to attend this event. It was awesome, and I look forward to helping out with the next PowerShell Saturday event.&lt;/p&gt;
&lt;p&gt;One of the cool things about Windows PowerShell is that if a particular cmdlet does not exist, there are multiple choices for a solution. Depending on what I am seeking, I might write a quick script, dash off a fast little function, write a more reusable function, or even write a module to provide the functionality I seek. Many times, however, I do none of the above. In fact, I find myself spending a lot of time at the Windows PowerShell console plunking around. Interactive use of the Windows PowerShell console is a great way to discover information, to manage a system, or to troubleshoot a problem.&lt;/p&gt;
&lt;p&gt;Today, I ran into a problem. It always happens when we come back home&amp;mdash;or at least it seems to be a problem when we come back home after having been gone for a while. The network is down&amp;mdash;or at least that was the report from the Scripting Wife. What the Scripting Wife actually meant to say was that from her computer in the kitchen, she was unable to connect to Facebook. That, in my mind, hardly qualifies as the network is down&amp;hellip;but I digress.&lt;/p&gt;
&lt;p&gt;The first thing I needed to do, after ensuring that her computer could actually communicate with other machines on the network, was to look at DNS. Indeed, it seemed to be a name resolution issue, because it turned out I could ping by IP address, by not by name. I have a rather complicated network at home, and I could not remember which of my domain controllers are actually running DNS (because I am using Active Directory integrated DNS).&lt;/p&gt;
&lt;p&gt;The first thing I do is create a remote session to one of my domain controllers. (I do this because my computer does not have the RSAT tools installed.) The command is shown here, and it enables me to use alternate credentials, if needed. (My normal user account is as a regular user, and so I need to specify an account with admin rights.)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Enter-PSSession -ComputerName dc3 -Credential iammred\administrator&lt;/p&gt;
&lt;p&gt;When I have done that, I import the ActiveDirectory module. This command is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Import-Module activedirectory&lt;/p&gt;
&lt;p&gt;Now I need to retrieve a list of all of my domain controllers. To do this, I use the &lt;b&gt;Get-ADDomainController&lt;/b&gt; cmdlet, and I use a wild card for the &lt;i&gt;Filter &lt;/i&gt;parameter. For each of the domain controller objects that return from the previous command, I need to find out the status of the DNS Server service on the machine. To do this, I use the &lt;b&gt;Get-Service&lt;/b&gt; cmdlet. Luckily the &lt;b&gt;Get-Service&lt;/b&gt; cmdlet accepts a value for the &lt;i&gt;ComputerName &lt;/i&gt;parameter, so I can use this one command to get the status of the DNS Server service on all of the returned domain controllers. After this is complete, I want to know the computer name, the name of the service, and the status of the service. The complete one-line command is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADDomainController -Filter * | foreach { Get-Service DNS -ComputerName $_.hostname} | Select machinename, name, status&lt;/p&gt;
&lt;p&gt;The command tells me that the DNS Server service is stopped on one of the domain controllers. Unfortunately, the &lt;b&gt;Start-Service&lt;/b&gt; cmdlet does not have a &lt;i&gt;ComputerName &lt;/i&gt;parameter, so I cannot use it directly. But the &lt;b&gt;Invoke-Command&lt;/b&gt; cmdlet does have a &lt;i&gt;ComputerName &lt;/i&gt;parameter, so I can start the DNS Server service on the remote server in this way. The command is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Invoke-Command -cn dc1 {start-service dns}&lt;/p&gt;
&lt;p&gt;Now I use the Up arrow to retrieve the prior command and to check the status of the DNS servers on the domain controllers. The command tells me that the service is now running. These commands, and the associated output are shown in the image that follows.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7510.hsg_2D00_3_2D00_11_2D00_12_2D00_01.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7510.hsg_2D00_3_2D00_11_2D00_12_2D00_01.png" alt="Image of command output" title="Image of command output" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I check downstairs with the Scripting Wife and she is now happy&amp;mdash;she can talk on Facebook with the friends she just saw. Cool. Now maybe I can find some time to relax and read a book. I just got a copy of Herman Wouk&amp;rsquo;s &lt;a href="http://en.wikipedia.org/wiki/The_Caine_Mutiny" target="_blank"&gt;The Caine Mutiny&lt;/a&gt;, and I am excited to compare it to the &lt;a href="http://en.wikipedia.org/wiki/The_Caine_Mutiny_(film)" target="_blank"&gt;Humphrey Bogart movie&lt;/a&gt; with the same title.&lt;/p&gt;
&lt;p&gt;I will talk to you tomorrow, until then cheers.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3484439" width="1" height="1" alt="" /&gt;</description></item><item><title>Use PowerShell to Configure Static IP and DNS Settings</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2012/02/28/use-powershell-to-configure-static-ip-and-dns-settings.aspx</link><pubDate>Tue, 28 Feb 2012 06:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:14951</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to set the static IP and DNS addresses on a server.&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. One of the really cool things about computers is that you never get bored. At least for me this is true. For example, I have a server that has been running Exchange Server absolutely perfectly for more than a year. Today, it acted like a 150 pound St. Bernard that had become bored. That&amp;rsquo;s right, it threw a fit. Why did it do so? Well, I had changed the IP network configuration, and I did not change the IP address on this machine. For some reason, the IP changes caused a race condition in Exchange Server, and I could hardly get control of the box. I logged on to the computer, but I was unable to use the graphical tools to set a new IP address on the box&amp;mdash;things would spin in circles, and then disappear. Dude, what now?&lt;/p&gt;
&lt;p&gt;Well, I thought I would run my &lt;b&gt;Set-StaticIPAddress&lt;/b&gt; script on the machine to set the address, but there were two problems:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The script execution policy in my Exchange Server does not permit the running of scripts.&lt;/li&gt;
&lt;li&gt;The server is completely isolated and cannot contact my script share.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So what can I do? Well, I opened the Windows PowerShell ISE and typed the commands that follow into the script pane.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;strong&gt;SetStaticIP.ps1&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi = Get-WmiObject win32_networkadapterconfiguration -filter &amp;quot;ipenabled = &amp;#39;true&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi.EnableStatic(&amp;quot;10.0.0.15&amp;quot;, &amp;quot;255.255.255.0&amp;quot;)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi.SetGateways(&amp;quot;10.0.0.1&amp;quot;, 1)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi.SetDNSServerSearchOrder(&amp;quot;10.0.0.100&amp;quot;)&lt;/p&gt;
&lt;p&gt;This is the cool part, even when the Windows PowerShell script execution policy it set to &lt;i&gt;Restricted&lt;/i&gt;, which disallows the execution of scripts, it is still possible to open the Windows PowerShell ISE and run commands. This technique allowed me to type the four previous commands, and to execute them all at once.&lt;/p&gt;
&lt;p&gt;What do the four previous commands do?&lt;/p&gt;
&lt;p&gt;The first command uses the &lt;b&gt;Get-WmiObject &lt;/b&gt;cmdlet to retrieve the network adapter configuration for all the network adapters that are enabled for use with IP. To do this, I use the &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394217(v=vs.85).aspx"&gt;Win32_NetworkAdapterConfiguration&lt;/a&gt; WMI class. This class has a number of extremely useful methods&amp;mdash;that is, it can do a lot! I store the resulting object in a variable I called &lt;b&gt;$wmi&lt;/b&gt;. This line of code is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi = Get-WmiObject win32_networkadapterconfiguration -filter &amp;quot;ipenabled = &amp;#39;true&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p&gt;When the network adapter configuration object is stored in the &lt;b&gt;$wmi&lt;/b&gt; variable, it is easy to use the following three methods: &lt;b&gt;EnableStatic&lt;/b&gt;, &lt;b&gt;SetGateways&lt;/b&gt;, and &lt;b&gt;SetDnsServerSearchOrder&lt;/b&gt;&lt;i&gt;. &lt;/i&gt;All that is required is to supply the required values. The &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa390383(v=vs.85).aspx"&gt;EnableStatic&lt;/a&gt; method requires the static IP address in addition to a subnet mask. Each of these values are strings. The &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa393301(v=vs.85).aspx"&gt;SetGateways&lt;/a&gt;&lt;i&gt; &lt;/i&gt;method also requires two strings. The first parameter is the IP address of the gateway, and the second parameter is the metric. The last method I used is the &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa393295(v=vs.85).aspx"&gt;SetDnsServerSearchOrder&lt;/a&gt; method.&lt;i&gt; &lt;/i&gt;This code is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi.EnableStatic(&amp;quot;10.0.0.15&amp;quot;, &amp;quot;255.255.255.0&amp;quot;)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi.SetGateways(&amp;quot;10.0.0.1&amp;quot;, 1)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$wmi.SetDNSServerSearchOrder(&amp;quot;10.0.0.100&amp;quot;)&lt;/p&gt;
&lt;p&gt;The figure that is shown here illustrates the four lines of code, and the output from those commands.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5238.hsg_2D00_2_2D00_28_2D00_12_2D00_01.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5238.hsg_2D00_2_2D00_28_2D00_12_2D00_01.png" alt="Image of command output" title="Image of command output" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When I ran the code, I could verify the IP address via the GUI tool. The actual IP configuration is shown here.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/8686.hsg_2D00_2_2D00_28_2D00_12_2D00_02.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/8686.hsg_2D00_2_2D00_28_2D00_12_2D00_02.png" alt="Image of IP properties" title="Image of IP properties" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I am not sure why the race condition appeared in my Exchange Server. My guess is that it was trying &lt;i&gt;really &lt;/i&gt;hard to contact domain controllers, DNS servers and the like, and it was unable to do so because of the IP changes. When I fixed the problem, Exchange Server settled down. The cool thing is that I was able to use Windows PowerShell to fix the problem, even though I could not run a script. The four commands I used are the essence of a script, but because I did not save them as a .ps1 file prior to execution, Windows PowerShell saw them as just another group of commands.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3483194" width="1" height="1" alt="" /&gt;</description></item><item><title>Use PowerShell to Test Connectivity on Remote Servers</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2012/02/24/use-powershell-to-test-connectivity-on-remote-servers.aspx</link><pubDate>Fri, 24 Feb 2012 06:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:14883</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;: Microsoft Scripting Guy talks about using Windows PowerShell to test connectivity after a network configuration change.&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. It seems that there are always good news/bad news&lt;i&gt; &lt;/i&gt;types of scenarios. After months of trying to obtain faster Internet connectivity at the house, I finally found a source that doubled the upload and download speeds for the Scripting Wife and I, at literally half the price we had been paying. Talk about a deal. Talk about not just good news&lt;i&gt;, &lt;/i&gt;but GREAT NEWS&lt;i&gt;. &lt;/i&gt;Now for the bad news&lt;i&gt; &lt;/i&gt;part of the equation&amp;hellip;&lt;/p&gt;
&lt;p&gt;The router they showed up with at the house&amp;mdash;part of the free installation&amp;mdash;would not accept a static IP address on the Ethernet side of the equation that was compatible with my current network configuration&amp;mdash;and I have a relatively complex configuration that involves multiple subnets.&lt;/p&gt;
&lt;h2&gt;Writing a quick script to ensure connectivity&lt;/h2&gt;
&lt;p&gt;When I ran into problems, I decided to write a really quick script to ping the most critical servers on my network to ensure connectivity. I wanted to ensure that DNS resolution worked, so I did the ping by name instead of by IP address. I manually created an array of computer names that I stored in a variable called &lt;b&gt;$servers&lt;/b&gt;. To walk through the array of servers, I used the &lt;b&gt;ForEach&lt;/b&gt;&lt;i&gt; &lt;/i&gt;statement. The &lt;b&gt;$s&lt;/b&gt; variable represents the actual computer name inside the loop. This is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$servers = &amp;quot;dc1&amp;quot;,&amp;quot;dc3&amp;quot;,&amp;quot;sql1&amp;quot;,&amp;quot;wds1&amp;quot;,&amp;quot;ex1&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Foreach($s in $servers)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;{&lt;/p&gt;
&lt;p&gt;To ping the computers, I use the &lt;b&gt;Test-Connection &lt;/b&gt;cmdlet. In the definition of the &lt;b&gt;Test-Connection &lt;/b&gt;command, I determine the buffer size, the number of pings to submit, and whether it returns detailed ping status information or a simple Boolean value. I specify the &lt;i&gt;ea &lt;/i&gt;parameter (&lt;i&gt;ea &lt;/i&gt;is an alias for the &lt;i&gt;ErrorAction &lt;/i&gt;parameter) value of 0. The value of 0 tells the cmdlet to not display error information (an error displays when a ping is unsuccessful).&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;For more information about using the &lt;b&gt;Test-Connection&lt;/b&gt;, cmdlet refer to &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#comments" target="_blank"&gt;Query AD for Computers and Use Ping to Determine Status&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Because the cmdlet returns a Boolean value, I am able to simplify the code a bit. I therefore state that if the command does not return a True value, I want to perform additional actions. This portion of the script is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; {&lt;/p&gt;
&lt;p&gt;Because I am hiding errors that are returned from the &lt;b&gt;Test-Connection &lt;/b&gt;cmdlet, I decided to display my own status information. I print out a message that lets me know a problem occurs with reaching the computer. I then decide to run three commands. The first flushes the DNS cache, the second updates the DNS registration, and the third performs an &lt;b&gt;NSLookup&lt;/b&gt; on the server. Finally, I ping the computer again. This portion of the script is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;quot;Problem connecting to $s&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;Flushing DNS&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; ipconfig /flushdns | out-null&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;Registering DNS&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; ipconfig /registerdns | out-null&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;doing a NSLookup for $s&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; nslookup $s&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;Re-pinging $s&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;quot;Problem still exists in connecting to $s&amp;quot;}&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE {&amp;quot;Resolved problem connecting to $s&amp;quot;} #end if&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; } # end if&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;} # end foreach&lt;/p&gt;
&lt;p&gt;When I ran the PingTest.ps1 script on my computer, the following output appeared in the Windows PowerShell ISE.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5383.hsg_2D00_2_2D00_24_2D00_12_2D00_1.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5383.hsg_2D00_2_2D00_24_2D00_12_2D00_1.png" alt="Image of command output" title="Image of command output" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The complete PingTest.ps1 script is shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;strong&gt;PingTest.PS1&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$servers = &amp;quot;dc1&amp;quot;,&amp;quot;dc3&amp;quot;,&amp;quot;sql1&amp;quot;,&amp;quot;wds1&amp;quot;,&amp;quot;ex1&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Foreach($s in $servers)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;{&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; {&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;Problem connecting to $s&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;Flushing DNS&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; ipconfig /flushdns | out-null&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;Registering DNS&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; ipconfig /registerdns | out-null&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; &amp;quot;doing a NSLookup for $s&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; nslookup $s&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; &amp;quot;Re-pinging $s&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;quot;Problem still exists in connecting to $s&amp;quot;}&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE {&amp;quot;Resolved problem connecting to $s&amp;quot;} #end if&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp; } # end if&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;} # end foreach&lt;/p&gt;
&lt;p&gt;This script took me less than five minutes to write, and it saved me much more time than that if I had to do a lot of manual troubleshooting. If I needed the output to a text file, I would have called the script from the Windows PowerShell console and redirected the output to a text file. I did not need to do that, but it would have been simple.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;For more information about writing to text files, see &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/17/scripting-wife-learns-to-work-with-text-files.aspx" target="_blank"&gt;The Scripting Wife Learns to Work with Text Files&lt;i&gt;.&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If I needed to run the script from each of the critical servers (so they could check for connectivity to each other), I would have copied the script to a network share, and then used Windows PowerShell remoting to run the script on each of the servers. I would also have redirected the output to a text file, but in this example, I would have used a text file on the same network share as the script.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;For more information about Windows PowerShell remoting, see &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/remoting/" target="_blank"&gt;these Hey, Scripting Guy! blogs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I invite you back tomorrow for the Weekend Scripter, when I will talk about copying Windows PowerShell Scripts to a network share.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3482818" width="1" height="1" alt="" /&gt;</description></item><item><title>Weekend Scripter: Use a Free PowerShell Module to Ease DNS Administration</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2010/10/24/weekend-scripter-use-a-free-powershell-module-to-ease-dns-administration.aspx</link><pubDate>Sun, 24 Oct 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7979</guid><dc:creator>Anonymous</dc:creator><description>Summary: Learn how to use a free Windows PowerShell module to ease administration of Windows DNS. Microsoft Scripting Guy Ed Wilson here. I have been talking to Chris Dent for several months now, and I finally convinced him to write a guest blog for me...(&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/24/weekend-scripter-use-a-free-powershell-module-to-ease-dns-administration.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3363503" width="1" height="1" alt="" /&gt;</description></item><item><title>Manage DNS in a Windows Environment by Using PowerShell</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2010/09/13/manage-dns-in-a-windows-environment-by-using-powershell.aspx</link><pubDate>Mon, 13 Sep 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7588</guid><dc:creator>Anonymous</dc:creator><description>Summary : Manage DNS in a Windows environment by using Windows PowerShell. Guest Blogger Richard Siddaway shows how to do it in a simple and effective manner. &amp;#160; Hey, Scripting Guy! What can I do with Windows PowerShell to manage my DNS infrastructure...(&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/13/manage-dns-in-a-windows-environment-by-using-powershell.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3354366" width="1" height="1" alt="" /&gt;</description></item></channel></rss>