{"id":186,"date":"2013-01-30T17:18:40","date_gmt":"2013-01-31T00:18:40","guid":{"rendered":"http:\/\/www.Get-Blog.com\/?p=186"},"modified":"2013-01-30T17:18:40","modified_gmt":"2013-01-31T00:18:40","slug":"quick-tips-counting-in-powershell","status":"publish","type":"post","link":"http:\/\/www.Get-Blog.com\/?p=186","title":{"rendered":"Quick Tips: Counting in PowerShell"},"content":{"rendered":"<p>If you&#8217;re like me, sometimes you just feel like counting.  Well, in PowerShell you can count easier than ever before!  PowerShell gives you ability to not only easily increment, but also run code for each increment because you can pipe!  First, let&#8217;s take a look at the basic code:<\/p>\n<pre class=\"theme:psconsole lang:ps decode:true \" title=\"Counting Up\" >PS C:&gt; 1..5\n1\n2\n3\n4\n5<\/pre>\n<pre class=\"theme:psconsole lang:ps decode:true \" title=\"Counting from 5\" >PS C:&gt; 5..7\n5\n6\n7<\/pre>\n<p>And why limit yourself to counting up?!  You can even decrement those numbers:<\/p>\n<pre class=\"theme:psconsole lang:ps decode:true \" title=\"Counting Down\" >PS C:&gt; 6..3\n6\n5\n4\n3<\/pre>\n<p>So, how can you use this?  Well, remember the wonderful thing called a pipeline.  You can potentially ping an entire subnet with the following command:<\/p>\n<pre class=\"theme:psconsole lang:ps decode:true \" title=\"Pinging a Subnet\" >1..254 | % {ping 192.168.1.$_}<\/pre>\n<p>Remember, if that command takes too long, you could consider multithreading it with one of the scripts on this site!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re like me, sometimes you just feel like counting. Well, in PowerShell you can count easier than ever before! PowerShell gives you ability to not only easily increment, but also run code for each increment because you can pipe! First, let&#8217;s take a look at the basic code: PS C:&gt; 1..5 1 2 3 <a href='http:\/\/www.Get-Blog.com\/?p=186' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4,5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/posts\/186"}],"collection":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=186"}],"version-history":[{"count":0,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}