{"id":290080,"date":"2021-07-02T18:00:00","date_gmt":"2021-07-02T15:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/what-is-infrastructure-testing-and-how-to-do-it-with-powershell-cloudsavvy-it\/"},"modified":"2021-07-02T18:00:00","modified_gmt":"2021-07-02T15:00:00","slug":"what-is-infrastructure-testing-and-how-to-do-it-with-powershell-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/what-is-infrastructure-testing-and-how-to-do-it-with-powershell-cloudsavvy-it\/","title":{"rendered":"#What Is Infrastructure Testing and How to Do It with PowerShell \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a27636dcbbc8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a27636dcbbc8\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/what-is-infrastructure-testing-and-how-to-do-it-with-powershell-cloudsavvy-it\/#What_Is_Infrastructure_Testing\" >What Is Infrastructure Testing?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/what-is-infrastructure-testing-and-how-to-do-it-with-powershell-cloudsavvy-it\/#Testing_a_Network_Port\" >Testing a Network Port<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/what-is-infrastructure-testing-and-how-to-do-it-with-powershell-cloudsavvy-it\/#Testing_DNS_Name_Resolution\" >Testing DNS Name Resolution<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/what-is-infrastructure-testing-and-how-to-do-it-with-powershell-cloudsavvy-it\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What Is Infrastructure Testing and How to Do It with PowerShell \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-4374\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/03\/23e4a5a4.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Powershell logo\" width=\"1400\" height=\"578\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>As we all try to do more with less with automation, we sometimes get to a point where we\u2019ve got a new problem. We\u2019re now running so many <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">script<\/a>s and processes that, in the end, we\u2019re not sure what \u201cdone\u201d looks like<\/p>\n<p>If we\u2019re running a user provisioning script that creates an AD (Active Directory) user, an Exchange mailbox, or a home folder, how do we truly know that script did everything it was supposed to? We don\u2019t. We can notice that there wasn\u2019t an error thrown and also spot-check things afterward. But if the script is covering 1,000 users, there\u2019s no way that\u2019s going to be feasible. We need to use test automation, too!<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Is_Infrastructure_Testing\"><\/span>What Is Infrastructure Testing?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One way to automate this kind of testing is with what is loosely called infrastructure testing. What is infrastructure testing? It means any code that reads configuration values from various things in the IT environment and compares them to expected values.<\/p>\n<p>Some examples of infrastructure testing include:<\/p>\n<ul>\n<li>\u201cWas that AD user created with the right attributes?\u201d<\/li>\n<li>\u201cIs port 80 responding on my webserver?\u201d<\/li>\n<li>\u201cIs the DHCP service running?\u201d<\/li>\n<\/ul>\n<p>The infrastructure-testing discussion is much bigger than we have time for in a single article, but I can give you a head start. As you begin writing these tests, you\u2019ll start to notice patterns; you\u2019ll start to realize that you\u2019re repeatedly writing the same kind of code, just applied to different things. Rather than copying and pasting all the time you can share this code in the form of a PowerShell script or function.<\/p>\n<p>Let\u2019s go over a couple of common examples of scripts that I use to help me ensure my infrastructure is configured appropriately.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Testing_a_Network_Port\"><\/span>Testing a Network Port<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One typical example of an infrastructure test is testing a network port. Because all network services open up and listen on a particular port, a real test of if that service is \u201cup\u201d or not is to confirm that a specific port is available to remote computers. To build this test, though, requires a fair amount of knowledge about TCP, UDP, and .NET. Luckily, you can use an existing script from the community called <em>Test-NetworkPort.ps1<\/em>. This script can be downloaded from the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.powershellgallery.com\/packages\/Test-NetworkPort\/1.0\/DisplayScript\">PowerShell Gallery<\/a> by running <code>Install-Script -Name Test-NetworkPort<\/code>.<\/p>\n<p>Once downloaded, simply call it by using <em>Test-NetworkPort.ps1<\/em> and pass a computer name and port to test.<\/p>\n<pre><code>PS &gt; Test-NetworkPort.ps1 -ComputerName DC -Port 389&#13;\nTrue&#13;\n<\/code><\/pre>\n<p>Depending on if the port is listening or not, this script will return <code>True<\/code> or <code>False<\/code>. You can explore other parameters this script has by reading the help associated with it via <code>Get-Help Test-NetworkPort.ps1<\/code>.<\/p>\n<p>This script performs a <em>test<\/em> on the <em>infrastructure<\/em> listening on a particular port.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Testing_DNS_Name_Resolution\"><\/span>Testing DNS Name Resolution<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When bringing up a new machine, whether relying on dynamic DNS to register the name or if you\u2019re creating a DNS record explicitly, you\u2019re going to need to ensure its name can be resolved. With PowerShell, you can use a script that attempts to resolve a particular name and return <code>True<\/code> or <code>False<\/code> if it can be resolved or not.<\/p>\n<p>As with our port testing example, we can also download this script from the PowerShell Gallery as well via <code>Install-Script -Name Test-DnsNameResolution<\/code>.<\/p>\n<p>When the download has completed, simply call <em>Test-DnsNameResolution.ps1<\/em> with the name and the DNS server you\u2019d like to query.<\/p>\n<pre><code>PS&gt; Test-DnsNameResolution.ps1 -Name DC.mylab.local -Server DC&#13;\nFalse&#13;\n<\/code><\/pre>\n<p>If the script returns <code>True<\/code>, the DNS server <em>DC<\/em> can resolve the name of <em>DC.mylab.local<\/em>. If not, it would have returned <code>False<\/code>.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The examples provided here are just two amongst thousands. The point of this article isn\u2019t to show you you <em>how<\/em> to to perform infrastructure tests but more to guide you on creating your own.<\/p>\n<p>To create well-developed infrastructure tests requires first defining what it means to be \u201cup\u201d or \u201cexpected\u201d, building a PowerShell script to find the current and expected state, and to make a decision from there.<\/p>\n<p>Don\u2019t continue to manually confirm your infrastructure is working as you expect. Get to building some PowerShell scripts and automate those mundane processes for you!\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/4424\/what-is-infrastructure-testing-and-how-to-do-it-with-powershell\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What Is Infrastructure Testing and How to Do It with PowerShell \u2013 CloudSavvy IT&#8221; As we all try to do more with less with automation, we sometimes get to a point where we\u2019ve got a new problem. We\u2019re now running so many scripts and processes that, in the end, we\u2019re not sure what \u201cdone\u201d looks&#8230;<\/p>\n","protected":false},"author":1,"featured_media":290081,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/03\/23e4a5a4.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-290080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/290080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=290080"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/290080\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/290081"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=290080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=290080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=290080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}