<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6313390886970291384</id><updated>2012-01-28T10:54:03.960-08:00</updated><category term='netstat tasklist Windows Vista'/><category term='Powershell:  Query GAC'/><category term='System.Net.NetworkInformation.IcmpV4Statistic;System.Net.NetworkInformation.IPGlobalStatistics;Win32_PerfFormattedData_Tcpip_NetworkInterface;'/><category term='Displaying IP Addresses'/><category term='6005..6009'/><category term='Message'/><category term='Query .NET Collections'/><category term='powershell;MidpSSh 1.7'/><category term='Powershell'/><category term='Powershell: Query .NET'/><category term='Cygwin'/><category term='Powershell: range operators'/><category term='Powershell: TcpState'/><category term='Josh Einstein'/><category term='performance testing with ps'/><category term='tcpvcon;tasklist;'/><category term='Parsing Event logs'/><category term='Threads'/><category term='Security'/><category term='System.Diagnostics.EventLogEntryType'/><category term='PSUserTools'/><category term='system reliability'/><category term='Powershell: Ping IP Ranges'/><category term='compare-object'/><category term='Powershell: Sequential File and Directory Creation'/><category term='Powershell: NetCmdlets; Ping Subnet;IP'/><category term='Blackberry'/><category term='get-variable'/><category term='cmd.exe; powershell; here string;Start-Process'/><category term='isolating &apos;get-counter&apos; data'/><category term='trace-command'/><category term='nmcap;logparser;Powershell;IP String Searches'/><category term='uptime'/><category term='Console'/><category term='Array to Hash'/><category term='Test-Commection GWMI Measure-object'/><category term='PS;modules;memory'/><category term='Modules'/><category term='OPENBSD'/><category term='PS'/><category term='Powershell: CMD.exe v Powershell'/><category term='NBT'/><category term='[System.Net.DNS]::Resolve'/><category term='while construct'/><category term='CTP3'/><category term='InputObject.LocalEndPoint'/><category term='Powershell: Split'/><category term='read-host'/><category term='Jaykul Bennett'/><category term='Measure-Object'/><category term='netstat'/><category term='.Address'/><category term='arrays'/><category term='CMD.EXE'/><category term='scope'/><category term='Powershell: Start folder;cmd.exe.'/><category term='Powershell:  get-eventlog;date parsing'/><category term='Debug Print'/><category term='Powershell:tlist substitute;get-process;find-modules;FileVersion;FileVersionInfo;loaded dlls'/><category term='GetIPGlobalProperties()'/><category term='Meta-File'/><category term='Replace'/><category term='Finding Time;Get-WmiObject -class Win32_PerfFormattedData_PerfOS_System;Get-WmiObject -class Win32_OperatingSystem;LastBootUpTime;LocalDateTime;uptime.exe;[DateTime];UTC;'/><category term='CMD.EXE: IP'/><category term='GetMembers'/><category term='Subnet Range Finder'/><category term='Powershel: Hristo Deshev'/><category term='Event ID 36'/><category term='Powershell:  AWK: Querying Authlogs'/><category term='Snort'/><category term='Powershell GUI'/><category term='Editing In-Line'/><category term='$$ functional programming'/><category term='Powershell: Firewall'/><category term='shutdown'/><category term='Powershell time-stamping logging'/><category term='meta-programming;Parameters;Create-Metadata;trace-command'/><category term='Failure Analysis'/><category term='Script Block'/><category term='Process'/><category term='Exif'/><category term='ping multiple subnets'/><category term='PowerTab'/><category term='log queries'/><category term='Compound Assignment;'/><category term='MemberTypes'/><category term='Powershell:  EXIF'/><category term='System.Diagnostics.EventLog'/><category term='Powershell: Network Info from Win32_NetworkAdapterConfiguration'/><category term='brilliant coders'/><category term='lsof tcpview.exe netstat -bno'/><category term='DOS'/><title type='text'>Horizontal Logic</title><subtitle type='html'>Random Notes on Learning .NET Powershell C#. I publish as I learn. This
gives the blog a scratch quality. Starting with Powershell. A script
repository is at &lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts"&gt;www.rmfdevelopment.com/PowerShell_Scripts&lt;/a&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>61</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2609822542610244481</id><published>2012-01-05T07:03:00.001-08:00</published><updated>2012-01-05T11:51:34.771-08:00</updated><title type='text'>Two methods to query psdrives</title><content type='html'>Both the methods below will query remote and local drives of all types:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-SBEXBe4Dktk/TwX_LYqvHfI/AAAAAAAAIbY/7j7d9LIXckc/s1600/get-psdrive.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="230" src="http://3.bp.blogspot.com/-SBEXBe4Dktk/TwX_LYqvHfI/AAAAAAAAIbY/7j7d9LIXckc/s640/get-psdrive.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2609822542610244481?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2609822542610244481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2609822542610244481&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2609822542610244481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2609822542610244481'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2012/01/ps-cps1-get-psdrive-where.html' title='Two methods to query psdrives'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-SBEXBe4Dktk/TwX_LYqvHfI/AAAAAAAAIbY/7j7d9LIXckc/s72-c/get-psdrive.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2327827075898790063</id><published>2012-01-04T23:12:00.001-08:00</published><updated>2012-01-04T23:12:53.211-08:00</updated><title type='text'>Parse TCP and UDP ports from services file</title><content type='html'>&lt;br /&gt;&lt;br /&gt;# Parses TCP and UDP ports from services file on Windows 7&lt;br /&gt;&lt;br /&gt;$a=gc C:\Windows\System32\drivers\etc\services&lt;br /&gt;$tcp=$a | sls tcp&lt;br /&gt;$udp=$a | sls udp&lt;br /&gt;&lt;br /&gt;[array[]]$tcp=0..(($tcp.count) -1) | % { (($tcp.GetValue($_) -split("/"))[0])}&lt;br /&gt;[array[]]$udp=0..(($udp.count) -1) | % { (($udp.GetValue($_) -split("/"))[0])}&lt;br /&gt;&lt;br /&gt;[array[]]$tcp_service_ports=0..(($tcp.count) -1) | % { (($tcp.GetValue($_) -split(" "))[-1])}&lt;br /&gt;[array[]]$udp_service_ports=0..(($udp.count) -1) | % { (($udp.GetValue($_) -split(" "))[-1])}&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2327827075898790063?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2327827075898790063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2327827075898790063&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2327827075898790063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2327827075898790063'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2012/01/parse-tcp-and-udp-ports-from-services.html' title='Parse TCP and UDP ports from services file'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-6445103511174714308</id><published>2012-01-04T23:10:00.000-08:00</published><updated>2012-01-06T20:19:38.797-08:00</updated><title type='text'>Count the number of binaries in your path</title><content type='html'>Powershell 3.0 CTP2&lt;br /&gt;&lt;br /&gt;Count the number of binaries in your path:&lt;br /&gt;&lt;br /&gt;([System.Environment]::GetEnvironmentVariables().Path -split(";") |% { ls $_ *.exe}).count&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-6445103511174714308?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/6445103511174714308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=6445103511174714308&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6445103511174714308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6445103511174714308'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2012/01/count-number-of-binaries-in-you-path.html' title='Count the number of binaries in your path'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-6206066688193788374</id><published>2011-09-03T14:14:00.000-07:00</published><updated>2011-09-03T14:24:21.731-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Compound Assignment;'/><title type='text'>Compound variable assignment as [array[]] based storage</title><content type='html'>Below is a function I have written to demonstrate a function which recursively checks ownership and access for files modified within a given time span. What I call to your attention is the ability to use the assignment operator ('+=') to store data recursively as highlighted in salmon. &amp;nbsp;This is mentioned in 'about_assignment_operators' in the help for Powershell V2:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;"&amp;nbsp;&lt;i&gt;When the value of the variable is an array, the += operator appends the&lt;br /&gt;&amp;nbsp;values on the right side of the operator to the array. Unless the array is&lt;br /&gt;&amp;nbsp;explicitly typed by casting, you can append any type of value to the array..."&lt;/i&gt;&lt;/blockquote&gt;In the second part of the script below, I pump the results of a foreach loop into an explicitly typed compound assignment variable ("$RecurseList"):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="background-color: #ea9999;"&gt;[Array[]]$RecurseList +=  foreach ($folder in $Recurse) {...&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;"&gt;This structure almost shows some 'lambda' like functionality, enabling the Powershell programmer to operate on a series of objects, return and store values back to the pipeline which can be collected later in the same function for further operations.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Check-RecentAccessCombined&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;br /&gt;[CmdletBinding()]&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;Param&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;br /&gt;        [Parameter(ValueFromPipeline&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;)]&lt;br /&gt;           [&lt;/span&gt;&lt;span style="color: teal;"&gt;int&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$days&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;        [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$ErrorActionPreference&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;SilentlyContinue&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;    )&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: purple;"&gt;$RecurseList&lt;/span&gt;&lt;span style="color: black;"&gt;) {&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Clear-variable&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;RecurseList&lt;/span&gt;&lt;span style="color: black;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$host&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;UI&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;RawUI&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;BufferSize&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;new-object&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;System.Management.Automation.Host.Size&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;500&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;/span&gt;&lt;span style="color: black;"&gt;9999&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$Global:StartTime&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;get-date&lt;/span&gt;&lt;span style="color: black;"&gt;) &lt;/span&gt;&lt;span style="color: red;"&gt;-&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;new-timespan&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-days&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$days&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$Global:Current&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$pwd&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$List&lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;gci&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;*&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;where&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: red;"&gt;!&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.psiscontainer}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$Query&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;foreach&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: purple;"&gt;$i&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$List&lt;/span&gt;&lt;span style="color: black;"&gt;) { &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;gci&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$i&lt;/span&gt;&lt;span style="color: black;"&gt; |&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Select&lt;/span&gt;&lt;span style="color: black;"&gt; FullName,*Time, @{Label&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Access&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;;Expression&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;get-acl&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.PSChildName| &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;%&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.AccessToString}}}, @{Label&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Owner&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;;Expression&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;get-acl&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.PSChildName| &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;%&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.Owner}}}}&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #ea9999;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: #ea9999;"&gt;&lt;span style="color: teal;"&gt;Array&lt;/span&gt;&lt;span style="color: black;"&gt;[]]&lt;/span&gt;&lt;span style="color: purple;"&gt;$Global:RecurseList&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;+=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$Query&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Select&lt;/span&gt;&lt;span style="color: black;"&gt; LastAccessTime,CreationTime,FullName,Owner,Access| &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;where&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.LastAccessTime &lt;/span&gt;&lt;span style="color: red;"&gt;-gt&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$StartTime&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="background-color: #ea9999;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: #ea9999;"&gt;$Global:Recurse=&lt;span style="font-weight: bold;"&gt;ls&lt;/span&gt; &lt;span style="font-style: italic;"&gt;-recurse&lt;/span&gt; * | &lt;span style="font-weight: bold;"&gt;where&lt;/span&gt; {$_.PSISContainer}&lt;br /&gt;[Array[]]$RecurseList +=  foreach ($folder in $Recurse) {&lt;br /&gt;    &lt;span style="font-weight: bold;"&gt;sl&lt;/span&gt; $folder.FullName;&lt;br /&gt;    # $folder.FullName&lt;br /&gt;    $List=&lt;span style="font-weight: bold;"&gt;gci&lt;/span&gt; * | &lt;span style="font-weight: bold;"&gt;where&lt;/span&gt; {!$_.psiscontainer};&lt;br /&gt;    $Query= $List |&lt;span style="font-weight: bold;"&gt;Select&lt;/span&gt; FullName,*Time,@{Label="Access";Expression={&lt;span style="font-weight: bold;"&gt;get-acl&lt;/span&gt; $_.PSChildName| &lt;span style="font-weight: bold;"&gt;%&lt;/span&gt; {$_.AccessToString}}}, @{Label="Owner";Expression={&lt;span style="font-weight: bold;"&gt;get-acl&lt;/span&gt; $_.PSChildName| &lt;span style="font-weight: bold;"&gt;%&lt;/span&gt; {$_.Owner}}};&lt;br /&gt;    $Query | &lt;span style="font-weight: bold;"&gt;Select&lt;/span&gt; LastAccessTime,CreationTime,FullName,Owner,Access| &lt;span style="font-weight: bold;"&gt;where&lt;/span&gt; {$_.LastAccessTime -gt $StartTime}; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: #ea9999;"&gt;&lt;br /&gt;    } &lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;sl&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$Current&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$RecurseList&lt;/span&gt;&lt;span style="color: black;"&gt;  | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Sort&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-descending&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;LastAccessTime&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-6206066688193788374?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/6206066688193788374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=6206066688193788374&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6206066688193788374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6206066688193788374'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2011/09/compound-variable-assignment-as-array.html' title='Compound variable assignment as [array[]] based storage'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-7148611201374500886</id><published>2011-08-24T11:40:00.000-07:00</published><updated>2011-08-30T08:30:10.499-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='isolating &apos;get-counter&apos; data'/><title type='text'>Storing 'Get-counter' data</title><content type='html'>You can do this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;((get-counter -counter '\\rmfvpc\TCPv4\Connections Established').countersamples) | % {$_.CookedValue}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;and this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;(get-counter -counter '\\rmfvpc\TCPv4\Connections Established').Readings | findstr ^[0-9]&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;and this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;(get-counter -counter '\\rmfvpc\TCPv4\Connections Established' -continuous -sampleinterval 2)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;but you can't do this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;(get-counter -counter '\\rmfvpc\TCPv4\Connections Established' -continuous -sampleinterval 2).countersamples&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;or this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;(get-counter -counter '\\rmfvpc\TCPv4\Connections Established' -continuous -sampleinterval 2).Readings&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;or this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;[array]$a=(get-counter -counter '\\rmfvpc\TCPv4\Connections Established' -continuous -sampleinterval 2)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Therefore I ended up with this (which works):&lt;br /&gt;&lt;br /&gt;&lt;b&gt;while($true) {foreach ($i in (get-counter -counter '\\rmfvpc\TCPv4\Connections Established')) {$i.Readings | findstr ^[0-9]};sleep -seconds 2}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;or this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;while($true) {foreach ($i in (get-counter -counter '\\rmfvpc\TCPv4\Connections Established')) {$i.countersamples | % {$_.CookedValue}};sleep -seconds 2}&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;and one these (which also works):&lt;br /&gt;&lt;br /&gt;&lt;b&gt;while($true) {[array]$b+=foreach ($i in (get-counter -counter '\\rmfvpc\TCPv4\Connections Established').countersamples) {$i | % {$_.CookedValue}};sleep -seconds 2}&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&amp;nbsp;while($true) {[array]$b+=foreach ($i in (get-counter -counter '\\rmfvpc\TCPv4\Connections Established')) {$i.Readings | findstr ^[0-9]};sleep -seconds 2}&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;$b&lt;br /&gt;3&lt;br /&gt;3&lt;br /&gt;3&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;But it all seems just a little ungainly! &amp;nbsp;Here's how I got there:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;get-counter -ListSet * | findstr "CounterSetName" | Sort&lt;/b&gt;&lt;br /&gt;CounterSetName &amp;nbsp; &amp;nbsp; : .NET CLR Data&lt;br /&gt;...&lt;br /&gt;CounterSetName &amp;nbsp; &amp;nbsp; : .NET Memory Cache 4.0&lt;br /&gt;...&lt;br /&gt;CounterSetName &amp;nbsp; &amp;nbsp; : ASP.NET v4.0.30319&lt;br /&gt;CounterSetName &amp;nbsp; &amp;nbsp; : Authorization Manager Applications&lt;br /&gt;...&lt;br /&gt;CounterSetName &amp;nbsp; &amp;nbsp; : Browser&lt;br /&gt;CounterSetName &amp;nbsp; &amp;nbsp; : Cache&lt;br /&gt;CounterSetName &amp;nbsp; &amp;nbsp; : Database&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;(get-counter -ListSet Memory).Counter &amp;nbsp;| Sort&lt;/b&gt;&lt;br /&gt;\Memory\% Committed Bytes In Use&lt;br /&gt;\Memory\Available Bytes&lt;br /&gt;\Memory\Available KBytes&lt;br /&gt;...&lt;br /&gt;\Memory\Free &amp;amp; Zero Page List Bytes&lt;br /&gt;\Memory\Free System Page Table Entries&lt;br /&gt;\Memory\Modified Page List Bytes&lt;br /&gt;...&lt;br /&gt;&lt;b&gt;(get-counter -ListSet 'TCPv4').Paths &amp;nbsp;| Sort&lt;/b&gt;&lt;br /&gt;\TCPv4\Connection Failures&lt;br /&gt;\TCPv4\Connections Active&lt;br /&gt;\TCPv4\Connections Established&lt;br /&gt;\TCPv4\Connections Passive&lt;br /&gt;\TCPv4\Connections Reset&lt;br /&gt;\TCPv4\Segments Received/sec&lt;br /&gt;\TCPv4\Segments Retransmitted/sec&lt;br /&gt;\TCPv4\Segments Sent/sec&lt;br /&gt;\TCPv4\Segments/sec&lt;br /&gt;&lt;br /&gt;&lt;b&gt;get-counter -counter '\\rmfvpc\TCPv4\Connections Established' -continuous -sampleinterval 10&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Timestamp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CounterSamples&lt;br /&gt;--------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --------------&lt;br /&gt;8/24/2011 10:36:24 AM &amp;nbsp; &amp;nbsp; \\rmfvpc\tcpv4\connections established :&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;8/24/2011 10:36:34 AM &amp;nbsp; &amp;nbsp; \\rmfvpc\tcpv4\connections established :&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;br /&gt;&lt;br /&gt;Update 08/30/2011:&lt;br /&gt;&lt;br /&gt;This one liner:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;while($true) {foreach ($i in (get-counter -counter '\\rmfvpc\TCPv4\Connections Established')) {write-host -backgroundcolor red "$($i.countersamples | % {$_.CookedValue}) Established Connections"};sleep -seconds 2;clear}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;produces a nice&amp;nbsp;flashing&amp;nbsp;update of the number of TCPv4 connections. Looks like this:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-PVvyiX-eBF0/Tl0B4rHW4VI/AAAAAAAAIHA/UFR_2lkKN-c/s1600/EstablishedConnections.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="101" src="http://1.bp.blogspot.com/-PVvyiX-eBF0/Tl0B4rHW4VI/AAAAAAAAIHA/UFR_2lkKN-c/s400/EstablishedConnections.JPG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-7148611201374500886?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/7148611201374500886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=7148611201374500886&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7148611201374500886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7148611201374500886'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2011/08/storing-get-counter-data.html' title='Storing &apos;Get-counter&apos; data'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-PVvyiX-eBF0/Tl0B4rHW4VI/AAAAAAAAIHA/UFR_2lkKN-c/s72-c/EstablishedConnections.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-7118253583491481738</id><published>2011-08-22T01:29:00.000-07:00</published><updated>2011-08-22T01:29:57.965-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Modules'/><category scheme='http://www.blogger.com/atom/ns#' term='PSUserTools'/><title type='text'>Some addendum on modules</title><content type='html'>If you add modules like&amp;nbsp;&lt;a href="http://archive.msdn.microsoft.com/PowerShellPack"&gt;&amp;nbsp;PSUserTools&lt;/a&gt;&amp;nbsp;from Microsoft you receive some enhanced functionality. You also receive some well conceived script. &amp;nbsp;After you have imported your modules ('import-module'), you can use a function like that below to list all the exported commands:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;i&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Global:get-module_exports&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;nbsp;{&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;[CmdletBinding()]&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;i&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;Param&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;i&gt;&lt;span style="color: black;"&gt;[Parameter(Mandatory&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;)]&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;i&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$ModName&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;i&gt;&lt;span style="color: purple;"&gt;$commands&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;&lt;b&gt;get-module&lt;/b&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: purple;"&gt;$ModName&lt;/span&gt;&lt;span style="color: black;"&gt;).ExportedCommands&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;i&gt;&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: teal;"&gt;Array&lt;/span&gt;&lt;span style="color: black;"&gt;[]]&lt;/span&gt;&lt;span style="color: purple;"&gt;$list&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;((&lt;/span&gt;&lt;span style="color: purple;"&gt;$commands&lt;/span&gt;&lt;span style="color: black;"&gt;).Values) |&amp;nbsp;&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;&lt;b&gt;%&lt;/b&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.Name} |&amp;nbsp;&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;&lt;b&gt;Sort&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;span style="color: purple;"&gt;&lt;i&gt;$list&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;PS C:\&amp;gt; get-module -list&lt;br /&gt;ModuleType Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ExportedCommands&lt;br /&gt;---------- ---- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;----------------&lt;br /&gt;...&lt;br /&gt;Manifest &amp;nbsp; PSUserTools &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;br /&gt;....&lt;br /&gt;PS C:\&amp;gt; import-module PSUserTools&lt;br /&gt;PS C:\&amp;gt; get-module_exports PSUserTools&lt;br /&gt;Get-CurrentUser&lt;br /&gt;Get-Everyone&lt;br /&gt;Start-ProcessAsAdministrator&lt;br /&gt;Test-IsAdministrator&lt;/blockquote&gt;&lt;br /&gt;'Get-CurrentUser' queries WMI to find domain and local users. Here is a simplified function derived from that script that prints out local users and their SIDs:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;net_user&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;{&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;netusers&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: purple;"&gt;$query&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"Win32_UserAccount"&lt;/span&gt;&lt;span style="color: black;"&gt;;&lt;/span&gt;&lt;span style="color: purple;"&gt;$query&lt;/span&gt;&lt;span style="color: red;"&gt;+=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;" WHERE LocalAccount='True'"&lt;/span&gt;&lt;span style="color: black;"&gt;;&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;&lt;b&gt;Get-WmiObject&lt;/b&gt;&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$query&lt;/span&gt;&lt;span style="color: black;"&gt; }&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;span style="color: cadetblue;"&gt;netusers&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;&lt;b&gt;%&lt;/b&gt;&lt;/span&gt;&lt;span style="color: black;"&gt; {(&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.name)&lt;/span&gt;&lt;span style="color: red;"&gt;+&lt;/span&gt;&lt;span style="color: maroon;"&gt;" "&lt;/span&gt;&lt;span style="color: red;"&gt;+&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.SID)}&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;PS C:\ net_user &amp;nbsp;[SIDs deleted for privacy]&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;Administrator S-1-*&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;Guest S-1-*&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0in;"&gt;&lt;span style="color: black;"&gt;&lt;i&gt;rferrisx S-1-*&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-7118253583491481738?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/7118253583491481738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=7118253583491481738&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7118253583491481738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7118253583491481738'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2011/08/some-addendum-on-modules.html' title='Some addendum on modules'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-8579114210513411360</id><published>2011-05-06T16:35:00.000-07:00</published><updated>2011-05-06T16:35:56.470-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='$$ functional programming'/><title type='text'>$$ Recursion?</title><content type='html'>After reading Lee Holmes &lt;a href="http://blogs.msdn.com/b/powershell/archive/2010/12/04/the-great-dollar-dollar.aspx"&gt;$$ blog post&lt;/a&gt;, I realized the $$ command has some recursive properties.&lt;br /&gt;You can assign a function to the $$ variable and then init that function as follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="color: blue;"&gt;Function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Repeat-History&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$$&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;'&lt;/span&gt;&lt;span style="color: maroon;"&gt;function gh {get-history}&lt;/span&gt;&lt;span style="color: maroon;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Invoke-History&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$$&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;gh&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This allows us to do some interesting work. The function below will run through &amp;nbsp;a class C subnet pinging port 443 with a TCP based ping. &amp;nbsp; It does this by loading the "$$" variable with an nping cmd, echoing the command , and then using invoke-expression ('iex') to load the results into a file. &amp;nbsp;The advantage of &amp;nbsp;'executing your label' ...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;global:nmap_subnet&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;{&lt;br /&gt;   [CmdletBinding()]&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: blue;"&gt;Param&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;br /&gt;        [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$subnet&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;        [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$ErrorActionPreference&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;silentlycontinue&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;         )&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: black;"&gt;.255&lt;/span&gt;&lt;span style="color: black;"&gt; |&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;%&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: purple;"&gt;$$&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;C:\tools\nmap-5.51-win32\nmap-5.51\nping -c 1 --tcp -p 443 $subnet.$_&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$$&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;iex&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$$&lt;/span&gt;&lt;span style="color: black;"&gt; | findstr RCVD | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;out-file&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-append&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$subnet&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-8579114210513411360?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/8579114210513411360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=8579114210513411360&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8579114210513411360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8579114210513411360'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2011/05/recursion.html' title='$$ Recursion?'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-1351602652842808699</id><published>2011-02-09T21:55:00.000-08:00</published><updated>2011-02-09T21:55:49.172-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Displaying IP Addresses'/><title type='text'>Displaying IP addresses with Windows Powershell</title><content type='html'>How many IP Addresses on a Windows 7 system?&lt;br /&gt;&lt;br /&gt;Here are two different Powershell commands that produce a list of IPv4 and IPv6 addresses on the same Windows 7 workstation. One parses 'ipconfig' and validates five addresses through &amp;nbsp;'[System.Net.IPaddress]'. The other uses 'gwmi' and the format of the addresses it produces will not similarly validate. Aside from the formatting of the object produced, I cannot understand why they will not validate. &amp;nbsp;It appears here I am extracting IPv6 anycast and broadcast addresses with 'ipconfig' that 'gwmi' is not giving me.&lt;br /&gt;&lt;br /&gt;$IPAddress_ipconfig=(ipconfig | Select-string Address) -split ": " | Select-string -notmatch ". ."&lt;br /&gt;foreach ($IP in $IPAddress_ipconfig) {([System.Net.IPaddress]::Parse("$IP")).IPAddressToString}&lt;br /&gt;&lt;br /&gt;fe80::6172:6ecf:2d05:b0ae%12&lt;br /&gt;192.168.0.11&lt;br /&gt;fe80::cddc:ceef:b717:a5ac%11&lt;br /&gt;2001:0:4137:9e76:30c3:129:3f57:fff4&lt;br /&gt;fe80::30c3:129:3f57:fff4%17&lt;br /&gt;&lt;br /&gt;(Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.IPAddress} | Select IPaddress | fc -expand CoreOnly | findstr [0-9])&lt;br /&gt;&lt;br /&gt;fe80::cddc:ceef:b717:a5ac&lt;br /&gt;192.168.0.11&lt;br /&gt;fe80::6172:6ecf:2d05:b0ae&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-1351602652842808699?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/1351602652842808699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=1351602652842808699&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1351602652842808699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1351602652842808699'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2011/02/displaying-ip-addresses-with-windows.html' title='Displaying IP addresses with Windows Powershell'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-1724421613531367984</id><published>2011-01-08T02:04:00.000-08:00</published><updated>2011-01-08T02:06:48.187-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ping multiple subnets'/><title type='text'>ping multiple subnets</title><content type='html'>&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: green;"&gt;# &lt;/span&gt;&lt;span style="color: green;"&gt;'&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/ping-multiple_subnets.ps1"&gt;ping-multiple_subnets.ps1&lt;/a&gt;'&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: green;"&gt;# All Rights Reserved Ryan M. Ferris r.10:34 PM 1/7/2011&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; Powershell V2 functions to ping multiple-subnets&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; Consists of three functions: (ping-subnet, ping-ip , ping-multi)&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; ping-subnet : .NET $ping.send - a single (simple) eight byte ICMP packet&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; ping-ip : WMI 'test-connection' - a single (wmi info) eight byte ICMP packet&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; ping-multi : wrapper function &lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: green;"&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; first create multiple Class C ranges: e.g.:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: green;"&gt;    # $IPRange = 0..5 | %{"192.168.$_"}&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: green;"&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; use 'ping-multi' to discover them: e.g.:&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: green;"&gt;    # $IPRange | % {ping-multi $_}&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; The .NET $ping.send is much faster than WMI although 'test-connection' returns more&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: green;"&gt;# information&lt;/span&gt;&lt;span style="color: green;"&gt; and can be configured to do authentication and impersonation&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt; Essentially, 'ping-subnet' does discovery that it pumps to 'ping-ip' which&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: green;"&gt;# creates csv files named per subnet per pass.&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;global:Ping-Subnet&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;{&lt;br /&gt;   [CmdletBinding()]&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: blue;"&gt;Param&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;br /&gt;       [Parameter(Mandatory&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;,ValueFromPipeline&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;)]&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$Network&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;array&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$subnet&lt;/span&gt;&lt;span style="color: black;"&gt;=@(&lt;/span&gt;&lt;span style="color: black;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: black;"&gt;.254&lt;/span&gt;&lt;span style="color: black;"&gt;),&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;int32&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$buffersize&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;8&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;Int32&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$timeout&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;10&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;Int32&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$TTL&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;128&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;bool&lt;/span&gt;&lt;span style="color: black;"&gt;]  &lt;/span&gt;&lt;span style="color: purple;"&gt;$fragment&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$false&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$ErrorActionPreference&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;silentlycontinue&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;          )&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$ping&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;new-object&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;System.Net.NetworkInformation.Ping&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$pingoptions&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;new-object&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;System.Net.NetworkInformation.PingOptions&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$pingoptions&lt;/span&gt;&lt;span style="color: black;"&gt;.ttl&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$TTL&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$pingoptions&lt;/span&gt;&lt;span style="color: black;"&gt;.dontfragment&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$fragment&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$Global:SNIPs&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;( &lt;/span&gt;&lt;span style="color: purple;"&gt;$subnet&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;%&lt;/span&gt;&lt;span style="color: black;"&gt; -process  {&lt;/span&gt;&lt;span style="color: purple;"&gt;$Ping&lt;/span&gt;&lt;span style="color: black;"&gt;.Send(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;$Network.$_&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;, &lt;/span&gt;&lt;span style="color: purple;"&gt;$timeout&lt;/span&gt;&lt;span style="color: black;"&gt;, &lt;/span&gt;&lt;span style="color: purple;"&gt;$buffersize&lt;/span&gt;&lt;span style="color: black;"&gt;, &lt;/span&gt;&lt;span style="color: purple;"&gt;$PingOptions&lt;/span&gt;&lt;span style="color: black;"&gt;)} | &lt;br /&gt;                &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;where&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.Status &lt;/span&gt;&lt;span style="color: red;"&gt;-eq&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Success&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;})&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$Global:IPs&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$SNIPs&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;%&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.Address.IPAddressToString}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;global:Ping-ip&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;br /&gt;{&lt;br /&gt;   [CmdletBinding()]&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: blue;"&gt;Param&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;br /&gt;       [Parameter(Mandatory&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;,ValueFromPipeline&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;)]&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$computername&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;int32&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$buffersize&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;8&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;int32&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$count&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;Int32&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$TimeToLive&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;128&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;Int32&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$Delay&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;,&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$ErrorActionPreference&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;silentlycontinue&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;          )&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: purple;"&gt;$global:result&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Test-connection&lt;/span&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-computername&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$computername&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;`&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-buffersize&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$buffersize&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;`&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-count&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$count&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;`&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-TimeToLive&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$TimeToLive&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;`&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-Delay&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$Delay&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: purple;"&gt;$global:icmp_out&lt;/span&gt;&lt;span style="color: black;"&gt;  &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;New-Object&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;PSObject&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-Property&lt;/span&gt;&lt;span style="color: black;"&gt; @{&lt;br /&gt;            IPv4          &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$result&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;IPv4Address&lt;/span&gt;&lt;span style="color: black;"&gt;.IPAddressToString&lt;br /&gt;            IPv6          &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$result&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;IPv6Address&lt;/span&gt;&lt;span style="color: black;"&gt;.IPAddressToString&lt;br /&gt;            BytesSent     &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$result&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;BufferSize&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;            BytesReturned &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$result&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;ReplySize&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;            ResponseTime  &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$result&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;ResponseTime&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;            ReplyInc      &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$result&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;ReplyInconsistency&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;      } | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Select-Object&lt;/span&gt;&lt;span style="color: black;"&gt; IPv4,IPv6,BytesSent,BytesReturned,Responsetime,ReplyInc&lt;br /&gt;   &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: purple;"&gt;$icmp_out&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;-ne&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$null&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;br /&gt;    {&lt;/span&gt;&lt;span style="color: purple;"&gt;$ICMP_out&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;ConvertTo-Csv&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-NoTypeInformation&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;out-file&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-width&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;120&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-append&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-NoClobber&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;write&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;$3OCT.csv&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;)}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;ping-multi&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;Param&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;br /&gt;       [Parameter(Mandatory&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;,ValueFromPipeline&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$true&lt;/span&gt;&lt;span style="color: black;"&gt;)]&lt;br /&gt;       [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$Global:3OCT&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;       )&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$3OCT&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;%&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;ping-subnet&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$IPs&lt;/span&gt;&lt;span style="color: black;"&gt;  | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;%&lt;/span&gt;&lt;span style="color: black;"&gt; {&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;ping-ip&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-1724421613531367984?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/1724421613531367984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=1724421613531367984&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1724421613531367984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1724421613531367984'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2011/01/ping-multiple-subnets.html' title='ping multiple subnets'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-7681353741845670728</id><published>2011-01-04T13:03:00.000-08:00</published><updated>2011-01-04T13:14:24.092-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Test-Commection GWMI Measure-object'/><title type='text'>Using Test-Connection</title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;'&lt;a href="http://technet.microsoft.com/en-us/library/dd315259.aspx"&gt;Test-Connectio&lt;/a&gt;n' is Powershell V2's&amp;nbsp;&lt;a href="http://technet.microsoft.com/en-us/library/dd315295.aspx"&gt;GWMI&lt;/a&gt;-based &lt;a href="http://msdn.microsoft.com/en-us/library/dd432328(v=VS.85).aspx"&gt;icmp test cmdlet&lt;/a&gt; that returns considerable amounts of information in object format. &amp;nbsp;'Test-Connection' also has the ability to authenticate (at various levels) to the computer whose ICMP responses it is testing, but I do not discuss that in this post. '&lt;a href="http://technet.microsoft.com/en-us/library/dd315259.aspx"&gt;Test-Connection&lt;/a&gt;' can return a number of errors, which I found difficult to trap, throw, or try-catch-finally. &amp;nbsp;So, like some others (&lt;a href="http://jdhitsolutions.com/blog/2010/03/test-connection-troubles/"&gt;1&lt;/a&gt;,&lt;a href="http://www.powergui.org/thread.jspa?threadID=10800"&gt;2&lt;/a&gt;), I punted on error-trapping with:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;[&lt;i&gt;string] $ErrorActionPreference="silentlycontinue" &lt;/i&gt;&amp;nbsp;(Yea, I know...what a wimp...)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Although, '&lt;a href="http://technet.microsoft.com/en-us/library/dd315259.aspx"&gt;Test-Connection&lt;/a&gt;' is slower than &lt;span class="Apple-style-span" style="color: #333333; line-height: 20px;"&gt;&lt;a href="http://system.net.networkinformation.ping/"&gt;System.Net.NetworkInformation.Ping&lt;/a&gt;&amp;nbsp;will probably ever be, it does return considerable amounts of useful information. Below is the &lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/icmp_gwmi.ps1"&gt;function 'Ping-IP'&lt;/a&gt;&amp;nbsp;with the returned object and some statistical results from &lt;a href="http://technet.microsoft.com/en-us/library/dd315251.aspx"&gt;'measure-object&lt;/a&gt;'. I've created a hash table and renamed six of the properties. &amp;nbsp;Notice how I can use '&lt;a href="http://technet.microsoft.com/en-us/library/dd315259.aspx"&gt;Test-Connection&lt;/a&gt;' to check for IPv4 and IPv6 connections simultaneously (if you have an existing IPv6 interface).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;function global:Ping-IP&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; [CmdletBinding()]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; Param(&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; [Parameter(Mandatory=$true,ValueFromPipeline=$true)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; [string]$computername,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; [int32] $buffersize=8,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; [int32] $count=1,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; [string] $ErrorActionPreference="silentlycontinue"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;$global:result= Test-connection -computername $computername -buffersize $buffersize -count $count&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;$global:ICMP_out = New-Object PSObject -Property @{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; IPv4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= $result.IPv4Address.IPAddressToString&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; IPv6&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;= $result.IPv6Address.IPAddressToString&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; BytesSent &amp;nbsp; &amp;nbsp; = $result.BufferSize&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; BytesReturned = $result.ReplySize&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; ResponseTime &amp;nbsp;= $result.ResponseTime&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; ReplyInc&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp;= $result.ReplyInconsistency&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp;} | Select-Object IPv4,IPv6,BytesSent,BytesReturned,Responsetime,ReplyInc&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;if ($result -ne $null) {$ICMP_out}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;First I create a partial subnet range to ping, pipe the function output&amp;nbsp;&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/icmp_gwmi.ps1"&gt;("ping-ip"&lt;/a&gt;) to a variable and then sort the output by response time:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;b&gt;$IPRange=0..50 | %{"74.125.127.$_"}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;b&gt;$result=$IPRange | % {Ping-IP $_}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;b&gt;$result | Sort Responsetime -Descending | ft&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;I&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;Pv4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IPv6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BytesSent &amp;nbsp; &amp;nbsp; BytesReturned &amp;nbsp; &amp;nbsp; ResponseTime &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReplyInc&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;---- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--------- &amp;nbsp; &amp;nbsp; ------------- &amp;nbsp; &amp;nbsp; ------------ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.19 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;115 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.46 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 74 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.16 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 68 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.48 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 67 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.27 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 66 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.14 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 61 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.33 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 43 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.39 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.41 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 34 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"&gt;74.125.127.18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;.....&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Next, I can easily measure the "Responsetime" of my '&lt;a href="http://technet.microsoft.com/en-us/library/dd315259.aspx"&gt;Test-Connection&lt;/a&gt;' queries with&amp;nbsp;&lt;a href="http://technet.microsoft.com/en-us/library/dd315251.aspx"&gt;'measure-object&lt;/a&gt;' :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;b&gt;$result | Measure-Object -Average -Maximum -Minimum -Sum -Property Responsetime&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Count &amp;nbsp; &amp;nbsp;: 28&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Average &amp;nbsp;: 40.7857142857143&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Sum &amp;nbsp; &amp;nbsp; &amp;nbsp;: 1142&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Maximum &amp;nbsp;: 115&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Minimum &amp;nbsp;: 19&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Property : ResponseTime&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: small;"&gt;There are considerable more statistics and graphing output that could be done with this function with log-parser, and/or a Powershell statistics package and/or csv exports to spreadsheet software. Creating a more robust function will involve more sophisticated error-trapping and or the use of the background jobs. To be continued...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-7681353741845670728?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/7681353741845670728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=7681353741845670728&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7681353741845670728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7681353741845670728'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2011/01/using-test-connection.html' title='Using Test-Connection'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-8502748384846885381</id><published>2010-12-21T09:40:00.000-08:00</published><updated>2010-12-21T09:40:23.999-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell time-stamping logging'/><title type='text'>Powershell log time-stamping</title><content type='html'>The function 'logtime' &amp;nbsp;below will work as a logging function in scripts&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$FileTime=[DateTime]::Now.ToFileTime()&lt;br /&gt;&lt;br /&gt;function logtime{&lt;br /&gt;$date = [DateTime]::Now.Day&lt;br /&gt;$hour = [DateTime]::Now.TimeOfDay.Hours&lt;br /&gt;$minutes = [DateTime]::Now.TimeOfDay.Minutes&lt;br /&gt;$seconds = [DateTime]::Now.TimeOfDay.Seconds&lt;br /&gt;$ms = [DateTime]::Now.TimeOfDay.Milliseconds&lt;br /&gt;&lt;br /&gt;[object]$logtime = New-Object PSObject -Property @{&lt;br /&gt;date=$date&lt;br /&gt;hour=$hour&lt;br /&gt;minutes=$minutes&lt;br /&gt;seconds=$seconds&lt;br /&gt;ms=$ms&lt;br /&gt;}&lt;br /&gt;write $logtime | ft -HideTableHeaders -AutoSize -Property date,hour,minutes,seconds,ms | out-file -append -noclobber $PWD\$FileTime&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[output]&lt;br /&gt;PS C:\Users\rferrisx\Documents&amp;gt; gc 129374235* | more&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;21 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp;45 &amp;nbsp; &amp;nbsp; &amp;nbsp;43 821&lt;br /&gt;&amp;nbsp;&amp;nbsp;21 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp;51 &amp;nbsp; &amp;nbsp; &amp;nbsp;12 604&lt;br /&gt;&amp;nbsp;&amp;nbsp;21 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp;51 &amp;nbsp; &amp;nbsp; &amp;nbsp;12 616&lt;br /&gt;&amp;nbsp;&amp;nbsp;21 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp;51 &amp;nbsp; &amp;nbsp; &amp;nbsp;12 656&lt;br /&gt;&amp;nbsp;&amp;nbsp;21 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp;51 &amp;nbsp; &amp;nbsp; &amp;nbsp;12 662&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-8502748384846885381?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/8502748384846885381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=8502748384846885381&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8502748384846885381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8502748384846885381'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2010/12/powershell-log-time-stamping.html' title='Powershell log time-stamping'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-4876849600362399942</id><published>2010-12-08T16:47:00.000-08:00</published><updated>2010-12-24T20:45:25.812-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Ping IP Ranges'/><title type='text'>System.Net.NetworkInformation.Ping</title><content type='html'>Here are some Powershell ping notes from&amp;nbsp;System.Net.NetworkInformation.Ping. &amp;nbsp;Powershell v 2.0 provides for the&amp;nbsp;&amp;nbsp;gwmi &amp;nbsp;based Win32_PingStatus &amp;nbsp;in the&amp;nbsp;'&lt;b&gt;Test-Connection&lt;/b&gt;' cmdlet . &lt;b&gt;'Test-connection'&amp;nbsp;&lt;/b&gt;&amp;nbsp;provides a wealth of information. &amp;nbsp;However this post simply examines how to use:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;System.Net.NetworkInformation.Ping&lt;/li&gt;&lt;li&gt;System.Net.NetworkInformation.PingOptions&lt;/li&gt;&lt;/ul&gt;Below is the common code needed for all three examples. This code sets up $ping and $pingoptions:&lt;br /&gt;&lt;br /&gt;#Set up the ping options&lt;br /&gt;&lt;b&gt;$ping = new-object System.Net.NetworkInformation.Ping&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$pingoptions = new-object System.Net.NetworkInformation.PingOptions&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$pingoptions.ttl=255&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$pingoptions.dontfragment=$false&lt;/b&gt;&lt;br /&gt;&lt;b&gt;# Here is the overload&lt;/b&gt;&lt;br /&gt;&lt;b&gt;# &amp;nbsp;From $ping.send.overloaddefinitions &amp;nbsp;use: System.Net.NetworkInformation.PingReply Send(string hostNameOrAddress, int timeout, byte[] buffer, System.Net.NetworkInformation.PingOptions options)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;#now ping a subnet with one line of code&lt;br /&gt;&lt;b&gt;(1..254 | % -process &amp;nbsp;{$Ping.Send("192.168.0.$_", 10, 64, $PingOptions)})&lt;/b&gt;&lt;br /&gt;# or (stop output) or redirect to a variable:&lt;br /&gt;&lt;b&gt;$a=(1..254 | % -process &amp;nbsp;{$Ping.Send("192.168.0.$_", 10, 64, $PingOptions)})&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This gives us something interesting like this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;PS C:\ps1&amp;gt; $a | where {$_.Status -eq "Success"} | ft * -auto&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;Status Address &amp;nbsp; &amp;nbsp; &amp;nbsp; RoundtripTime Options &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Buffer&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;------ ------- &amp;nbsp; &amp;nbsp; &amp;nbsp; ------------- ------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ------&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Success 192.168.0.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 System.Net.NetworkInformation.PingOptions {64}&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Success 192.168.0.6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 System.Net.NetworkInformation.PingOptions {64}&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Success 192.168.0.11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 System.Net.NetworkInformation.PingOptions {64}&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Success 192.168.0.13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 System.Net.NetworkInformation.PingOptions {64}&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;If you functionalize/filterize the output :&lt;br /&gt;&lt;b&gt;function pingsn {1..254 | % -process &amp;nbsp;{$Ping.Send("192.168.0.$_", 10, 64, $PingOptions)}}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;filter success {if ($_.status -eq "Success") {($_.Address.IPAddressToString)+" "+($_.roundtriptime)}}&lt;/b&gt;&lt;br /&gt;you get a similar output:&lt;br /&gt;&lt;b&gt;pingsn | success&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;192.168.0.1 1&lt;br /&gt;192.168.0.6 1&lt;br /&gt;192.168.0.9 0&lt;br /&gt;192.168.0.11 1&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;We can also ping and array of names (as below) and retrieve similar information if we pipe the output to a variable. Or we can do something more CSV like:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;#ping a multiple names&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$DNS_array="google.com", "googel.com", "googley.com"&lt;/b&gt;&lt;br /&gt;&lt;b&gt;($DNS_array | % -process &amp;nbsp;{$Ping.Send("$_", 10, 64, $PingOptions)})&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Status &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: Success&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Address &amp;nbsp; &amp;nbsp; &amp;nbsp; : 72.14.213.99&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RoundtripTime : 29&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Options &amp;nbsp; &amp;nbsp; &amp;nbsp; : System.Net.NetworkInformation.PingOptions&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Buffer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: {64, 0, 0, 0...}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Status &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: Success&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Address &amp;nbsp; &amp;nbsp; &amp;nbsp; : 74.125.224.17&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RoundtripTime : 38&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Options &amp;nbsp; &amp;nbsp; &amp;nbsp; : System.Net.NetworkInformation.PingOptions&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Buffer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: {64}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Status &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: Success&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Address &amp;nbsp; &amp;nbsp; &amp;nbsp; : 74.117.221.11&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RoundtripTime : 96&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Options &amp;nbsp; &amp;nbsp; &amp;nbsp; : System.Net.NetworkInformation.PingOptions&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Buffer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: {64}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;($DNS_array | % -process &amp;nbsp;{$Ping.Send("$_", 10, 64, $PingOptions)}) |&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;% {$_.Address.IPAddressToString +","+ &amp;nbsp;$_.Status +","+ $_.RoundTripTime}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;72.14.213.99,Success,25&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;74.125.224.17,Success,38&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;74.117.221.11,Success,98&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Something more clever to ping multiple subnets is needed. The code below isn't very fast. The use of a filter might speed it up. However, you can make it faster by specifying exactly the hosts you want in $Host_array.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;#ping multiple subnets&lt;/b&gt;&lt;br /&gt;&lt;b&gt;[array]$Host_array=1..20&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$Subnet_array="192.168.0","192.168.1","192.168.2"&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$count=$Subnet_array.count&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$i=0&lt;/b&gt;&lt;br /&gt;&lt;b&gt;do&lt;/b&gt;&lt;br /&gt;&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$global:out = $host_array | % -process {$Ping.Send($Subnet_array[$i]+"."+$_ , 1, 64, $PingOptions)}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$out | % {if ($_.Address) {$_.Address.IPAddressToString +","+ &amp;nbsp;$_.Status +","+ $_.RoundTripTime}}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;$i=$i+1&lt;/b&gt;&lt;br /&gt;&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;&lt;b&gt;while ($i -lt $count)&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-4876849600362399942?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/4876849600362399942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=4876849600362399942&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4876849600362399942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4876849600362399942'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2010/12/systemnetnetworkinformationping.html' title='System.Net.NetworkInformation.Ping'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-5010828201272674748</id><published>2010-07-31T00:54:00.000-07:00</published><updated>2010-08-13T17:45:38.886-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threads'/><category scheme='http://www.blogger.com/atom/ns#' term='Modules'/><category scheme='http://www.blogger.com/atom/ns#' term='Process'/><title type='text'>Looking at Process, Threads, Modules with Powershell 2.0</title><content type='html'>I have published&amp;nbsp;"&lt;a href="http://rmfdevelopment.com/WhitePapers/LookingatProcessesThreadsModules.pdf"&gt;Looking at Processes, Modules, and Threads with Powershell 2.0 Part I&lt;/a&gt;". &amp;nbsp;The paper concerns itself with comparing Processes, Modules, and Threads and offers some discussion for comparing their changes over time. See also:&lt;br /&gt;&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/diff_PMT.ps1"&gt;http://www.rmfdevelopment.com/PowerShell_Scripts/diff_PMT.ps1&lt;/a&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://rmfdevelopment.com/PowerShell_Scripts/diff_PMT_adv.ps1"&gt;http://rmfdevelopment.com/PowerShell_Scripts/diff_PMT_adv.ps1&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-5010828201272674748?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/5010828201272674748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=5010828201272674748&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5010828201272674748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5010828201272674748'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2010/07/looking-at-process-threads-modules-with.html' title='Looking at Process, Threads, Modules with Powershell 2.0'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2574288803672697354</id><published>2010-05-05T19:32:00.000-07:00</published><updated>2010-05-06T11:38:50.596-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netstat tasklist Windows Vista'/><title type='text'>Which processes are communicating on Vista? Part II</title><content type='html'>This is a faster method of telling which &lt;b&gt;processes are communicating&lt;/b&gt;. It feeds netstat output to tasklist:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;@for /f "tokens=1-5" %a in ('@netstat -nto ^| findstr /V Active ^| findstr /V Proto') do @tasklist /FO CSV /V /FI "PID eq %e" /NH&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;If put in a batch file that is properly escaped:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;@for /f "tokens=1-5" %%a in ('@netstat -nto ^| findstr /V Active ^| findstr /V Proto') do @tasklist /FO CSV /V /FI "PID eq %%e" /NH&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;and then run as below, it gives you process information on Established TCP connections. Tested on Vista. :&lt;br /&gt;&lt;br /&gt;&lt;i&gt;@ntob_ts.cmd | sort /+2&lt;/i&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"chrome.exe","3192","Console","1","77,012 K","Running","RMFVista\Admin","0:02:54","Daily Alerts - Google Analytics - Google Chrome"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"chrome.exe","3192","Console","1","77,012 K","Running","RMFVista\Admin","0:02:54","Daily Alerts - Google Analytics - Google Chrome"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"opera.exe","4092","Console","1","346,284 K","Running","RMFVista\Admin","0:09:03","http://sn114w.snt114.mail.live.com/default.aspx?wa=wsignin1.0 - Opera"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"opera.exe","4092","Console","1","346,328 K","Running","RMFVista\Admin","0:09:03","http://sn114w.snt114.mail.live.com/default.aspx?wa=wsignin1.0 - Opera"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;This &amp;nbsp;batch file below includes netstat endpoints but seems to randomly attach an IP address to the System Idle process ("0"):&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;@echo off&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;for /f "tokens=1-5" %%a in ('@netstat -nto ^| findstr /V Active ^| findstr /V Proto') do set EP=%%c&amp;amp; set PID=%%e&amp;amp; call :loop&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;goto EOF&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;:loop&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;@echo "%EP%", | findstr /V "ECHO"&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;@tasklist /FO CSV /V /FI "PID eq %PID%" /NH&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;@echo " " &amp;gt;NUL&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;:EOF&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[output]&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"74.125.19.17:443",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"chrome.exe","3192","Console","1","89,400 K","Running","RMFVista\Admin","0:03:34","Blogger: Horizontal Logic - Edit Post "Which Processes are communicating on Vista? Part I...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;" - Google Chrome"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"74.125.19.19:443",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"chrome.exe","3192","Console","1","89,400 K","Running","RMFVista\Admin","0:03:34","Blogger: Horizontal Logic - Edit Post "Which Processes are communicating on Vista? Part I...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;" - Google Chrome"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"74.125.19.19:443",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"opera.exe","4092","Console","1","346,312 K","Running","RMFVista\Admin","0:09:40","http://sn114w.snt114.mail.live.com/default.aspx?wa=wsignin1.0 - Opera"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"74.125.19.19:443",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"opera.exe","4092","Console","1","346,324 K","Running","RMFVista\Admin","0:09:40","http://sn114w.snt114.mail.live.com/default.aspx?wa=wsignin1.0 - Opera"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"74.125.19.101:80",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"chrome.exe","3192","Console","1","89,400 K","Running","RMFVista\Admin","0:03:34","Blogger: Horizontal Logic - Edit Post "Which Processes are communicating on Vista? Part I...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;" - Google Chrome"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"74.125.10.23:80",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"chrome.exe","3192","Console","1","89,400 K","Running","RMFVista\Admin","0:03:34","Blogger: Horizontal Logic - Edit Post "Which Processes are communicating on Vista? Part I...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;" - Google Chrome"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"76.96.30.119:110",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"System Idle Process","0","Services","0","24 K","Unknown","NT AUTHORITY\SYSTEM","24:51:17","N/A"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"85.13.200.108:110",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"WinMail.exe","4456","Console","1","179,712 K","Running","RMFVista\Admin","0:34:00","Google Alert - TCP/IP"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2574288803672697354?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2574288803672697354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2574288803672697354&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2574288803672697354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2574288803672697354'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2010/05/which-services-are-communicating-part.html' title='Which processes are communicating on Vista? Part II'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-5740823343139080766</id><published>2010-03-08T13:13:00.000-08:00</published><updated>2010-05-05T19:37:50.288-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tcpvcon;tasklist;'/><title type='text'>Which services are communicating on Vista?</title><content type='html'>What I want to know is which services are engaging in network communication. How they are changing over time. Network Monitor 3.3 tracks data packets back to executables but has an "unknown" category that carries a lot of data. &amp;nbsp;TCPView gives a dynamic list of Process, Protocol, Address &amp;nbsp;and Port in real-time. In the batch files below I pipe uniq tcpvcon output of process IDs &amp;nbsp;to tasklist /SVC and have FC detect what has changes. &amp;nbsp;Tasklist /SVC is slow however.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@echo off&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@for /f %%i in ('tcpvcon -a -c ^| gawk -F"," '{print $3}' ^| sort ^| uniq') do @(tasklist /NH /FO CSV /SVC /FI "PID eq %%i") &amp;gt;&amp;amp;1&amp;gt;&amp;gt; temp1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@for /f %%i in ('tcpvcon -a -c ^| gawk -F"," '{print $3}' ^| sort ^| uniq') do @(tasklist /NH /FO CSV /SVC /FI "PID eq %%i") &amp;gt;&amp;amp;1&amp;gt;&amp;gt; temp2&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;fc temp1 temp2 &amp;gt; &amp;amp;1&amp;gt;&amp;gt; diff&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@echo off&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;:top&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;del temp1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;del temp2&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@for /f %%i in ('tcpvcon -a -c ^| gawk -F"," '{print $3}' ^| sort ^| uniq') do @(tasklist /NH /FO CSV /SVC /FI "PID eq %%i") &amp;gt;&amp;amp;1&amp;gt;&amp;gt; temp1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@for /f %%i in ('tcpvcon -a -c ^| gawk -F"," '{print $3}' ^| sort ^| uniq') do @(tasklist /NH /FO CSV /SVC /FI "PID eq %%i") &amp;gt;&amp;amp;1&amp;gt;&amp;gt; temp2&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;fc temp1 temp2&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;goto top&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some relatively simple Powershell also helps detect which services are communicating:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia; font-size: 13px; line-height: 20px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;$global:svchost = get-wmiObject win32_process -filter "name='svchost.exe'"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;$global:win32_handle = $svchost | foreach { gwmi -query "Select * from win32_service where processID = $($_.handle)" }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;$global:Sort_handle = $win32_handle | sort processID, Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;$global:Sort_svchost = $svchost | sort processID&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;$Sort_handle | format-table processID,name,state, startmode,Started,AcceptStop,Description -AutoSize&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;$Sort_svchost | format-table ProcessID,ThreadCount,HandleCount,WS,VM,KernelModeTime,ReadOperationCount,ReadTransferCount,OtherTransferCount -Autosize&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-5740823343139080766?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/5740823343139080766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=5740823343139080766&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5740823343139080766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5740823343139080766'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2010/03/which-services-are-communicating.html' title='Which services are communicating on Vista?'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-5392675631069085905</id><published>2009-06-14T15:44:00.000-07:00</published><updated>2011-01-09T16:29:09.876-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PS;modules;memory'/><title type='text'>Enumerating running modules</title><content type='html'>&lt;div&gt;Some code worth publishing (from some work I am doing over at &lt;a href="http://thinking-about-network-security.blogspot.com/"&gt;RMF Network Security&lt;/a&gt;  on Conficker, worm detection, etc: ):&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:ps = ps&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$ps_count = $ps.count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "Process Count = $ps_count"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:all_modules = 0..$ps_count |%{$ps[$_].Modules} | Select Size,ModuleName,FileName,FileVersion&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$allmod_count = $all_modules.count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "All instances of loaded modules = $allmod_count"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:unique_all_modules = $all_modules | Select -property ModuleName | Sort -Unique -property ModuleName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$uniqmod_count = $unique_all_modules.count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "All uniq module names = $uniqmod_count"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:all_modules_memory = $all_modules | Select -property ModuleName,Size | Sort -property Size&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:MO_all_mod_mem = $all_modules_memory | measure-object -property Size -sum&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:CountModMem = $MO_all_mod_mem.count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:SumModMem = $MO_all_mod_mem.sum&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SumModMemMB = ( ( $SumModMem * 1000)/ 1GB)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "Sum of $CountModMem modules memory size = $SumModMemMB GB"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Output:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;.\AllModules.ps1&lt;/div&gt;&lt;div&gt;Process Count = 69&lt;/div&gt;&lt;div&gt;All instances of loaded modules = 2943&lt;/div&gt;&lt;div&gt;All uniq module names = 526&lt;/div&gt;&lt;div&gt;Sum of 2943 modules memory size = 1.75315514206886 GB&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The error below is something I will have to look into:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;:$a = ps -Module&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;Get-Process : cannot enumerate the modules of process 'Idle'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;At line:1 char:8&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;+ $a = ps &amp;lt;&amp;lt;&amp;lt;&amp;lt;  -Module&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;    + CategoryInfo          : PermissionDenied: (System.Diagnostics.Process (Idle):Process) [Get-Process], ProcessCommandException&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;    + FullyQualifiedErrorId : CouldnotEnumerateModules,Microsoft.PowerShell.Commands.GetProcessCommand&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;Get-Process : cannot enumerate the modules of process 'System'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;At line:1 char:8&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;+ $a = ps &amp;lt;&amp;lt;&amp;lt;&amp;lt;  -Module&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;    + CategoryInfo          : PermissionDenied: (System.Diagnostics.Process (System):Process) [Get-Process], ProcessCommandException&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;    + FullyQualifiedErrorId : CouldnotEnumerateModules,Microsoft.PowerShell.Commands.GetProcessCommand&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;:$a.count&lt;/div&gt;&lt;div&gt;2940&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-5392675631069085905?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/5392675631069085905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=5392675631069085905&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5392675631069085905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5392675631069085905'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/06/some-code-worth-publishing-from-some.html' title='Enumerating running modules'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-7979944140276294921</id><published>2009-04-14T13:18:00.000-07:00</published><updated>2009-04-15T09:54:04.636-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='Blackberry'/><category scheme='http://www.blogger.com/atom/ns#' term='powershell;MidpSSh 1.7'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;Well, I thought this was pretty cool.  Blackberry Storm, Cygwin, Powershell v2CTP3,MidpSSH 1.7:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-L4HUu8oKmI/SeTwBW9nSvI/AAAAAAAADe0/QXbsQMR0Mr4/s1600-h/P1070606.JPG"&gt;&lt;img src="http://3.bp.blogspot.com/_-L4HUu8oKmI/SeTwBW9nSvI/AAAAAAAADe0/QXbsQMR0Mr4/s200/P1070606.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5324644565593311986" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 200px; height: 150px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-L4HUu8oKmI/SeTx9_E9LNI/AAAAAAAADfE/BmCHwKJ8nfc/s1600-h/P1070607.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 200px; height: 150px;" src="http://3.bp.blogspot.com/_-L4HUu8oKmI/SeTx9_E9LNI/AAAAAAAADfE/BmCHwKJ8nfc/s200/P1070607.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5324646706665303250" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-L4HUu8oKmI/SeTwOzGaGoI/AAAAAAAADe8/2rfvNX7rMNw/s1600-h/P1070595.JPG" style="text-decoration: none;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;img style="text-decoration: underline;display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 200px; height: 150px; " src="http://4.bp.blogspot.com/_-L4HUu8oKmI/SeTwOzGaGoI/AAAAAAAADe8/2rfvNX7rMNw/s200/P1070595.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5324644796484688514" /&gt;&lt;/a&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-7979944140276294921?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/7979944140276294921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=7979944140276294921&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7979944140276294921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7979944140276294921'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/04/well-i-thought-this-was-pretty-cool.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_-L4HUu8oKmI/SeTwBW9nSvI/AAAAAAAADe0/QXbsQMR0Mr4/s72-c/P1070606.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-3200773542698270553</id><published>2009-04-08T20:51:00.000-07:00</published><updated>2011-07-07T11:35:57.900-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System.Net.NetworkInformation.IcmpV4Statistic;System.Net.NetworkInformation.IPGlobalStatistics;Win32_PerfFormattedData_Tcpip_NetworkInterface;'/><title type='text'>Gathering Network Statistics</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# In PS CTP2v3, .NET access to IP statistics is non-existent. There are no static members&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# for the interface statistics yet,&amp;nbsp;although there are non static members:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[System.Net.NetworkInformation.IcmpV4Statistics].getmembers() | %{$_.name}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[System.Net.NetworkInformation.IPGlobalStatistics].getmembers() | %{$_.name}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# This means network data has to come from WMI or netsh:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$computer = "LocalHost"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$namespace = "root\CIMV2"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfFormattedData_Tcpip_TCP -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfFormattedData_Tcpip_UDP -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfFormattedData_Tcpip_IP -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfRawData_Tcpip_TCP -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfRawData_Tcpip_UDP -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfRawData_Tcpip_IP -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Get-WmiObject -class Win32_PerfRawData_Tcpip_NetworkInterface -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;netsh interface ip show&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;netsh interface ip show ipstats&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;netsh interface ip show tcpstats&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;netsh interface ip show interface&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$computer = "LocalHost"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$namespace = "root\CIMV2"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Tcpip_TCP = Get-WmiObject -class Win32_PerfFormattedData_Tcpip_TCP -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Tcpip_TCP | Select ConnectionFailures,ConnectionsActive,ConnectionsEstablished,ConnectionsPassive,ConnectionsReset&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$computer = "LocalHost"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$namespace = "root\CIMV2"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Tcpip_NI = Get-WmiObject -class Win32_PerfRawData_Tcpip_NetworkInterface -computername $computer -namespace $namespace&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Tcpip_NI | Select BytesReceivedPersec,BytesSentPersec,BytesTotalPersec&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$netsh_interface_stats = netsh interface ip show interface&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$netsh_interface_stats | Select-string "In Octets"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$netsh_interface_stats | Select-string "Out Octets"&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-3200773542698270553?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/3200773542698270553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=3200773542698270553&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3200773542698270553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3200773542698270553'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/04/in-ps-ctp2v3_08.html' title='Gathering Network Statistics'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-256672276018665631</id><published>2009-04-01T11:18:00.000-07:00</published><updated>2011-01-09T16:30:33.854-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nmcap;logparser;Powershell;IP String Searches'/><title type='text'>Working with netmon caps in Powershell</title><content type='html'>&lt;span style="font-size: 85%;"&gt;An update to this post 8:32 PM 8/7/2009:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;I have no path to loading nmcap files into powershell now that logparser does not work with Netmon 3.3 file format. I added my comment to this feature request:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=265564&amp;amp;SiteID=216"&gt;https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=265564&amp;amp;SiteID=216&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;"The jump between 3.2 and 3.3 file formats/APIs broke logparser2.2 interface to netmon files which was extraordinarily useful since logparser would convert file formats, sql-lize queries, create charts and datagrids, etc. Examples are below. Granted this is probably a logparser (e.g. unsupported ware) defect, however...The real defect is here is that there is no path to convert Netmon 3.3 captures files to CSV.C:\Program Files (x86)\Log Parser 2.2&amp;gt;logparser -headers OFF -stats NO -i:NETMON -o:CSV "SELECT DateTime,SrcMAC,SrcPort,DstMAC,DstPort,WindowSize FROM32.cap"2009-01-13 11:37:53,00095B00F3DA,80,0013021A607B,2004,328902009-01-13 11:37:53,0013021A607B,2006,00095B00F3DA,80,163842009-01-13 11:37:54,00095B00F3DA,80,0013021A607B,2006,58402009-01-13 11:37:54,0013021A607B,2006,00095B00F3DA,80,175202009-01-13 11:37:54,0013021A607B,2006,00095B00F3DA,80,17520.....C:\Program Files (x86)\Log Parser 2.2&amp;gt;logparser -headers OFF -i:NETMON -o:CSV "SELECT DateTime,SrcMAC,SrcPort,DstMAC,DstPort,WindowSize FROM 33.cap"Statistics:-----------Elements processed: 0Elements output: 0Execution time: 0.01 seconds"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;7:10 AM 4/2/2009: An update to this post&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Once you have a capture in the form of an object, you can do interesting work with it in powershell:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$DstSrcPort_8NET = $capture where-object {($_.SrcIP -match "^8\." ) -or ($_.DstIP -match "^8\.")}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$DstSrcPort_8NET Sort DateTime -unique ft more&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$DstSrcPort_8NET group-object DstPort Sort -descending Count&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$DstSrcPort_8NET measure-object -average -minimum -maximum -property WindowSize&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$a = $DstSrcPort_8NET Sort SrcIP -unique&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$a %{[System.Net.DNS]::Resolve($_.SrcIP)}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In progress...concating collections of nmcap files and searching them for specific SrcIP and DstIp with Powershell and LogParser. This code is working now, but still "to be continued"...&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function Search-IP($IP_String)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{ #start function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(ls -name *.cap) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;foreach-object -begin {$file =[DateTime]::now.ToFileTime().ToString()} `&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;-process {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$filename = $_ ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$temp = logparser -headers OFF -stats NO -i:NETMON -o:CSV "SELECT DateTime,SrcIP,SrcPort,DstIP,DstPort,WindowSize FROM $filename" ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;out-file -inputobject $temp -append -noclobber -filepath $file} `&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;-end {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$header = "DateTime","SrcIP","SrcPort","DstIP","DstPort","WindowSize" ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:capture = Import-csv $file -header $header ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:MatchIPObject = $capture where-object {$_ -match $IP_String} ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Global:MatchIPString = Select-String $IP_String $file -AllMatches}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;} #end function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;:$MatchIPObject[0..10] ft&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;DateTime SrcIP SrcPort DstIP DstPort WindowSize&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;-------- ----- ------- ----- ------- ----------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 68.26.116.175 1169 66.133.124.56 443 16384&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 66.133.124.56 443 68.26.116.175 1169 4140&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 68.26.116.175 1169 66.133.124.56 443 16560&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 68.26.116.175 1169 66.133.124.56 443 16560&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 66.133.124.56 443 68.26.116.175 1169 4140&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 68.26.116.175 1169 66.133.124.56 443 15753&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 68.26.116.175 1169 66.133.124.56 443 15753&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 68.26.116.175 1170 66.133.124.56 443 16384&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 66.133.124.56 443 68.26.116.175 1169 4229&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 66.133.124.56 443 68.26.116.175 1169 4229&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;2007-07-16 13:59:52 68.26.116.175 1169 66.133.124.56 443 15753&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;:$MatchIPString[0..10]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:7:2007-07-16 13:59:52,68.26.116.175,1169,66.133.124.56,443,16384&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:9:2007-07-16 13:59:52,66.133.124.56,443,68.26.116.175,1169,4140&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:10:2007-07-16 13:59:52,68.26.116.175,1169,66.133.124.56,443,16560&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:11:2007-07-16 13:59:52,68.26.116.175,1169,66.133.124.56,443,16560&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:12:2007-07-16 13:59:52,66.133.124.56,443,68.26.116.175,1169,4140&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:13:2007-07-16 13:59:52,68.26.116.175,1169,66.133.124.56,443,15753&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:14:2007-07-16 13:59:52,68.26.116.175,1169,66.133.124.56,443,15753&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:15:2007-07-16 13:59:52,68.26.116.175,1170,66.133.124.56,443,16384&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:16:2007-07-16 13:59:52,66.133.124.56,443,68.26.116.175,1169,4229&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:17:2007-07-16 13:59:52,66.133.124.56,443,68.26.116.175,1169,4229&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;128830930248593750:18:2007-07-16 13:59:52,68.26.116.175,1169,66.133.124.56,443,15753&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;:$MatchIPObject[0..10] gm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;TypeName: System.Management.Automation.PSCustomObject&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Name MemberType Definition&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;---- ---------- ----------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Equals Method System.Boolean Equals(Object obj)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;GetHashCode Method System.Int32 GetHashCode()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;GetType Method System.Type GetType()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;ToString Method System.String ToString()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;DateTime NoteProperty System.String DateTime=2007-07-16 13:59:52&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;DstIP NoteProperty System.String DstIP=66.133.124.56&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;DstPort NoteProperty System.String DstPort=443&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;SrcIP NoteProperty System.String SrcIP=68.26.116.175&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;SrcPort NoteProperty System.String SrcPort=1169&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;WindowSize NoteProperty System.String WindowSize=16384&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;:$MatchIPString[0..10] gm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;TypeName: Microsoft.PowerShell.Commands.MatchInfo&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Name MemberType Definition&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;---- ---------- ----------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Equals Method System.Boolean Equals(Object obj)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;GetHashCode Method System.Int32 GetHashCode()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;GetType Method System.Type GetType()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;ToString Method System.String ToString(), System.String ToString(String directory)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Context Property Microsoft.PowerShell.Commands.MatchInfoContext Context {get;set;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Filename Property System.String Filename {get;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;IgnoreCase Property System.Boolean IgnoreCase {get;set;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Line Property System.String Line {get;set;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;LineNumber Property System.Int32 LineNumber {get;set;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Matches Property System.Text.RegularExpressions.Match[] Matches {get;set;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Path Property System.String Path {get;set;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Pattern Property System.String Pattern {get;set;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-256672276018665631?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/256672276018665631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=256672276018665631&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/256672276018665631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/256672276018665631'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/04/in-progress.html' title='Working with netmon caps in Powershell'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-4568259981805941681</id><published>2009-03-30T19:33:00.000-07:00</published><updated>2009-03-30T19:40:16.983-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Start folder;cmd.exe.'/><title type='text'></title><content type='html'>&lt;div&gt;I experimented with a powershell script  in the start folder. I had some issues. I am still not sure how to get consecuitive commands that share the same environment running.  So I simply appended my function name after defining it in my script.  I did not use the "-file" option but invoked the script like a command from a cmd.exe file.  This cmd.exe file still requires me to type an Administrative password after startup. Not quite sure how to get around that... &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;:: Powershell startup to pump established connections to the Event Log &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;:: see &lt;span class="Apple-style-span" style="font-family: Georgia; "&gt;&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/List-TCPConnections_Advanced.ps1"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;http://www.rmfdevelopment.com/PowerShell_Scripts/List-TCPConnections_Advanced.ps1&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo Powershell -windowStyle hidden -noexit -noprofile "&amp;amp; D:\PS1\netstat_Established_log_startup.ps1" &gt;TCPListen.cmd&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;runas /profile /env /user:Administrator TCPListen.cmd&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-4568259981805941681?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/4568259981805941681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=4568259981805941681&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4568259981805941681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4568259981805941681'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/03/i-experimented-with-powershell-script.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-133424821519919222</id><published>2009-03-24T21:37:00.000-07:00</published><updated>2011-05-19T09:15:21.091-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='meta-programming;Parameters;Create-Metadata;trace-command'/><title type='text'>Metadata</title><content type='html'>&lt;div&gt;&lt;div&gt;Jason Shirk's &lt;a href="http://blogs.msdn.com/powershell/archive/2009/03/13/dir-a-d.aspx#comments"&gt;excellent post&lt;/a&gt; on meta-programming inspired this function and alias I have added to my profile to help me get a handle on the use and format of paramaters in CTP2 v3 scripts.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function Create-Metadata($args0) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;$args0 = new-object System.Management.Automation.CommandMetadata (get-command $args0)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;[System.Management.Automation.ProxyCommand]::Create($args0) | out-file ProxyCommand.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;more ProxyCommand.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Set-Alias cm Create-Metadata&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Run as below:&lt;/div&gt;&lt;div&gt;CM("trace-command")&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[CmdletBinding(DefaultParameterSetName='expressionSet')]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;param(&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Parameter(ValueFromPipeline=$true)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.Management.Automation.PSObject]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${InputObject},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Parameter(Mandatory=$true, Position=0)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.String[]]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${Name},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Parameter(Position=2)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.Management.Automation.PSTraceSourceOptions]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${Option},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Parameter(ParameterSetName='expressionSet', Mandatory=$true, Position=1)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.Management.Automation.ScriptBlock]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${Expression},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Parameter(ParameterSetName='commandSet', Mandatory=$true, Position=1)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.String]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${Command},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Parameter(ParameterSetName='commandSet', ValueFromRemainingArguments=$true)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Alias('Args')]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.Object[]]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${ArgumentList},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.Diagnostics.TraceOptions]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${ListenerOption},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[Alias('PSPath')]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;[System.String]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;${FilePath},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;.....&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-133424821519919222?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/133424821519919222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=133424821519919222&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/133424821519919222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/133424821519919222'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/03/jason-shirks-excellent-post-on-meta.html' title='Metadata'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-7510171717402786604</id><published>2009-03-24T21:17:00.000-07:00</published><updated>2009-03-24T21:52:18.381-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell:tlist substitute;get-process;find-modules;FileVersion;FileVersionInfo;loaded dlls'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Some notes on FileVersionInfo, finding Modules, loaded dlls:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;(get-process -id $pid).modules | %{$_} | fl * | more&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Size              : 152&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Company           : Microsoft Corporation&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;FileVersion       : 6.1.6949.0 (fbl_srv_powershell_ctp(srvbld).081105-1651)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;ProductVersion    : 6.1.6949.0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Description       : Windows PowerShell&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Product           : Microsoft? Windows? Operating System&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;ModuleName        : PowerShell.exe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;FileName          : C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;BaseAddress       : 579928064&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;ModuleMemorySize  : 155648&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;EntryPointAddress : 579954429&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;FileVersionInfo   : File:             C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    InternalName:     POWERSHELL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    OriginalFilename: PowerShell.EXE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    FileVersion:      6.1.6949.0 (fbl_srv_powershell_ctp(srvbld).081105-1651)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    FileDescription:  Windows PowerShell&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    Product:          Microsoft? Windows? Operating System&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    ProductVersion:   6.1.6949.0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    Debug:            False&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    Patched:          False&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    PreRelease:       False&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    PrivateBuild:     True&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    SpecialBuild:     False&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;                    Language:         English (United States)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;....&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;A workable tlist substitute:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$a =foreach ($id in (get-process)) {write $id.Name,$id.Size,$id.modules}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$a | more&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;alg&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;   Size(K) ModuleName                                         FileName&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;   ------- ----------                                         --------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        52 alg.exe                                            C:\WINDOWS\System32\alg.exe&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       700 ntdll.dll                                          C:\WINDOWS\system32\ntdll.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       984 kernel32.dll                                       C:\WINDOWS\system32\kernel32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       352 msvcrt.dll                                         C:\WINDOWS\system32\msvcrt.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        68 ATL.DLL                                            C:\WINDOWS\System32\ATL.DLL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       580 USER32.dll                                         C:\WINDOWS\system32\USER32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       292 GDI32.dll                                          C:\WINDOWS\system32\GDI32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       620 ADVAPI32.dll                                       C:\WINDOWS\system32\ADVAPI32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       584 RPCRT4.dll                                         C:\WINDOWS\system32\RPCRT4.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        68 Secur32.dll                                        C:\WINDOWS\system32\Secur32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      1268 ole32.dll                                          C:\WINDOWS\system32\ole32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       556 OLEAUT32.dll                                       C:\WINDOWS\system32\OLEAUT32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        36 WSOCK32.dll                                        C:\WINDOWS\System32\WSOCK32.dll&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;.....&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-7510171717402786604?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/7510171717402786604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=7510171717402786604&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7510171717402786604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7510171717402786604'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/03/some-notes-on-fileversioninfo-finding.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-7127871977449081089</id><published>2009-03-16T21:40:00.000-07:00</published><updated>2009-03-18T11:06:37.981-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cmd.exe; powershell; here string;Start-Process'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;This will be worth some more investigation.  I can send a Powershell array of cmd.exe strings to the cmd.exe interpreter and pass cmd.exe a Powershell "here string" that will passthru a Powershell variable to the cmd.exe interpreter. Be interesting to next see if I can reverse the process.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;# writes out time and date from cmd.exe&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;write "Time and Date from CMD.EXE:" &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$Global:command = &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;"time /t",&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;"date /t"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;out-file -inputobject $command -encoding ASCII -filepath $pwd\cmd.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Start-Process cmd.exe -argument /Q -nonewwindow -wait -redirectstandardinput $pwd\cmd.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#set date in cmd.exe with UNIX style 'get-date' &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;write "Set cmd.exe date with (get-date -uformat)"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$DNT= get-date -uformat %m/%d/%Y&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$Global:command =&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;@"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;date $DNT&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;"@&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;out-file -inputobject $command -encoding ASCII -filepath $pwd\cmd.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Start-Process cmd.exe -argument /Q -nonewwindow -wait -redirectstandardinput $pwd\cmd.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This also works well to enter multiple lines to be interpreted by cmd.exe:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;function copy_con {[console]::In.ReadToEnd()}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;write "Enter lines into copy_con to be interpreted by cmd.exe. End the list with CTRL-C:"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$Global:command =  copy_con&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;out-file -inputobject $command -encoding ASCII -filepath $pwd\cmd.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Start-Process cmd.exe -argument /Q -nonewwindow -wait -redirectstandardinput $pwd\cmd.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;prompt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;This doesn't work yet, but probably could with some work:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function Start-Cmd($parameter1) {Start-Process cmd.exe -argument /Q -nonewwindow -wait -redirectstandardinput $parameter1}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Start-cmd dir&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Start-Process : This command cannot be executed because either the parameter 'RedirectStandardInput 'D:\PS1\dir'' has an invalid value or cannot be u&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;sed with this command. Give a valid input and Run your command again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;At line:1 char:47&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;+ function Start-Cmd($parameter1) {Start-Process &lt;&lt;&lt;&lt;  cmd.exe -argument /Q -nonewwindow -wait -redirectstandardinput $parameter1}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    + CategoryInfo          : InvalidOperation: (:) [Start-Process], FileNotFoundException&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    + FullyQualifiedErrorId : FileNotFoundException,Microsoft.PowerShell.Commands.StartProcessCommand&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-7127871977449081089?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/7127871977449081089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=7127871977449081089&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7127871977449081089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7127871977449081089'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/03/this-will-be-worth-some-more.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-4685615583289979738</id><published>2009-03-13T15:33:00.000-07:00</published><updated>2011-07-30T10:39:45.381-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Finding Time;Get-WmiObject -class Win32_PerfFormattedData_PerfOS_System;Get-WmiObject -class Win32_OperatingSystem;LastBootUpTime;LocalDateTime;uptime.exe;[DateTime];UTC;'/><title type='text'>Finding Time</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;FindingTimes in Powershell (and cmd.exe). &amp;nbsp;I have put the script &lt;/span&gt;&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/FindingTime.ps1"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;FindingTimes.ps1&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;in my repository. &amp;nbsp;I am returning various results. &amp;nbsp;This script demonstrates different methods of finding System Time and Uptime on Windows&amp;nbsp;with cmd.exe or Powershell. &amp;nbsp;There is a discrepancy in the method results between .NET&amp;nbsp;and GWMI. I do not know what is causing this, I suspect the hibernate process or uptime.exe&amp;nbsp;heartbeat function (from MS Reskit) is causing the descrepancy.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;PS D:\PS1&amp;gt; .\FindingTime_001.ps1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Finding Current and Boot Times from Powershell: A Medley of Methods&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;System Times:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Time now using Get-Date:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;03/16/2009 19:41:35&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;DisplayHint : DateTime&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;DateTime &amp;nbsp; &amp;nbsp;: Monday, March 16, 2009 7:41:35 PM&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 3/16/2009 12:00:00 AM&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Day &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : 16&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;DayOfWeek &amp;nbsp; : Monday&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;DayOfYear &amp;nbsp; : 75&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Hour &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 19&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Kind &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: Local&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Millisecond : 343&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Minute &amp;nbsp; &amp;nbsp; &amp;nbsp;: 41&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Month &amp;nbsp; &amp;nbsp; &amp;nbsp; : 3&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Second &amp;nbsp; &amp;nbsp; &amp;nbsp;: 35&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Ticks &amp;nbsp; &amp;nbsp; &amp;nbsp; : 633728292953437500&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;TimeOfDay &amp;nbsp; : 19:41:35.3437500&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Year &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 2009&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Time From .NET:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.NET Date Time Now is 03/16/2009 19:41:35&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.NET UTC Date Time Now is 03/17/2009 02:41:35&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.NET Time is Date Hours Minutes Seconds MS : 16 19 41 35 359&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.NET UTC Time is Date Hours Minutes Seconds MS : 17 2 41 35 359&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Time from WMI Win32_OperatingSystem LocalDateTime:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;03/16/2009 19:41:35&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Time and Date from CMD.EXE:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Microsoft Windows XP [Version 5.1.2600]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;(C) Copyright 1985-2001 Microsoft Corp.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;D:\PS1&amp;gt;07:41 PM&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;D:\PS1&amp;gt;Mon 03/16/2009&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;D:\PS1&amp;gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;System UpTimes:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptime for cmd.exe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Microsoft Windows XP [Version 5.1.2600]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;(C) Copyright 1985-2001 Microsoft Corp.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;D:\PS1&amp;gt;Running cmd.exe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;D:\PS1&amp;gt;Current TimeStamp is 03.16.2009_19.41.35.59&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Statistics since 3/14/2009 9:45 AM&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptime From Microsoft Resource Kit: 'D:\uptime.exe:'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;\\RMFMEDIA has been up for: 2 day(s), 9 hour(s), 57 minute(s), 26 second(s)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptimes from the System Event 6009 Log Query and (get-date): Elapsed from Last Boot Times&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Last boot Date/Time -- LBTs from Current Time in Days.Hours.Minutes.Seconds&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;03/14/2009 09:44:52 -- 2.9.56.44&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;03/04/2009 14:25:00 -- 12.5.16.36&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;02/20/2009 01:24:35 -- 24.18.17.1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;02/19/2009 20:47:39 -- 24.22.53.57&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;02/18/2009 11:10:45 -- 26.8.30.51&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;02/16/2009 10:24:21 -- 28.9.17.15&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;02/16/2009 10:10:47 -- 28.9.30.49&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;02/03/2009 11:33:24 -- 41.8.8.12&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;01/15/2009 22:40:17 -- 59.21.1.19&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;01/09/2009 09:52:51 -- 66.9.48.45&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;01/07/2009 17:39:39 -- 68.2.1.57&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;01/05/2009 18:30:06 -- 70.1.11.30&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;01/05/2009 11:01:59 -- 70.8.39.37&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;12/24/2008 11:20:21 -- 82.8.21.15&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptime from Get-WmiObject -class Win32_PerfFormattedData_PerfOS_System&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Number of Days = 2.41489583333333&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Number of Hours = 57.9575&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Number of Minutes = 3477.45&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Number of Seconds 208647&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptme from GWMI Win32_OperatingSystem -Namespace root\CIMV2 LastBootUpTime and (get-date)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Last Boot Time: 03/16/2009 03:33:43 Current Time: 03/16/2009 19:41:36&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptimes from Last Boot in Days.Hours.Minutes.Seconds = 0.16.7.52&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptime from Get-WmiObject -class Win32_OperatingSystem LastBootUpTime and LocalDateTime&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptime is 0.16.7.52&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Uptime from D:\cygwin\bin\uptime.exe (procps version 3.2.6)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande'; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;19:41:36 up 16:07, &amp;nbsp;1 user, &amp;nbsp;load average: 0.00, 0.00, 0.00&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'lucida grande';"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-4685615583289979738?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/4685615583289979738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=4685615583289979738&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4685615583289979738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4685615583289979738'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/03/findingtimes-in-powershell-and-cmd.html' title='Finding Time'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-9011610985529530254</id><published>2009-03-06T18:49:00.000-08:00</published><updated>2009-03-06T19:01:14.921-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='brilliant coders'/><category scheme='http://www.blogger.com/atom/ns#' term='Jaykul Bennett'/><category scheme='http://www.blogger.com/atom/ns#' term='Josh Einstein'/><title type='text'></title><content type='html'>&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The last few days have been horrible for me.  There is a level of knowledge I am missing about .NET and Powershell that is preventing me from doing great new creative things. Fortunately, there are brilliant coders like Josh Einstein and others stumbling across similar issues. For example:&lt;/span&gt;&lt;/span&gt;&lt;a href="http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/40356985a4e3e015/9112f551260968f0?hl=en#9112f551260968f0"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/40356985a4e3e015/9112f551260968f0?hl=en#9112f551260968f0&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;It's amazing how useful ad-hoc discussions about new features in CTPv3 are to many us. "Jaykul"Bennett posted one I am sure is being mined from all over the world:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://huddledmasses.org/a-guide-to-advanced-functions/#more-1116"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;http://huddledmasses.org/a-guide-to-advanced-functions/#more-1116&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Oh well, back to Holmes, Payette, Deshev, and others and see if I can figure out what I am doing. Perhaps some time spent just reading .NET  and C# books would be useful....hmmmm...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I've posted this:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"In learning Powershell, once you are over the humps of the pipeline, &lt;br /&gt;automatic variables, conditional loops, .NET, network admin tricks &lt;br /&gt;etc. (e.g. a "better cmd line"),  you are faced with absorbing the &lt;br /&gt;intent of the architects in creating and using functionality like: &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;params for Functions &lt;br /&gt;scriptlets &lt;br /&gt;[cmdletbinding] &lt;br /&gt;Cmdlet architecture &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;etc. and a subset of other dev skillsets like error handling, &lt;br /&gt;debugging that would make the difference for between someone who is &lt;br /&gt;rewriting his 10 line cmd scripts or someone who is creating &lt;br /&gt;significant functionality in Powershell scripts.  I think what I would &lt;br /&gt;like is book with a title like "Design Patterns for Powershell" that &lt;br /&gt;provides examples and discussion on how to best implement Powershell &lt;br /&gt;for performance, for re-usable design, when something more "lambda" &lt;br /&gt;than "imperative" makes sense and the converse.  Currently, there is a &lt;br /&gt;lot of research leg work to go through to come up with this "all by &lt;br /&gt;your lonesome".  Other pieces of this might be a Visio or VisStudio &lt;br /&gt;design template(s), advice on writing testable and easily debugged &lt;br /&gt;functions, PSIE extensions that provide for intellisense or design &lt;br /&gt;templates. It's true folks like Bennet, Lee, Snover, Payette, Holmes, &lt;br /&gt;and the Powershell team have some discussion and some examples  about &lt;br /&gt;this...but I find myself with many questions...and feeling a little &lt;br /&gt;confused.  Do I need to master "Design Patterns for C#" or understand &lt;br /&gt;Functional Language style vs. Imperative Language issues before I &lt;br /&gt;write elegant, correct, re-usable functions, and scriplets for &lt;br /&gt;Powershell?"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-9011610985529530254?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/9011610985529530254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=9011610985529530254&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/9011610985529530254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/9011610985529530254'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/03/last-few-days-have-been-horrible-for-me.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2116267933988750554</id><published>2009-02-23T13:51:00.000-08:00</published><updated>2009-02-23T14:07:31.274-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='trace-command'/><category scheme='http://www.blogger.com/atom/ns#' term='Script Block'/><category scheme='http://www.blogger.com/atom/ns#' term='get-variable'/><category scheme='http://www.blogger.com/atom/ns#' term='Debug Print'/><category scheme='http://www.blogger.com/atom/ns#' term='scope'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Teaching myself debugging...some random notes:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;There are no locals or watch windows in the CTP2  v3 ISE. They are sorely needed.  However, there is a plethora of debugging facilities in Powershell. Today's post is about my morning exploration  of such facilities. I have a function &lt;/span&gt;&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/List-TCPConnections_Advanced.ps1"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;List-TCPConnections &lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;that works fine with one argument but doesn't work with multiple pipeline values.  This param: [ValueFromPipeline] gives me a "load assembly" error message and I am not ready to debug that right now ;-) .  I have a cmd.exe test script to give myself connection states: for /l %i in (1000,100,10000) do wget %i.com.  I run through TCP Connection States like this: '0..11 | %{List-TCPConnections $_}'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Under such test, the function below works as expected, pumping out connection states, IP addresses to console and (classic) EventLog:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;function global:List-TCPEstablished {do {List-TCPConnections 5} while (1)}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This  (pipeline function) &lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;does not work&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;function global:List-TCPAllStates {do {0..11 | %{List-TCPConnections $_}} while (1)}  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Originally, I tried some simple 'print debug' type strategies with "get-variable" (gv) and  "out-gridview". But the compound variables do not Invoke() (for me)  in "out-gridview" so these strategies weren't helping. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;   (gv -s 0)| out-gridview ## scope for everything&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;   (gv -s 1)| out-gridview ## one scope up&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;   ## Just what the script gives subtracted from everything&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    compare-object (gv -s script) (gv -s 0) | out-gridview&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Along the same lines, I thought I would be more tricky and pump out  variable arrays I wanted to watch  as needed: &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $local_out=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    "last_netblock",&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    "netblock",&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    "State" &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $dbg = $local_out | %{gv ($_)}; $dbg | out-gridview&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;That still wasn't helpful for the above reasons. Below, the trace command dumps lots of information, but still doesn't help me with logic errors:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;trace-command -name metadata,parameterbinding,cmdlet -option ExecutionFlow,data,errors {do {0..11 | %{List-TCPConnections $_};sleep -s 5} while (1)}-pshost&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Using a script block at the start of my Begin{} function and calling it as needed  was most useful at this point.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## Debug Print Script Block&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $Global:locals_out=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $State&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $last_netblock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    write .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $netblock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; ## Debug&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    write $Locals_out.Invoke()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;to be continued...&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2116267933988750554?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2116267933988750554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2116267933988750554&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2116267933988750554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2116267933988750554'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/02/teaching-myself-debugging.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2848392725939836227</id><published>2009-02-18T09:34:00.001-08:00</published><updated>2009-04-06T09:32:39.519-07:00</updated><title type='text'></title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Three of the four last posts have resulted in a considerable speed up of my Powershell learning curve. In my &lt;/span&gt;&lt;a href="http://horizontal-logic.blogspot.com/2009/02/what-i-was-looking-for-is-simple-script.html"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;February 6th post&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; , I created a (not so) simple script to log all new Established TCP Connections.  'Compare-Object' was very useful in finding the diff between one netblock and the last. In my &lt;/span&gt;&lt;a href="http://horizontal-logic.blogspot.com/2009/02/code-below-is-failing-me-with-type.html"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;February 12th post&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;, I worked through how to send those Established TCP Connections to the (classic) Event Viewer.  I then spent quite a bit of time trying to build a script that iterated all TCPStates past the current TCP Connection diff in an attempt to send all TCP State Connections to the Event Log.  I spent a lot of time failing to create such an iteration. (Update February 25): Eventually, I did create a function(s) which will log select TCP Connection States. It is posted here:&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/List-TCPConnections_Advanced.ps1" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); text-decoration: none;"&gt; &lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style=" ;font-size:16px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(85, 26, 139); text-decoration: underline;"&gt;&lt;a href="http://www.rmfdevelopment.com/PowerShell_Scripts/List-TCPConnections_Advanced.ps1"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;http://www.rmfdevelopment.com/PowerShell_Scripts/List-TCPConnections_Advanced.ps1&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; There are a ton of issues for me to work out with Powershell involving .NET overloads, Functions Types, Iteration, Parameters....But the foreach-object can be used in a block to process an  array line by line. Very simple and straightforward:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'Times New Roman';"&gt;&lt;div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;       $global:c = compare-object -referenceobject $State_netblock -differenceobject $State_last_netblock&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;       if ($c -eq $null){}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;       elseif($c.SideIndicator -eq "&lt;=" )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;          {$C |&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                foreach-object -process{                                    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $LocalAddress = $_.InputObject.LocalEndPoint.Address&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $RemoteAddress = $_.InputObject.RemoteEndPoint.Address           &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $LocalPort = $_.InputObject.LocalEndPoint.Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $RemotePort = $_.InputObject.RemoteEndPoint.Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $TCP_State = $TCPState[$State]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $name = [System.Net.DNS]::Resolve("$RemoteAddress")&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $name_canon = $name.hostname&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                write "$TimeNow $RemoteAddress $name_canon : $RemotePort $TCP_State"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $EventLog.Source = "$name_canon" &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                $EventLog.WriteEntry("$LocalAddress $TCP_State connection to $RemoteAddress($name_canon)&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;from Local Port: $LocalPort to Remote Port: $RemotePort",$infoevent,$RemotePort,$State) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                } &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;           }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Update on event log queries for the event log generated by the above script:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Source&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Source_8NetUnique = get-eventlog -log EstablishedTCPConnections  | ?{$_.Source -match "^8\."} | sort-object -property Source -unique&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SourceNetUnique = get-eventlog -log EstablishedTCPConnections  | ?{$_.Source -match "^*"} | sort-object -property Source -unique&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SourceNetUniqueGroupBy = get-eventlog -log EstablishedTCPConnections  | ?{$_.Source -match "^*"} | group-object -property Source | Sort-object -property count -descending&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Function Get-NetName ($CountNetName) { get-eventlog -log EstablishedTCPConnections  | ?{$_.Source -match "^$CountNetName"} |  group-object -property Source | Sort-object -property count -descending}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;foreach($i in (gc alpha.txt)){get-netname $i}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Port&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Port80 = get-eventlog -log EstablishedTCPConnections  | ?{$_.EventID -match "^80"}|  sort-object -property TimeGenerated -descending&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$EventIDNetUnique = get-eventlog -log EstablishedTCPConnections  | ?{$_.EventID -match "^*"} | sort-object -property EventID -unique&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$EventIDNetUniqueGroupBy = get-eventlog -log EstablishedTCPConnections  | ?{$_.EventID -match "^*"} | group-object -property EventID | Sort-object -property count -descending&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Function Get-PortType ($CountPortType) { get-eventlog -log EstablishedTCPConnections  | ?{$_.EventID -match "^$CountPortType"} |  group-object -property EventID | Sort-object -property count -descending}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Source = get-eventlog -log EstablishedTCPConnections | group-object -property Source | sort-object -property Count -descending&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Port = get-eventlog -log EstablishedTCPConnections | group-object -property EventID  | sort-object -property Count -descending&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$UniqSource = get-eventlog -log EstablishedTCPConnections |  sort-object -property Source -descending -unique &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$UniqPort = get-eventlog -log EstablishedTCPConnections |  sort-object -property EventID -descending -unique &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$UniqSource = get-eventlog -log EstablishedTCPConnections | group-object -property Source | sort-object -property Count -descending&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$UniqSource | Select Count,Name | cvhtml &gt; UniqSource.html&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$a | %{[System.Net.DNS]::Resolve($_.Source)}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$a | %{whois ($_.Source)}  &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2848392725939836227?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2848392725939836227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2848392725939836227&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2848392725939836227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2848392725939836227'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/02/three-of-four-last-posts-have-resulted.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-29945449722402316</id><published>2009-02-12T14:41:00.000-08:00</published><updated>2009-02-15T14:32:49.859-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System.Diagnostics.EventLogEntryType'/><category scheme='http://www.blogger.com/atom/ns#' term='GetIPGlobalProperties()'/><category scheme='http://www.blogger.com/atom/ns#' term='[System.Net.DNS]::Resolve'/><category scheme='http://www.blogger.com/atom/ns#' term='InputObject.LocalEndPoint'/><category scheme='http://www.blogger.com/atom/ns#' term='.Address'/><category scheme='http://www.blogger.com/atom/ns#' term='System.Diagnostics.EventLog'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This function pushes off the stack every new Established TCP connection as so:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;PS &gt;List-EstablishedTCP&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;209.62.20.43 ev1s-209-62-20-43.theplanet.com : 80&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;72.30.190.105 rc10.ysm.vip.ac2.yahoo.com : 80&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;165.160.9.37 165.160.9.37 : 80&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;66.235.133.3 dc2-3.112.2o7.net : 80&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;75.101.151.37 ec2-75-101-151-37.compute-1.amazonaws.com : 80&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;8.12.226.77 8.12.226.77 : 80&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;96.17.232.242 a96-17-232-242.deploy.akamaitechnologies.com : 80&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;It also send a message to the (classic) Event Log named "EstablishedTCPConnections" &lt;a href="http://picasaweb.google.com/rferrisx/Powershell02#5303150477551184114"&gt;as shown here&lt;/a&gt;.  One PoSh blog was very helpful with this: &lt;/span&gt;&lt;/span&gt;&lt;a href="http://winpowershell.blogspot.com/2006/07/writing-windows-events-using.html"&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;http://winpowershell.blogspot.com/2006/07/writing-windows-events-using.html&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;function Global:EstablishedTCP &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{ ## start function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $a = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $b = $a.GetActiveTcpConnections() | where{$_.State -eq "Established" }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    if ($b -ne $null -and $last_b -ne $null) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $c = compare-object $b $last_b;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    if ($c.SideIndicator -eq "&lt;=" )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        {        &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $LocalAddress = $c.InputObject.LocalEndPoint.Address&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $RemoteAddress = $c.InputObject.RemoteEndPoint.Address           &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $LocalPort = $c.InputObject.LocalEndPoint.Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $RemotePort = $c.InputObject.RemoteEndPoint.Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $name = [System.Net.DNS]::Resolve("$RemoteAddress")&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $name_canon = $name.hostname&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        write "$RemoteAddress $name_canon : $RemotePort"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $EventLog = new-object System.Diagnostics.EventLog("EstablishedTCPConnections") &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $EventLog.Source = "$name_canon" &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $infoevent = [System.Diagnostics.EventLogEntryType]::Information &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        $EventLog.WriteEntry("$LocalAddress established connection to $RemoteAddress ($name_canon) from Local Port: $LocalPort to Remote Port: $RemotePort",$infoevent,$RemotePort,01) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;start-sleep -m 100&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$global:last_b = $b&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;} ## end function Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;function global:List-EstablishedTCP {do {EstablishedTCP} while (1)}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-29945449722402316?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/29945449722402316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=29945449722402316&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/29945449722402316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/29945449722402316'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/02/code-below-is-failing-me-with-type.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-191916972136663675</id><published>2009-02-08T19:44:00.000-08:00</published><updated>2009-02-08T19:54:57.342-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershel: Hristo Deshev'/><category scheme='http://www.blogger.com/atom/ns#' term='Array to Hash'/><category scheme='http://www.blogger.com/atom/ns#' term='PS'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This is a weird peice of code inspired by some syntax I found in Hristo Deshev's interesting book: "Pro Windows Powershell". Hristo talks about converting IDictionary objects to Hash Tables.  'PS' or 'get-process' uses the PID as the hash code for the process object. This allows a construct that produces a hash table with explict PIDs as hash keys. It is too late to figure out if this side-effect would have any value to anyone.&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$script_block_ID = {ps | %{$_.ID} | Sort-object }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$dict = new-object Collections.Specialized.OrderedDictionary&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$script_block_ID.Invoke() | %{$dict[(ps -id $_ | Select Name)] = $_.GetHashCode()}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write `r`n `$dict:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$dict &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$hash = [hashtable]$dict&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write `r`n `$hash:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$hash &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[$hash:]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=cmd}                    1364                                            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=alg}                    864                                             &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=explorer}               3212                                            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=gvim}                   1852                                            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=wmiprvse}               1332                                            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=VCSExpress}             3980                                            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=wscntfy}                352                                             &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=chrome}                 2724                                            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@{Name=svchost}                1536 &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;....      &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-191916972136663675?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/191916972136663675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=191916972136663675&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/191916972136663675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/191916972136663675'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/02/this-is-weird-peice-of-code-inspired-by.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-8675764083969929112</id><published>2009-02-06T10:18:00.000-08:00</published><updated>2011-01-09T16:29:42.763-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GetIPGlobalProperties()'/><category scheme='http://www.blogger.com/atom/ns#' term='netstat'/><category scheme='http://www.blogger.com/atom/ns#' term='compare-object'/><title type='text'>Enumerating TCP Connections</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;What I was looking for is a simple script to capture all new ("Established") connections. &amp;nbsp;This could use some improve since my code has some side-effects. &amp;nbsp;'Compare-object' subtracts the diff between two arrays: the reference set and the difference set. To run this I type this at a PS prompt:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;function Est_do {do {Established} while (1)}&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Est_do | out-file $pwd\Established.txt&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;function global:Established&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Begin&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$a = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Process&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if ($b -ne $null) {$last_b = $b}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$b = $a.GetActiveTcpConnections()&amp;nbsp;&amp;nbsp;&amp;nbsp;| where{$_.State -eq "Established" }&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if ($last_b -ne $null)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{$c = compare-object $last_b $b;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ($c.SideIndicator -eq "=&amp;gt;" ) {write $c.InputObject | ft -HideTableHeaders} &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; $global:last_b = $b&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;End&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;start-sleep -m 250&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;} &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;[Established.txt] :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Established 192.168.0.8:3419 209.85.147.83:80&lt;/div&gt;&lt;div&gt;Established 192.168.0.8:3420 74.125.19.191:80&lt;/div&gt;&lt;div&gt;Established 192.168.0.8:3422 74.125.19.191:80&lt;/div&gt;&lt;div&gt;...&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-8675764083969929112?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/8675764083969929112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=8675764083969929112&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8675764083969929112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8675764083969929112'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/02/what-i-was-looking-for-is-simple-script.html' title='Enumerating TCP Connections'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-5235932646195973058</id><published>2009-02-05T15:41:00.000-08:00</published><updated>2009-02-05T15:58:53.895-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lsof tcpview.exe netstat -bno'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I spent some time seeing if Powershell could deliver some 'lsof' functionality easily with little luck. Few windows utilities do this now. Some exceptions are 'netstat -bno' (XPSP3) or tcpview.exe.  Powershell (or at least me with Powershell) can't do much with the TCPState interface despite the presence of static members:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;PS &gt; [System.Net.NetworkInformation.TcpState].GetMembers() | % {$_.Name}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Unknown&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Closed&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Listen&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SynSent&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SynReceived&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;FinWait1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;FinWait2&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;CloseWait&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Closing&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;LastAck&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;TimeWait&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;DeleteTcb&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This interface: [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;was more useful:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[netstat.ps1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$a = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$b = $a.GetActiveTcpListeners() | Select Address,Port | Sort Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$c = $a.GetActiveUDPListeners() | Select Address,Port | Sort Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$d = $a.GetActiveTcpConnections() | Select LocalEndPoint,RemoteEndPoint,State | Sort State,RemoteEndPoint&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "TCP Listeners" $b | ft -auto&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "UDP Listeners" $c | ft -auto&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "TCP Active Connections" $d | ft -auto&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;PS &gt;.\netstat.ps1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;TCP Listeners&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Address     Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;-------     ----&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0.0.0.0      135&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.5  139&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8  139&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0.0.0.0      445&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1   1027&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0.0.0.0     3389&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;UDP Listeners&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Address     Port&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;-------     ----&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1    123&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8  123&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.5  123&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.5  137&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8  137&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.5  138&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8  138&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0.0.0.0      445&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0.0.0.0      500&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.5 1900&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1   1900&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8 1900&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1   2139&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1   2683&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1   2704&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0.0.0.0     4500&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;TCP Active Connections&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;LocalEndPoint    RemoteEndPoint          State&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;-------------    --------------          -----&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1:1266   127.0.0.1:1265    Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1:1265   127.0.0.1:1266    Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1:1268   127.0.0.1:1267    Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;127.0.0.1:1267   127.0.0.1:1268    Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8:2877 65.55.11.254:80   Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8:2876 72.14.207.191:80  Established&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;192.168.0.8:1062 209.85.173.102:80   CloseWait&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-5235932646195973058?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/5235932646195973058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=5235932646195973058&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5235932646195973058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5235932646195973058'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/02/i-spent-some-time-seeing-if-powershell.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-446258026926702065</id><published>2009-01-27T10:58:00.000-08:00</published><updated>2009-01-30T03:43:50.928-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='uptime'/><category scheme='http://www.blogger.com/atom/ns#' term='Parsing Event logs'/><category scheme='http://www.blogger.com/atom/ns#' term='Event ID 36'/><category scheme='http://www.blogger.com/atom/ns#' term='system reliability'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This is my third update to this script.  I think this script will finally push me into "programming like a real man" (e.g. with functions, params, hash arrays, throws, traps other optimizations) e.g. &lt;span class="Apple-style-span"  style=" ;font-family:Georgia;"&gt;&lt;a href="http://rmfdevelopment.com/PowerShell_Scripts/QueryEventFunction.ps1"&gt;http://rmfdevelopment.com/PowerShell_Scripts/QueryEventFunction.ps1&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:Georgia;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;Interestingly, I found System Event ID 36 breaks my script. It is a failure of the Windows Time Service and I think I have found a defect in Time/Date formatting:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## Takes Event Log queries...and finds elapsed time from event&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;# Default queries localhost system shutdown (EventID 6009)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;# E.G. .\EventLogQueries.ps1 System 4072&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;# E.G .  6005..6009 | %{.\EventLogQueries.ps1 System $_ }    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;if ($args[0] -eq $Null) {$Log_Type = "System"} else {$Log_Type = $args[0]}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;if ($args[1] -eq $Null) {$Event_ID = 6009} else {$Event_ID = $args[1]}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;write $args[1]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## TODO for remote and other properties:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## if ($args[3] = $Null) {$Computer = localhost} else {$args[3] = $Computer}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;# query Event Log&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$EventLog = get-eventlog -log $Log_Type | Select Message,EventID,TimeGenerated&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$Event = $EventLog | ?{$_.eventID -eq $Event_ID}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$EventID = $Event | %{$_.eventID}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$Message = $Event | %{$_.Message}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$TimeGenerated = $Event | %{$_.TimeGenerated}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## TODO: Needs Trap or Throw for bad date or time format from Microsoft like for Event ID 36&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## EventID 36 will break this script because....(??) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## if EventID is null, discard query&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;if  ($LogType = "System" -and $EventID -eq 36) {$EventID = $NULL;write "Skip System EventID 36 because it breaks this script"}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;if  ($EventID -ne $NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    # Find elapsed time, total restarts, restarts/days and generate some arrays&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    ## DBG::$test_EventID = $EventID[0]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    ## DBG::$test_Args_1  = $Args[1]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    ## DBG::write "Args[1]:$test_Args_1 -- Date/Time -- Elapsed Time (D.H.M.S)"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    write  "EventID -- Message -- Date/Time -- Elapsed Time (D.H.M.S)"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $array_count = ($Event).count - 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $total_events = ($Event).count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $curr_date = get-date&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $first_event_date = $TimeGenerated[$array_count]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $last_event_date = $TimeGenerated[0]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $event_time_span =($curr_date - $first_event_date)  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $elapsed = $TimeGenerated[0..$array_count] | %{($curr_date - $_)}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $AverageDaysBetweenEvents = $event_time_span.Days%$total_events&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    ## Report Data&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    ## What happens if data field is null?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    0..$array_count | %{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $days = $elapsed[$_].days;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $hours = $elapsed[$_].hours;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $minutes = $elapsed[$_].minutes;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $seconds = $elapsed[$_].seconds;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $EventIDPrint = $EventID[$_];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $MessagePrint = $Message[$_];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $TimeGeneratedPrint = $TimeGenerated[$_];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    write "$EventIDPrint,$MessagePrint,$TimeGeneratedPrint,$days.$hours.$minutes.$seconds" }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;if  ($EventID -ne $NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{ &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;write "Number of Events:$total_events First Occurrence:$first_event_date Last Occurrence:$last_event_date Average Days Between Events:$AverageDaysBetweenEvents"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-446258026926702065?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/446258026926702065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=446258026926702065&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/446258026926702065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/446258026926702065'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/01/this-is-my-third-update-to-this-script.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-453537538941314066</id><published>2009-01-23T13:40:00.000-08:00</published><updated>2009-01-23T13:47:34.539-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='uptime'/><category scheme='http://www.blogger.com/atom/ns#' term='Parsing Event logs'/><category scheme='http://www.blogger.com/atom/ns#' term='shutdown'/><category scheme='http://www.blogger.com/atom/ns#' term='6005..6009'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# Takes Event Log queries...and finds elapsed time from event&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# E.G .  6005..6009 | %{.\EventLogQueries.ps1 System $_ }&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if ($args[0] -eq $Null) {$Log_Type = "System"} else {$Log_Type = $args[0]}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if ($args[1] -eq $Null) {$Event_ID = 6009} else {$Event_ID = $args[1]}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# query Event Log&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$EventLog = get-eventlog -log $Log_Type&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$EventID = $EventLog | ?{$_.eventID -eq $Event_ID}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# If EventID is null, discard query&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if  ($EventID -ne $NULL) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    # Find Elapsed Time and Generate Array    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    write "Event ID -- Date/Time -- Elapsed Time (D.H.M.S)"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $LogType_EventID_MsgProperty = $EventID | %{$_.TimeGenerated}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $count = ($LogType_EventID_MsgProperty).count - 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $curr_date = get-date&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $array = $LogType_EventID_MsgProperty[0..$count] | %{($curr_date - $_)}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    # Report Data&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    0..$count | %{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $days = $array[$_].days;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $hours = $array[$_].hours;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $minutes = $array[$_].minutes;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $seconds = $array[$_].seconds;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    $date = $LogType_EventID_MsgProperty[$_];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    write "$Event_ID -- $date -- $days.$hours.$minutes.$seconds";}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; } &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Output:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;PS &gt;6005..6009 | %{.\EventLogQueries.ps1 System $_ }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Event ID -- Date/Time -- Elapsed Time (D.H.M.S)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 01/15/2009 22:40:17 -- 7.15.0.2&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 01/09/2009 09:52:51 -- 14.3.47.28&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 01/07/2009 17:39:39 -- 15.20.0.40&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 01/05/2009 18:30:06 -- 17.19.10.13&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 01/05/2009 11:01:59 -- 18.2.38.20&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 12/24/2008 11:20:21 -- 30.2.19.58&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 12/21/2008 10:01:15 -- 33.3.39.4&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 12/19/2008 09:23:52 -- 35.4.16.27&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 12/11/2008 08:04:59 -- 43.5.35.20&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6005 -- 12/03/2008 08:10:23 -- 51.5.29.56&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Event ID -- Date/Time -- Elapsed Time (D.H.M.S)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6006 -- 01/15/2009 09:28:14 -- 8.4.12.6&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6006 -- 01/09/2009 09:52:04 -- 14.3.48.16&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6006 -- 01/07/2009 17:38:05 -- 15.20.2.15&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6006 -- 01/05/2009 11:00:36 -- 18.2.39.44&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6006 -- 12/19/2008 09:22:42 -- 35.4.17.38&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6006 -- 12/11/2008 08:03:46 -- 43.5.36.34&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Event ID -- Date/Time -- Elapsed Time (D.H.M.S)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 01/15/2009 22:40:17 -- 7.15.0.5&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 01/09/2009 09:52:51 -- 14.3.47.31&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 01/07/2009 17:39:39 -- 15.20.0.43&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 01/05/2009 18:30:06 -- 17.19.10.16&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 01/05/2009 11:01:59 -- 18.2.38.23&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 12/24/2008 11:20:21 -- 30.2.20.1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 12/21/2008 10:01:15 -- 33.3.39.7&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 12/19/2008 09:23:52 -- 35.4.16.30&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 12/11/2008 08:04:59 -- 43.5.35.23&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6009 -- 12/03/2008 08:10:23 -- 51.5.29.59&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-453537538941314066?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/453537538941314066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=453537538941314066&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/453537538941314066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/453537538941314066'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/01/takes-event-log-queries.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2068452107950077269</id><published>2009-01-22T19:42:00.001-08:00</published><updated>2009-01-22T19:43:49.574-08:00</updated><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Last Boot Times.  A Microsoft.public.windows.powershell forum question made me think about how important historical knowledge of last boot times are to most administrators. Microsoft has an excellent utility (uptime.exe at http://support.microsoft.com/kb/232243) that records significant system events and estimates system availability. I wanted to see how difficult such a utility would be to recreate in Powershell. I was surprised to find some reporting differeneces for last uptime between the different approaches. To be continued...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;##. \LastBootWMI.ps1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$colItems = Gwmi Win32_OperatingSystem -Namespace "root\CIMV2" -ComputerName localhost&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$LB = $ColItems.ConvertToDateTime($ColItems.LastBootUpTime)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$array = (get-date).subtract($LB)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Curr_date = (get-date) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$days = $array.days&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$hours = $array.hours&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$minutes = $array.minutes&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$seconds = $array.seconds&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "Last Boot Time: $LB Current Time: $Curr_date" &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "Time from Last Boot in Days.Hours.Minutes.Seconds = $days.$hours.$minutes.$seconds"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;PS &gt;.\LastBootWMI.ps1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Last Boot Time: 01/20/2009 03:42:31 Current Time: 01/22/2009 19:00:25&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Time from Last Boot in Days.Hours.Minutes.Seconds = 2.15.17.53&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;## .\LastBootTimes.ps1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SysEvtLog = get-eventlog -log System&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Evt_ID_6009 = $SysEvtLog | ?{$_.eventID -eq 6009}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$Evt_ID_6009TG = $Evt_ID_6009 | %{$_.TimeGenerated}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$count = ($Evt_ID_6009TG.count) -1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$curr_date = get-date&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$array = $Evt_ID_6009TG[0..$count] | %{($curr_date - $_)}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "Last boot Date/Time -- LBTs from Current Time in Days.Hours.Minutes.Seconds"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;0..$count | %{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$days = $array[$_].days;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$hours = $array[$_].hours;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$minutes = $array[$_].minutes;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$seconds = $array[$_].seconds;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$date = $Evt_ID_6009TG[$_];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;write "$date -- $days.$hours.$minutes.$seconds";}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;PS &gt;.\LastBootTimes.ps1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Last boot Date/Time -- LBTs from Current Time in Days.Hours.Minutes.Seconds&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;01/15/2009 22:40:17 -- 6.20.20.5&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;01/09/2009 09:52:51 -- 13.9.7.31&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;01/07/2009 17:39:39 -- 15.1.20.43&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;01/05/2009 18:30:06 -- 17.0.30.16&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;01/05/2009 11:01:59 -- 17.7.58.23&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/24/2008 11:20:21 -- 29.7.40.1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/21/2008 10:01:15 -- 32.8.59.7&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/19/2008 09:23:52 -- 34.9.36.30&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/11/2008 08:04:59 -- 42.10.55.23&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/03/2008 08:10:23 -- 50.10.49.59&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;D:\&gt;uptime.exe /s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Uptime Report for: \\RMFMEDIA&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Current OS: Microsoft Windows XP, Service Pack 3, Multiprocessor Free.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Time Zone: Pacific Standard Time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;System Events as of 1/22/2009 7:13:12 PM:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Date:      Time:        Event:               Comment:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;---------- -----------  -------------------  -----------------------------------&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; 12/3/2008  8:10:23 AM  Boot&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/11/2008  8:03:46 AM  Shutdown             Prior uptime:7d 23h:53m:23s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/11/2008  8:04:59 AM  Boot                 Prior downtime:0d 0h:1m:13s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/19/2008  9:22:42 AM  Shutdown             Prior uptime:8d 1h:17m:43s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/19/2008  9:23:52 AM  Boot                 Prior downtime:0d 0h:1m:10s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/21/2008 10:01:15 AM  Boot&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;12/24/2008 11:20:21 AM  Boot&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/5/2009 11:00:36 AM  Shutdown             Prior uptime:11d 23h:40m:15s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/5/2009 11:01:59 AM  Boot                 Prior downtime:0d 0h:1m:23s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/5/2009  6:30:06 PM  Boot&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/5/2009  6:30:12 PM  Bluescreen           STOP 0x0000008e&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/7/2009  5:38:05 PM  Shutdown&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/7/2009  5:39:39 PM  Boot                 Prior downtime:0d 0h:1m:34s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/9/2009  9:52:04 AM  Shutdown             Prior uptime:1d 16h:12m:25s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  1/9/2009  9:52:51 AM  Boot                 Prior downtime:0d 0h:0m:47s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; 1/15/2009  9:28:14 AM  Shutdown             Prior uptime:5d 23h:35m:23s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; 1/15/2009 10:40:17 PM  Boot                 Prior downtime:0d 13h:12m:3s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Current System Uptime: 6 day(s), 20 hour(s), 33 minute(s), 32 second(s)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2068452107950077269?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2068452107950077269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2068452107950077269&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2068452107950077269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2068452107950077269'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/01/last-boot-times.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2618617992646195673</id><published>2009-01-19T22:59:00.000-08:00</published><updated>2009-01-21T10:58:09.346-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CTP3'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='Editing In-Line'/><category scheme='http://www.blogger.com/atom/ns#' term='Console'/><category scheme='http://www.blogger.com/atom/ns#' term='read-host'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;S&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ome notes on cmd line editing for Powershell in v2 CTP 3. It is often nice to be able to use a command line editor like Vim or Edlin when writing simple scripts. This allows the administrator to stay in one shell and one environment. Edlin allows the user to see the command history above and the editing space below. Bruce Payette's work lead me to create this function that replaces the venerable 'copy con' in DOS: &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function copy_con {[console]::In.ReadToEnd&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;()}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;My 'copy_con' function can be used to write to file or  variable:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;copy_con &gt; a.txt &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;or&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$a = copy_con&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px; "&gt;The same functionality is achieved in v2 CTP3 with &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;read-host.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The 'out-gridview' cmdlet in CTP3 allows you to combine multiple output in one grid; a more readable and searchable window for multiple help files:  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$a | %{help $_ -detailed} | out-gridview&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Using the 'history' to create simple scripts is easy: &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$test_out = 25..30 | history| %{$_.CommandLine}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;To execute the collection of commands from a variable:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$test_out  | %{Invoke-expression $_}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2618617992646195673?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2618617992646195673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2618617992646195673&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2618617992646195673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2618617992646195673'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/01/some-notes-on-cmd-line-editing-for.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-9073811373779883529</id><published>2009-01-12T11:46:00.000-08:00</published><updated>2009-01-13T08:28:16.083-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Parsing Event logs'/><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Message'/><title type='text'></title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Parsing Logs again....Following up from a few posts ago. I would like to figure out how to get multiple log types working together with the simplest syntax in Powershell.  I think the goal would be to take events that happen from whatever handlers (Event Logs, Application Verifier, Windbg, NetMonitor, Syslogd, Firewall, IDS) and parse them into "congruent datetime stamped events" as objects (??). To get today's dump from Windows Firewall Audit (set this up in auditing...) messaging out of my Security Event Log, I do something like this:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$now = [System.DateTime]::get_now()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$NowSDS = $now.ToShortDateString()&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SEL = get-eventlog -logname Security | where-object {($_.timegenerated -match "$NowSDS") -and ($_.message -match "Windows Firewall")}  | fl * &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SEL | out-file $pwd\SEL.txt&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Select-string SEL.txt -pattern "Process Identifier","Path","Port number" -allmatches&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;## or &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Select-string SEL.txt -pattern "Process Identifier","Path","Port number" -allmatches | out-file SEL_SR.txt&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$sr = [System.IO.StreamReader]("$pwd\SEL_SR.txt")&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$sr.readToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Results are like:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SEL.txt:11669:                     Path: C:\WINDOWS\system32\svchost.exe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SEL.txt:11671:                     Process identifier: 1588&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SEL.txt:11685:                     Port number: 50386&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SEL.txt:11712:                     Path: C:\WINDOWS\system32\svchost.exe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SEL.txt:11714:                     Process identifier: 1588&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SEL.txt:11728:                     Port number: 59453&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Ungainly. Not parsing an object in the end but eventually text! So here we are parsing the Message descriptions from the Security Event log MSG field (which is text!) into an object:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$now = [System.DateTime]::get_now()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$NowSDS = $now.ToShortDateString()&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SEL = get-eventlog -logname Security | where-object {($_.timegenerated -match "$NowSDS") -and ($_.message -match "Windows Firewall")} &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$SEL_MSG =  $SEL | %{$_.message}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Select-string -inputobject $SEL_MSG -pattern "Process Identifier","Path","Port number" -allmatches&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Okay, an object but not what I want yet....And Select-String isn't helping any here:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Name: -&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Path: C:\WINDOWS\system32\svchost.exe&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Process identifier: 1588&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;User account: NETWORK SERVICE&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;User domain: NT AUTHORITY&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Service: Yes&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;RPC server: No&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;IP version: IPv4&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;IP protocol: UDP&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Port number: 55033&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Allowed: No&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;User notified: No The Windows Firewall has detected an application listening for incoming traffic.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;## This doesn't work&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;## $SR = [System.IO.StreamReader]($SEL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;## $sr.readToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;to be continued....&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-9073811373779883529?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/9073811373779883529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=9073811373779883529&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/9073811373779883529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/9073811373779883529'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/01/parsing-logs-again.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-3987911168974308258</id><published>2009-01-05T09:34:00.001-08:00</published><updated>2009-01-05T09:35:06.207-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell GUI'/><title type='text'></title><content type='html'>&lt;div&gt;I am happy to see that the new ISE can open multiple buffers like GVIM7.2:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://picasaweb.google.com/rferrisx/Powershell?authkey=Q5B4cx4qTOg#5287862514382137954"&gt;http://picasaweb.google.com/rferrisx/Powershell?authkey=Q5B4cx4qTOg#5287862514382137954&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-3987911168974308258?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/3987911168974308258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=3987911168974308258&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3987911168974308258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3987911168974308258'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/01/i-am-happy-to-see-that-new-ise-can-open.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-5348516273848864415</id><published>2009-01-02T00:08:00.000-08:00</published><updated>2012-01-08T18:06:36.712-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance testing with ps'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='arrays'/><title type='text'>Searching for malware with Powershell</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;hmmm.....&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;This gives me output like:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;1/3/2009 11:09 AM,19:9:16:859,100,csrss,1124,16388096,40923136,104357888,15458304,39809024,87851008&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;which covers WorkingSet, PrivateMemorySize, VirtualMemorySize, and their deltas between measurement interval.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;## Use ps to measure Application Memory Deltas&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;## Run '.\ws_diff [Interval in Seconds] [Process Name] or&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;## to log all processes continually every 10 seconds -- 'while (1) {.\WS_diff.ps1 10 cmd &amp;gt;&amp;gt; ps_out.txt }'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;# Create args as Variables or Objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;$sleep_time = $args[0]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;# Create or define PS_Array. Default is ps is called without args.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;# Then take measurements $now, $then, $count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;if ($args[1] -eq $NULL )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$then = ps | %{$_ | Select Name,ID,WorkingSet,PrivateMemorySize,VirtualMemorySize}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sleep -seconds $sleep_time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now &amp;nbsp;= ps | %{$_ | Select Name,ID,WorkingSet,PrivateMemorySize,VirtualMemorySize}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$count = ($now | Select Name).count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$ps_array = ( ps $args[1] )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$then = ps -inputobject $ps_array | %{$_ | Select Name,ID,WorkingSet,PrivateMemorySize,VirtualMemorySize}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sleep -seconds $sleep_time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now &amp;nbsp;= ps -inputobject $ps_array | %{$_ | Select Name,ID,WorkingSet,PrivateMemorySize,VirtualMemorySize}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$count = ($now | Select Name).count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;# Declare Time Measurements&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;$date = (get-date -format g)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;$hour = [DateTime]::UtcNow.TimeOfDay.Hours&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;$minutes = [DateTime]::UtcNow.TimeOfDay.Minutes&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;$seconds = [DateTime]::UtcNow.TimeOfDay.Seconds&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;$ms = [DateTime]::UtcNow.TimeOfDay.Milliseconds&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;# Write output and find diffs. Check if process has multiple instances first&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;if ( $count -gt 1 )&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$array_out = 0..$count |&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;%{&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$date + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$hour + ":" + $minutes + ":" + $seconds + ":" &amp;nbsp;+ $ms + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$sleep_time + "," + $now[$_].Name + "," + $now[$_].ID + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now[$_].WorkingSet + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now[$_].PrivateMemorySize + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now[$_].VirtualMemorySize + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;( ($now[$_].WorkingSet) - ($then[$_].WorkingSet) ) + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;( ($now[$_].PrivateMemorySize) - ($then[$_].PrivateMemorySize) ) + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;( ($now[$_].VirtualMemorySize) - ($then[$_].VirtualMemorySize) )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;else &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$array_out =&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$date + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$hour + ":" + $minutes + ":" + $seconds + ":" &amp;nbsp;+ $ms + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$sleep_time + "," + $now.Name + "," + $now.ID + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now.WorkingSet + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now.PrivateMemorySize + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$now.VirtualMemorySize + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;( ($now.WorkingSet) - ($then.WorkingSet) ) + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;( ($now.PrivateMemorySize) - ($then.PrivateMemorySize) ) + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;( ($now.VirtualMemorySize) - ($then.VirtualMemorySize) )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;write $array_out&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-5348516273848864415?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/5348516273848864415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=5348516273848864415&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5348516273848864415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5348516273848864415'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2009/01/as-before-in-previous-post-but.html' title='Searching for malware with Powershell'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2268846882191528706</id><published>2008-12-30T12:38:00.000-08:00</published><updated>2008-12-30T15:32:42.567-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance testing with ps'/><title type='text'>Measuring Working Set difference over time</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Something performance oriented that I spent way too much time with...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## Use ps to measure WS difference&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## Run '.\ws_diff [Measure Interval in Seconds]' or&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## to log to text continually every 10 seconds -- &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## 'while (1) {.\WS_diff.ps1 10 &gt;&gt; ps_out.txt }'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;# Take Measurements $Now and $Then and $Count&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$then = ps | %{$_ | Select Name,ID, WorkingSet}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;sleep -seconds $args[0]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$now = ps | %{$_ | Select Name,ID, WorkingSet}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;$count = ($now | Select Name).count&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;# Declare Time Measurement and Interval&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$date = (get-date -format g)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$hour = [DateTime]::UtcNow.TimeOfDay.Hours&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$Minutes = [DateTime]::UtcNow.TimeOfDay.Minutes&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$seconds = [DateTime]::UtcNow.TimeOfDay.Seconds&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$ms = [DateTime]::UtcNow.TimeOfDay.Milliseconds&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$interval = $args[0]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;## write output and find difference&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$text_out = 0..$count | &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;%{ &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $date + "," + $hour + ":" + $Minutes + ":" + $seconds + ":"  + $ms + "," + &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $interval + "," + $Now[$_].Name + "," + $Now[$_].ID + "," +&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    ( ($then[$_].WorkingSet) - ($Now[$_].WorkingSet) ) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;write $text_out&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Produces csv output like:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:arial;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:arial;font-size:13px;"&gt;&lt;div&gt;12/30/2008 12:53 PM,20:53:58:953,10,AcroRd32,2204,0&lt;/div&gt;&lt;div&gt;12/30/2008 12:53 PM,20:53:58:953,10,alg,1648,0&lt;/div&gt;&lt;div&gt;12/30/2008 12:53 PM,20:53:58:953,10,CepstralLicSrv,476,0&lt;/div&gt;&lt;div&gt;12/30/2008 12:53 PM,20:53:58:953,10,chrome,336,-4096&lt;/div&gt;&lt;div&gt;12/30/2008 12:53 PM,20:53:58:953,10,chrome,2416,0&lt;/div&gt;&lt;div&gt;12/30/2008 12:53 PM,20:53:58:953,10,chrome,2580,0&lt;/div&gt;&lt;div&gt;12/30/2008 12:53 PM,20:53:58:953,10,chrome,2660,-77824&lt;/div&gt;&lt;div&gt;...&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2268846882191528706?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2268846882191528706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2268846882191528706&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2268846882191528706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2268846882191528706'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/12/measuring-working-set-difference-over.html' title='Measuring Working Set difference over time'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-9044220241011285947</id><published>2008-10-04T21:32:00.000-07:00</published><updated>2008-10-05T07:12:09.161-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: CMD.exe v Powershell'/><title type='text'></title><content type='html'>&lt;div&gt;More cmd.exe vs Powershell&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This ditz below gets me a columnar listing of IP Address, DNS Name from cmd.exe . In the next post, we will whip that up in Powershell.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;:: Produces columnar listing of IP and DNS name for range of IPs&lt;/div&gt;&lt;div&gt;:: Takes one argument with the first three octets of an IP  &lt;/div&gt;&lt;div&gt;:: 'CheckNames 209.85.171 | findstr IP_Name' or&lt;/div&gt;&lt;div&gt;:: 'CheckNames 209.85.171 | findstr IP_Name &gt;&gt; Out.txt'&lt;/div&gt;&lt;div&gt;:: requires Cygwin in path or GNU grep, gawk, tr for Win32&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;@echo off&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; set args=%1&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; (for /l %%i in (1,1,255) do ( set OCT=%%i  &amp;amp;&amp;amp; set args &amp;amp;&amp;amp; call :loop ))&lt;/div&gt;&lt;div&gt;goto end&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;:loop&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;set OCT&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;for /f %%i in ('ping -n 1 -l 1 -w 750 %args%.%OCT% ^| grep Reply ^| gawk '{ print $3 }' ^| tr -d : '  ) do set IP=%%i&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;for /f %%i in ('nslookup %args%.%OCT% ^| grep Name: ^| gawk '{ print $2 }' ') do set Name=%%i&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;echo IP_Name %IP% %Name%&lt;/div&gt;&lt;div&gt;&lt;div&gt; set IP=&lt;/div&gt;&lt;div&gt; set Name=&lt;/div&gt;&lt;/div&gt;&lt;div&gt;:end&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Some sample output shows some of the problems in constructing complicated cmd.exe logic:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name  cg-in-f107.google.com&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name 209.85.171.108 cg-in-f108.google.com&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name 209.85.171.112 cg-in-f112.google.com&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name 209.85.171.113 cg-in-f113.google.com&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name 209.85.171.115 cg-in-f115.google.com&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;IP_Name 209.85.171.116&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;We know some ICMP fails, we know some name resolution fails, but we can't easily uncover the reasons for the failures or run additional code to check on the status of the failed ICMP and DNS requests.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-9044220241011285947?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/9044220241011285947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=9044220241011285947&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/9044220241011285947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/9044220241011285947'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/10/more-cmd.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-3195738473618443594</id><published>2008-09-14T10:48:00.000-07:00</published><updated>2008-09-14T10:53:34.273-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell:  get-eventlog;date parsing'/><category scheme='http://www.blogger.com/atom/ns#' term='Failure Analysis'/><title type='text'></title><content type='html'>&lt;div&gt;More Parsing Event Logs. Another way &lt;a href="http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/72f557072bd78474/70fc576cd6f6f64a?lnk=gst&amp;amp;q=get-eventlog#70fc576cd6f6f64a"&gt;to do this&lt;/a&gt; , &lt;a href="http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/72f557072bd78474/70fc576cd6f6f64a?lnk=gst&amp;amp;q=get-eventlog#70fc576cd6f6f64a"&gt;referencing part  of Brandon Shell and  Shay Levi's discussion. &lt;/a&gt;This doesn't parse the unformatted message text into object as I did in the post before.  In any event, it would be useful to get away from using findstr.exe.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;$now = [System.DateTime]::get_now()&lt;/div&gt;&lt;div&gt;$now.ToShortDateString()&lt;/div&gt;&lt;div&gt;$Now_ToString = $now.ToShortDateString()&lt;/div&gt;&lt;div&gt;get-eventlog -logname Security | where-object {($_.timegenerated -match "$Now_ToString") -and ($_.message -match "Windows Firewall")}  | fl * |  findstr "Port number"&lt;/div&gt;&lt;div&gt;# or&lt;/div&gt;&lt;div&gt;get-eventlog -logname Security | where-object {($_.timegenerated -match "$Now_ToString") -and ($_.message -match "Port number")}  | fl * | findstr "Port number"&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-3195738473618443594?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/3195738473618443594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=3195738473618443594&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3195738473618443594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3195738473618443594'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/09/more-parsing-event-logs.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-736390726483856429</id><published>2008-09-10T17:47:00.000-07:00</published><updated>2008-09-10T17:54:12.353-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Parsing Event logs'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Firewall'/><title type='text'></title><content type='html'>&lt;div&gt;Creates a columnar listing of Ports to which the Windows Firewall has denied access. No doubt there is a simpler way....This uses Lee Holmes 'Convert-TextObject.ps1' from the "The Windows Powershell Cookbook". To get around parsing the message fields in the Event Log which aren't objects, I used findstr.exe with "MessageFilters.txt" as far below.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;$now = [System.DateTime]::get_now()&lt;/div&gt;&lt;div&gt;$nowshort = ($now.ToShortDateString()).ToString()&lt;/div&gt;&lt;div&gt;$TodaysFA = ( ( get-eventlog -logname security | where {$_.EntryType -eq "FailureAudit" -and $_.TimeGenerated -match "$nowshort" } )| Select TimeGenerated,Message )&lt;/div&gt;&lt;div&gt;$TodaysFA_Delimited = ($TodaysFA | fl * | findstr /g:MessageFilters.txt) | .\Convert-TextObject.ps1 -Delimiter ":"&lt;/div&gt;&lt;div&gt;$TodaysFA_Ports = $TodaysFA_Delimited | where-object {$_.Property1 -match "Port"} | sort-object {$_.Property2}&lt;/div&gt;&lt;div&gt;$TodaysFA_PortNumber =  $TodaysFA_Ports | Select {$_.Property2} &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;MessageFilters.txt&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;TimeGenerated :&lt;/div&gt;&lt;div&gt;Message:&lt;/div&gt;&lt;div&gt;Process identifier:&lt;/div&gt;&lt;div&gt;User account:&lt;/div&gt;&lt;div&gt;User domain:&lt;/div&gt;&lt;div&gt;Service:&lt;/div&gt;&lt;div&gt;RPC server:&lt;/div&gt;&lt;div&gt;IP version:&lt;/div&gt;&lt;div&gt;IP protocol:&lt;/div&gt;&lt;div&gt;Port number:&lt;/div&gt;&lt;div&gt;Allowed:&lt;/div&gt;&lt;div&gt;User notified:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-736390726483856429?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/736390726483856429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=736390726483856429&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/736390726483856429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/736390726483856429'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/09/creates-columnar-listing-of-ports-to.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-4633070790471880067</id><published>2008-09-02T20:14:00.000-07:00</published><updated>2008-09-03T08:03:26.504-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell:  get-eventlog;date parsing'/><title type='text'></title><content type='html'>Parsing Event Logs. So what I am trying to do is fish out all the Windows Firewall Entries that tell me what internal ports communicate with the outside world.   This is a useful way to use pfirewall.log (Windows Firewall to check for Trojans). I have eventviewer entries like below that give me more information than the pfirewall.log&lt;br /&gt;&lt;br /&gt;Event Type:    Failure Audit&lt;br /&gt;Event Source:    Security&lt;br /&gt;Event Category:    Detailed Tracking&lt;br /&gt;Event ID:    861&lt;br /&gt;Date:        9/3/2008&lt;br /&gt;Time:        6:58:53 AM&lt;br /&gt;User:        NT AUTHORITY\NETWORK SERVICE&lt;br /&gt;Computer:    RMFMEDIA&lt;br /&gt;Description:&lt;br /&gt;The Windows Firewall has detected an application listening for incoming traffic.&lt;br /&gt;&lt;br /&gt;Name: -&lt;br /&gt;Path: C:\WINDOWS\system32\svchost.exe&lt;br /&gt;Process identifier: 1432&lt;br /&gt;User account: NETWORK SERVICE&lt;br /&gt;User domain: NT AUTHORITY&lt;br /&gt;Service: Yes&lt;br /&gt;RPC server: No&lt;br /&gt;IP version: IPv4&lt;br /&gt;IP protocol: UDP&lt;br /&gt;Port number: 61248&lt;br /&gt;Allowed: No&lt;br /&gt;User notified: No&lt;br /&gt;&lt;br /&gt;D:\&gt;tail pfirewall.log&lt;br /&gt;2008-09-03 07:27:37 OPEN UDP 192.168.1.114 69.7.46.8 56319 53 - - - - - - - - -&lt;br /&gt;2008-09-03 07:27:37 OPEN TCP 192.168.1.114 72.14.207.191 1551 80 - - - - - - - - -&lt;br /&gt;2008-09-03 07:27:38 OPEN UDP 192.168.1.114 192.168.0.2 1025 514 - - - - - - - - -&lt;br /&gt;2008-09-03 07:27:44 CLOSE TCP 192.168.1.114 72.14.223.191 1550 80 - - - - - - - - -&lt;br /&gt;2008-09-03 07:27:44 DROP TCP 72.14.223.191 192.168.1.114 80 1550 288 AP 2880782099&lt;br /&gt;&lt;br /&gt;This is the basic idea:&lt;br /&gt;&lt;br /&gt;( ( get-eventlog -logname security | where {$_.EntryType -eq "FailureAudit"} )| Select ReplacementStrings,TimeGenerated,Message )&lt;br /&gt;&lt;br /&gt;The spew below also works now.  What I wanted to do is limit the event log entries to today's date, but I couldn't find any easy way to embed a 'get-date' command without parsing it.&lt;br /&gt;&lt;br /&gt;$date = (get-date -format g).Split(" ")&lt;br /&gt;$now = $date[0].ToString()&lt;br /&gt;$TodaysFA = ( ( get-eventlog -logname security | where {$_.EntryType -eq "FailureAudit"  -and $_.TimeGenerated -match "$now" } )| Select ReplacementStrings,TimeGenerated,Message )&lt;br /&gt;&lt;br /&gt;$date = (get-date -format g).Split(" ")&lt;br /&gt;$now = $date[0].ToString()&lt;br /&gt;$Todays_861 = ( ( get-eventlog -logname security | where {$_.EventID -eq "861"  -and $_.TimeGenerated -match "$now" } )| Select ReplacementStrings,TimeGenerated,Message )&lt;br /&gt;&lt;br /&gt;Next up: to dump just the Message field and extract out the port number and other various info into a csv.  What I really want is just this information in a csv:&lt;br /&gt;&lt;br /&gt;Process identifier: 1432&lt;br /&gt;User account: NETWORK SERVICE&lt;br /&gt;User domain: NT AUTHORITY&lt;br /&gt;Service: Yes&lt;br /&gt;RPC server: No&lt;br /&gt;IP version: IPv4&lt;br /&gt;IP protocol: UDP&lt;br /&gt;Port number: 61248&lt;br /&gt;Allowed: No&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-4633070790471880067?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/4633070790471880067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=4633070790471880067&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4633070790471880067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4633070790471880067'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/09/parsing-event-logs-and-back-on.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-3012849833990664779</id><published>2008-07-15T15:59:00.000-07:00</published><updated>2008-07-15T16:05:54.801-07:00</updated><title type='text'></title><content type='html'>With the help of Kuma:&lt;br /&gt;&lt;br /&gt;http://groups.google.com/group/microsoft.public.windows.powershell&lt;br /&gt;/browse_thread/thread/9b10ea1270dfd0ad/eb78a0bc226837d6#eb78a0bc226837d6&lt;br /&gt;&lt;br /&gt;I have picked up this gem, which gives all the physical IPs on a system:&lt;br /&gt;&lt;br /&gt;0..1 | %{([System.Net.DNS]::GetHostEntry(""))&lt;br /&gt;.AddressList[$_].IPAddressToString}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-3012849833990664779?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/3012849833990664779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=3012849833990664779&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3012849833990664779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3012849833990664779'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/07/with-help-of-kuma-httpgroups.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-6623969742285785751</id><published>2008-07-07T10:43:00.000-07:00</published><updated>2008-07-07T10:49:45.473-07:00</updated><title type='text'></title><content type='html'>&lt;span style="font-family: courier new;font-size:78%;" &gt;/\/\o\/\/ came up with the following brilliance:&lt;br /&gt;http://thepowershellguy.com/blogs/posh/archive/2008/06/30/powershell-get-ipconfig-function.aspx?&lt;br /&gt;CommentPosted=true#commentmessage&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: courier new;font-size:78%;" &gt;&lt;br /&gt;[System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()&lt;br /&gt;|% {$_.getIPProperties().UnicastAddresses[0]}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Address                        : 192.168.0.5&lt;br /&gt;IPv4Mask                       : 255.255.255.0&lt;br /&gt;IsTransient                    : False&lt;br /&gt;IsDnsEligible                  : True&lt;br /&gt;PrefixOrigin                   : Dhcp&lt;br /&gt;SuffixOrigin                   : OriginDhcp&lt;br /&gt;DuplicateAddressDetectionState : Preferred&lt;br /&gt;AddressValidLifetime           : 349435&lt;br /&gt;AddressPreferredLifetime       : 349435&lt;br /&gt;DhcpLeaseLifetime              : 349435&lt;br /&gt;&lt;br /&gt;Address                        : 127.0.0.1&lt;br /&gt;IPv4Mask                       :&lt;br /&gt;IsTransient                    : False&lt;br /&gt;IsDnsEligible                  : True&lt;br /&gt;PrefixOrigin                   : Manual&lt;br /&gt;SuffixOrigin                   : Manual&lt;br /&gt;DuplicateAddressDetectionState : Preferred&lt;br /&gt;AddressValidLifetime           : 3079514780&lt;br /&gt;AddressPreferredLifetime       : 3079514780&lt;br /&gt;DhcpLeaseLifetime              : 3079514780&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()&lt;br /&gt;|% {$_.getIPProperties}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MemberType          : Method&lt;br /&gt;OverloadDefinitions : {System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties()}&lt;br /&gt;TypeNameOfValue     : System.Management.Automation.PSMethod&lt;br /&gt;Value               : System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties()&lt;br /&gt;Name                : GetIPProperties&lt;br /&gt;IsInstance          : True&lt;br /&gt;&lt;br /&gt;MemberType          : Method&lt;br /&gt;OverloadDefinitions : {System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties()}&lt;br /&gt;TypeNameOfValue     : System.Management.Automation.PSMethod&lt;br /&gt;Value               : System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties()&lt;br /&gt;Name                : GetIPProperties&lt;br /&gt;IsInstance          : True&lt;br /&gt;&lt;br /&gt;MemberType          : Method&lt;br /&gt;OverloadDefinitions : {System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties()}&lt;br /&gt;TypeNameOfValue     : System.Management.Automation.PSMethod&lt;br /&gt;Value               : System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties()&lt;br /&gt;Name                : GetIPProperties&lt;br /&gt;IsInstance          : True&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-6623969742285785751?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/6623969742285785751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=6623969742285785751&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6623969742285785751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6623969742285785751'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/07/o-came-up-with-following-brilliance.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-8798212831360118550</id><published>2008-07-06T21:36:00.001-07:00</published><updated>2008-07-06T22:06:32.855-07:00</updated><title type='text'></title><content type='html'>&lt;span style=";font-family:courier new;font-size:85%;"  &gt;I find it simply amazing that  Powershell can use the .NET  to find the Broadcast and Loopback with little complication, but not the host IP Address:&lt;br /&gt;[System.Net.IPAddress]::Broadcast.IPAddressToString&lt;br /&gt;or&lt;br /&gt;[System.Net.IPAddress]::Loopback.IPAddressToString&lt;br /&gt;&lt;br /&gt;I can find all NetworkInterface information BUT the IP easily enough:&lt;br /&gt;[System.Net.NetworkInformation.NetworkInterface]::&lt;br /&gt;GetAllNetworkInterfaces()&lt;br /&gt;&lt;br /&gt;But if I want my local host IP address through .NET I need some kludge like:&lt;br /&gt;$host_name = [System.Net.Dns]::GetHostName() ; [System.Net.Dns]::Resolve("$host_name")&lt;br /&gt;&lt;br /&gt;Or I can dredge up some other not quite satisfactory kludge from gwmi:&lt;br /&gt;&lt;br /&gt;$NetworkInfo =gwmi -query "SELECT * FROM Win32_NetworkAdapterConfiguration"&lt;br /&gt;function NetworkInfoSort {$NetworkInfo | Select-Object IPAddress,Description,Index,DefaultIPGateway | sort-object Index}&lt;br /&gt;NetworkInfoSort&lt;br /&gt;&lt;br /&gt;gwmi -class win32_NetworkAdapterConfiguration | %{ $_.IPAddress }&lt;br /&gt;&lt;br /&gt;gwmi -query "SELECT IPAddress FROM Win32_NetworkAdapterConfiguration" | Select IPAddress&lt;br /&gt;&lt;br /&gt;I wish I could just do something like:&lt;br /&gt;&lt;br /&gt;[System.Net.IPAddress]::LocalHost.IPAddressToString&lt;br /&gt;or&lt;br /&gt;[System.Net.NetworkInformation.NetworkInterface]::&lt;br /&gt;GetAllNetworkInterfaces.IPAddress&lt;br /&gt;or&lt;br /&gt;Get-ipconfig&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-8798212831360118550?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/8798212831360118550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=8798212831360118550&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8798212831360118550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8798212831360118550'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/07/i-find-it-simply-amazing-that.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-7545178560943537976</id><published>2008-07-02T18:38:00.000-07:00</published><updated>2008-07-02T18:43:49.243-07:00</updated><title type='text'></title><content type='html'>&lt;span style=";font-family:arial;font-size:85%;"  &gt;Still relatively confused on how to use the .NET through Powershell.  Here are some simple examples that were easy to find because they have accessible overloaded interfaces (??):&lt;br /&gt;&lt;br /&gt;$Ping = new-object System.Net.NetworkInformation.ping&lt;br /&gt;$Ping.Send("192.168.0.1")&lt;br /&gt;Status        : Success&lt;br /&gt;Address       : 192.168.0.1&lt;br /&gt;RoundtripTime : 1 ms&lt;br /&gt;BufferSize    : 32&lt;br /&gt;Options       : TTL=127, DontFragment=False&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[System.Net.Dns]::Resolve("google.com") | fl *&lt;br /&gt;HostName    : google.com&lt;br /&gt;Aliases     : {}&lt;br /&gt;AddressList : {64.233.167.99, 72.14.207.99, 64.233.187.99}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[System.Net.Dns]::GetHostName()&lt;br /&gt;rmfmedia&lt;br /&gt;&lt;br /&gt;[System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()&lt;br /&gt;&lt;br /&gt;Id                   : {0348D5D7-6D83-44C8-B556-B29466698340}&lt;br /&gt;Name                 : Wireless Network Connection&lt;br /&gt;Description          : Intel(R) PRO/Wireless 3945ABG Network Connection - Packet Scheduler Miniport&lt;br /&gt;NetworkInterfaceType : Ethernet&lt;br /&gt;OperationalStatus    : Up&lt;br /&gt;Speed                : 54000000&lt;br /&gt;IsReceiveOnly        : False&lt;br /&gt;SupportsMulticast    : True&lt;br /&gt;....&lt;br /&gt;&lt;br /&gt;[System.Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable()&lt;br /&gt;True&lt;/span&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-7545178560943537976?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/7545178560943537976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=7545178560943537976&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7545178560943537976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/7545178560943537976'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/07/still-relatively-confused-on-how-to-use.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-1240578897118390532</id><published>2008-06-17T15:30:00.000-07:00</published><updated>2008-06-17T16:51:18.606-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerTab'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: TcpState'/><category scheme='http://www.blogger.com/atom/ns#' term='GetMembers'/><title type='text'></title><content type='html'>Exploration of .NET through 'Powertab' interrogation continues.   I still don't know how to benefit from 'Powertab' just yet...I would like to know is Powershell can call these Properties below.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; [System.Net.NetworkInformation.TcpState]&lt;br /&gt;.GetMembers() | %{$_.Name}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Unknown&lt;br /&gt;Closed&lt;br /&gt;Listen&lt;br /&gt;SynSent&lt;br /&gt;SynReceived&lt;br /&gt;Established&lt;br /&gt;FinWait1&lt;br /&gt;FinWait2&lt;br /&gt;CloseWait&lt;br /&gt;Closing&lt;br /&gt;LastAck&lt;br /&gt;TimeWait&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-1240578897118390532?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/1240578897118390532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=1240578897118390532&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1240578897118390532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1240578897118390532'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/06/exploration-of.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-5327414984521166219</id><published>2008-06-17T14:08:00.001-07:00</published><updated>2008-06-17T14:17:49.532-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Query .NET'/><category scheme='http://www.blogger.com/atom/ns#' term='MemberTypes'/><title type='text'></title><content type='html'>Querying .NET in Powershell.  The ability to use the vast repertoire of .NET in Powershell  is impressive.  More difficult of late has been how to find .NET functions and call arguments. I was stuck reading the 3.5 Framework docs doing clunky stuff like this:&lt;br /&gt;&lt;br /&gt;$webclient = New-Object System.Net.WebClient&lt;br /&gt;$a = ($webclient | gm) | % {$_.Name}&lt;br /&gt;$b = ( $a | % {$WebClient.$_} )&lt;br /&gt;$c =  ( $b | Select Name , OverloadDefinitions )&lt;br /&gt;write $c&lt;br /&gt;&lt;br /&gt;But then I installed 'PowerTab' and can tab my way to knowledge with the '.findmember' property. (This works without 'PowerTab' but is nowhere near as easy and complete.)&lt;br /&gt;&lt;br /&gt;[System.Net.*&lt;br /&gt;[System.Net.WebClient].&lt;br /&gt;[System.Net.WebClient].FindMembers&lt;br /&gt;&lt;br /&gt;PS [RMFMEDIA] &gt;[System.Net.WebClient].FindMembers | ft -auto -wrap&lt;br /&gt;&lt;br /&gt;WARNING: 4 columns do not fit into the display and were removed.&lt;br /&gt;&lt;br /&gt;MemberType OverloadDefinitions&lt;br /&gt;---------- -------------------&lt;br /&gt;    Method {System.Reflection.MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, Object filterCriteria)}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-5327414984521166219?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/5327414984521166219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=5327414984521166219&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5327414984521166219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5327414984521166219'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/06/querying.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-3231911615704347349</id><published>2008-06-11T16:03:00.000-07:00</published><updated>2008-06-11T16:22:31.529-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Meta-File'/><category scheme='http://www.blogger.com/atom/ns#' term='Measure-Object'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell:  EXIF'/><title type='text'></title><content type='html'>&lt;span style=";font-family:lucida grande;font-size:85%;"  &gt;Selected 'Exif' statistics script is below. There are a number of ways I can improve it: Stream output, skip csv file creation (as an interim step) read list with arrays and parameters, using regex expressions to best effect.  Still, quite a few lessons learned with this and the output can help check for errors. The issue is that 'exif' (Cygwin, GNU output) will sometimes skip fields.  I am not checking for that or other error conditions in general but the 'Counts' need to sync up at least.  That being said, 'measure-object' cmdlet gives me some easy 'meta-file' (exif) stats about my JPGs.  Output looks as below. I am still not solving the problem that I do not know how to obtain select "meta-file" information from Powershell.&lt;br /&gt;&lt;br /&gt;Count    : 214&lt;br /&gt;Average  :&lt;br /&gt;Sum      :&lt;br /&gt;Maximum  :&lt;br /&gt;Minimum  :&lt;br /&gt;Property : Exif_Tag&lt;br /&gt;&lt;br /&gt;Count    : 214&lt;br /&gt;Average  : 7.07102803738318&lt;br /&gt;Sum      :&lt;br /&gt;Maximum  : 13&lt;br /&gt;Minimum  : 3.5&lt;br /&gt;Property : FNumber&lt;br /&gt;&lt;br /&gt;Count    : 214&lt;br /&gt;Average  : 58.0140186915888&lt;br /&gt;Sum      :&lt;br /&gt;Maximum  : 82&lt;br /&gt;Minimum  : 27&lt;br /&gt;Property : Focal_Length&lt;br /&gt;&lt;br /&gt;## Get-exif-stats.ps1&lt;br /&gt;$exif_index  =  gci *.jpg | %{exif ($_.Name)}&lt;br /&gt;$c = $exif_index | Select-String -pattern "EXIF tag" , FNumber , "Focal Length In 35mm"&lt;br /&gt;$c1 =  ("$c").Split(  ) | Select-String -pattern JPG , f/ , mm&lt;br /&gt;$c2 = (("$c1").Replace( "'" , "")).Split()&lt;br /&gt;$c3 = (("$c2").Replace( " |f/" , ",")).Split()&lt;br /&gt;$c4 = (("$c3").Replace( " 35mm|" , ",")).Split()&lt;br /&gt;&lt;br /&gt;if ((gci PhotoData.csv).Exists -eq "True") {mv PhotoData.csv PhotoData.csv.old -force}&lt;br /&gt;&lt;br /&gt;"Exif_Tag,FNumber,Focal_Length" | out-file PhotoData.csv&lt;br /&gt;$c4 | out-file -append PhotoData.csv&lt;br /&gt;$PhotoData = import-csv -path PhotoData.csv&lt;br /&gt;&lt;br /&gt;$FileName =  ( $PhotoData | Measure-Object -Property Exif_Tag  )&lt;br /&gt;$FNumber = ( $PhotoData | Measure-Object -Property FNumber  -average -maximum -minimum )&lt;br /&gt;$Focal_Length = ( $PhotoData | Measure-Object -Property Focal_Length  -average -maximum -minimum )&lt;br /&gt;&lt;br /&gt;echo $FileName&lt;br /&gt;echo $FNumber&lt;br /&gt;echo $Focal_Length&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-3231911615704347349?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/3231911615704347349/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=3231911615704347349&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3231911615704347349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/3231911615704347349'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/06/selected-exif-statistics-scripts-is.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-6150845185412389202</id><published>2008-06-09T21:57:00.000-07:00</published><updated>2008-06-09T22:10:30.427-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exif'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Split'/><category scheme='http://www.blogger.com/atom/ns#' term='Replace'/><title type='text'></title><content type='html'>&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Some progress tonight parsing 'exif' output with .Split and .Replace operators.  Lee Holmes book is excellent on the use of comparison operators and text parsing. The script below takes text like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;EXIF tags in 'P1050027.JPG' ('Intel' byte order):&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;FNumber             |f/3.7&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Focal Length In 35mm|71&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and turns it into CSV delimited fields like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;P1050027.JPG,f/3.7,71&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;## ParseExif.ps1&lt;br /&gt;$exif_index  =  gci *.jpg | %{exif ($_.Name)}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$c = $exif_index | Select-String -pattern "EXIF tag" , FNumber , "Focal Length In 35mm"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$c1 =  ("$c").Split(  ) | Select-String -pattern JPG , f/ , mm&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;&lt;br /&gt;$c2 = (("$c1").Replace( "'" , "")).Split()&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;&lt;br /&gt;$c3 = (("$c2").Replace( " |" , ",")).Split()&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;&lt;br /&gt;$c4 = (("$c3").Replace( " 35mm|" , ",")).Split()&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-6150845185412389202?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/6150845185412389202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=6150845185412389202&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6150845185412389202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6150845185412389202'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/06/some-progress-tonight-parsing-exif.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-96226658502759097</id><published>2008-06-08T16:27:00.000-07:00</published><updated>2008-06-09T08:23:45.461-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: range operators'/><category scheme='http://www.blogger.com/atom/ns#' term='while construct'/><title type='text'></title><content type='html'>&lt;span style="font-family:courier new;"&gt;The 'exif' program spits out an array of tags which I thought were consistently 56 lines (see below). (They are not of course.) So I attempted to query the 0 (filename) and the 20 (FNumber) per every group of 56 as if the output was an artificial array always 56 lines in length.&lt;br /&gt;&lt;br /&gt; e.g. I am attempting to index an array of data by line number. This wasn't useful, but as an exercise in use of PS range operators and while construct. I am looking for some method to use PS to create objects from foreign data constructs. I think this may be approached more effectively else wise.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;$exif_index  =  gci *.jpg | %{exif ($_.Name)}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;$eil  = $exif_index.length&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;$i = $eil&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;while ($i -gt 56) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;  {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    $file_name = ($eil - ($i - 0))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    $FNumber = ($eil - ($i - 20))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    $exif_index[$file_name]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    $exif_index[$FNumber]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    ## 56 is size of array&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    $i = ($i - 56)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;  }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Something like this results:&lt;br /&gt;D:\images\06.04.08a&lt;br /&gt;EXIF tags in 'P1050027.JPG' ('Intel' byte order):&lt;br /&gt;FNumber             |f/3.7&lt;br /&gt;EXIF tags in 'P1050028.JPG' ('Intel' byte order):&lt;br /&gt;FNumber             |f/3.7&lt;br /&gt;EXIF tags in 'P1050029.JPG' ('Intel' byte order):&lt;br /&gt;FNumber             |f/4.1&lt;br /&gt;EXIF tags in 'P1050030.JPG' ('Intel' byte order):&lt;br /&gt;FNumber             |f/4.1&lt;br /&gt;&lt;br /&gt;[full exif dump]&lt;br /&gt;&lt;br /&gt;26# $exif_index | more&lt;br /&gt;EXIF tags in 'P1050027.JPG' ('Intel' byte order):&lt;br /&gt;--------------------+----------------------------------------------------------&lt;br /&gt;Tag                 |Value&lt;br /&gt;--------------------+----------------------------------------------------------&lt;br /&gt;Manufacturer        |Panasonic&lt;br /&gt;Model               |DMC-TZ1&lt;br /&gt;Orientation         |top - left&lt;br /&gt;x-Resolution        |72.00&lt;br /&gt;y-Resolution        |72.00&lt;br /&gt;Resolution Unit     |Inch&lt;br /&gt;Software            |Ver.1.0&lt;br /&gt;Date and Time       |2008:06:04 09:54:14&lt;br /&gt;YCbCr Positioning   |co-sited&lt;br /&gt;Compression         |JPEG compression&lt;br /&gt;Orientation         |top - left&lt;br /&gt;x-Resolution        |72.00&lt;br /&gt;y-Resolution        |72.00&lt;br /&gt;Resolution Unit     |Inch&lt;br /&gt;YCbCr Positioning   |co-sited&lt;br /&gt;Exposure Time       |1/800 sec.&lt;br /&gt;FNumber             |f/3.7&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-96226658502759097?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/96226658502759097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=96226658502759097&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/96226658502759097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/96226658502759097'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/06/this-wasnt-very-useful-but-i-am-writing.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-8519174357343937198</id><published>2008-06-07T10:42:00.000-07:00</published><updated>2008-06-09T08:25:24.025-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CMD.EXE'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell:  EXIF'/><title type='text'></title><content type='html'>&lt;span style="font-family:courier new;"&gt; All I really want is a 'Get-exif' cmdlet in Powershell so I can compare specs in 'list' below for photos I have taken. I don't want to query .NET or load an assembly or set up an array. !!!    Read four or five blogs on the matter. Read Lee Holmes Cookbook.  Cygwin's &lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;exif&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; with CMD.exe trumps anything &lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;Powershell &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;I could come up with. A stupid wasted afternoon and morning. &lt;/span&gt;  &lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;more list&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;Exposure Time&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;FNumber&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;&lt;br /&gt;ISO&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;&lt;br /&gt;Focal Length&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;Exposure Mode&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;(one line in cmd.exe)&lt;br /&gt;for /f %i in ('dir /b *.jpg') do exif %i | Findstr -g:list &amp;amp;&amp;amp; pause&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;  &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;(I need PS to do more than this..)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$exif_index  =  gci *.jpg | %{exif ($_.Name)}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-8519174357343937198?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/8519174357343937198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=8519174357343937198&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8519174357343937198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/8519174357343937198'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/06/all-i-really-want-is-get-exif-cmdlet-in.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-6551395272361249625</id><published>2008-06-01T22:18:00.000-07:00</published><updated>2008-06-09T08:20:34.141-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: NetCmdlets; Ping Subnet;IP'/><title type='text'></title><content type='html'>&lt;span style=";font-family:lucida grande;font-size:100%;"  &gt;Okay...This uses &lt;/span&gt;&lt;span style=";font-family:lucida grande;font-size:100%;"  &gt; 'Ping-Host'  from&lt;/span&gt;&lt;span style=";font-family:lucida grande;font-size:100%;"  &gt; &lt;span style="font-weight: bold;"&gt;PSCX&lt;/span&gt; PSSnapin. My function still doesn't do what I want it to do but..more promising. Give function  first three octets (and hard code range - 1..254) , Bytes, Wait, Count  (which only works as below with count of one right now...)  Then Prints (only) Hosts UP, IP Address, AverageTime, MinimumTime, MaximumTime, Loss as so....Stats are misleading since I think (?)  it is the ave, min, max for each separate run? )....Will fix this...and TTL...Man, Powergui is helpful. So are the NetCmdlets. Anyway, 'ping-host' is faster..than accessing the .NET ping(send) functionality from the post before this. My programming logic is still not standard.  I should be using params and arrays as Holmes and Payette specify&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.\CheckClassC_NC_function.ps1 209.85.173. 8000 1 20&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Host UP,209.85.173.4,228,228,228,0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Host UP,209.85.173.5,42,42,42,0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Host UP,mh-in-f17.google.com,38,38,38,0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Host UP,mh-in-f18.google.com,41,41,41,0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Host UP,mh-in-f19.google.com,37,37,37,0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Host UP,mh-in-f32.google.com,42,42,42,0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function CheckHostClassC_function&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;## ($Subnet,$BufferSize,$Count,$Timeout,$TTL)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;begin {$ping =(Ping-Host -Quiet -HostName $Subnet$_&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;-BufferSize $BufferSize -Count $Count -Timeout $Timeout );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; $pingtrue =($ping.Received)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; $host_ = ($ping.Host) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; $AverageTime_ = ($ping.AverageTime) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; $MinimumTime_ = ($ping.MinimumTime) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; $MaximumTime_ = ($ping.MaximumTime) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; $Loss_ = ($ping.Loss) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;process {if ($pingtrue -eq "1")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; {"Host UP"+","+"$host_"+","+"$AverageTime_"+","+&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;"$MinimumTime_"+","+"$MaximumTime_"+","+"$Loss_"}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;sv Subnet $Args[0]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;sv BufferSize $Args[1]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;sv Count $Args[2]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;sv Timeout $Args[3]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;## sv TTL $Args[4]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;1..254 | %{CheckHostClassC_function}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-6551395272361249625?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/6551395272361249625/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=6551395272361249625&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6551395272361249625'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6551395272361249625'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/06/okay.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-6549525107402581202</id><published>2008-05-25T20:24:00.000-07:00</published><updated>2008-05-26T18:29:25.213-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Ping IP Ranges'/><title type='text'></title><content type='html'>&lt;span style="COLOR: rgb(102,0,204)"&gt;&lt;span style="COLOR: rgb(51,0,51);font-family:courier new;font-size:85%;color:#ff6600;"   &gt;So in thinking about what I have learned doing the work below...Please see my next post...To make matters worse, the pipe command does not appear in this blog.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;&lt;span style="COLOR: rgb(51,0,51);font-family:courier new;font-size:85%;"  &gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;&lt;span style="COLOR: rgb(51,0,51)"&gt;Pinging IP subnet ranges in Powershell. This will be more difficult than...(you know the rest)..I am attempting to duplicate the  functionality of my previous post.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PS D:\&gt; $var = '192.168.0.1','192.168.0.2'&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;PS D:\&gt; $var&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;192.168.0.1&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;192.168.0.2&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;PS D:\&gt; $ping = new-object System.Net.NetworkInformation.Ping&lt;br /&gt;&lt;br /&gt;PS D:\&gt; $var foreach-object -process {$ping.Send($_)} ft -auto&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;Status Address RoundtripTime Options Buffer&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;------ ------- ------------- ------- ------&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;Success 192.168.0.1 1 System.Net.NetworkInformation.PingOptions {97, 98, 99, 100...}&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(102,0,204)"&gt;TimedOut 0 {}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#330033;"&gt;Closer yet...&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#6600cc;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;PS D:\&gt; $ping = new-object System.Net.NetworkInformation.Ping&lt;br /&gt;PS D:\&gt; $3OCT='71.0.0.'&lt;br /&gt;PS D:\&gt; 1..254 [pipe command here] foreach-object -process { if($ping.Send("$3OCT$_").status -eq "Success") {"$3OCT$_"} }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;71.0.0.1&lt;br /&gt;71.0.0.3&lt;br /&gt;71.0.0.7&lt;br /&gt;71.0.0.8&lt;br /&gt;71.0.0.9&lt;br /&gt;71.0.0.11&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#330033;"&gt;Putting this together a little bit more...&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;PS D:\&gt; $3OCT = '190.10.10.'&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;PS D:\&gt; function Ping-Host { begin{ $ping = new-object System.Net.NetworkInformation.Ping; } process{ if($ping.Send("$3OCT$_").status -eq "Success") {"$3OCT$_";} } }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;PS D:\&gt; 1..254 [pipe command here] Ping-Host&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;190.10.10.1&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;190.10.10.10&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;190.10.10.17&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Looking Much Better this morning:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#6600cc;"&gt;PS D:\&gt; function Ping-Host { begin{ $ping = new-object System.Net.NetworkInformation.Ping; } process{ if($ping.Send("$3OCT$_","8").status -eq "Success") {"$3OCT$_"+","+($ping.Send("$3OCT$_","8").roundtriptime)+","+(date-time);} } }&lt;br /&gt;PS D:\&gt; 1..20 Ping-Host&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#6600cc;"&gt;&lt;br /&gt;71.0.0.1,80,05/26/2008 07:09:31&lt;br /&gt;71.0.0.3,107,05/26/2008 07:09:32&lt;br /&gt;71.0.0.7,97,05/26/2008 07:09:33&lt;br /&gt;71.0.0.8,118,05/26/2008 07:09:33&lt;br /&gt;71.0.0.11,104,05/26/2008 07:09:34&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Below this 'works', but I had all kinds of issues with it and suspect that &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(a) I don't understand argument and text passing in Powershell very well&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;(b) such skill are more idiosyncratic than they appear.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There were all kinds of issues here....lots of idiosyncratic behaviour to think about in Powershell. Actually, a whole host of Powershell topological and semantic rules exist that are not well described anywhere....&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#333399;"&gt;# CheckHostClassC.ps1 5:55 PM 5/26/2008 Down, dirty attempt to ping subnet. Takes two args: first three octets and wait time. Prints out IP address date, roundtriptime. No error checking.&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;function date-time {get-date -displayhint datetime}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;function CheckHostClassC {begin {$ping = new-object System.Net.NetworkInformation.Ping; } process { if($ping.Send("$3OCT$_","$WaitTime").status -eq "Success") {"$3OCT$_"+","+($ping.Send("$3OCT$_","$WaitTime").roundtriptime)+","+(date-time);} }}&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;sv 3OCT $Args[0]&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;sv WaitTime $Args[1] &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333399;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;1..254 [pipe command here] CheckHostClassC &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;PS D:\&gt; .\CheckHostClassC.ps1 193.172.1. 100&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;193.172.1.1,211,05/26/2008&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt; 18:24:37&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;193.172.1.3,212,05/26/2008 18:24:38&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#333399;"&gt;193.172.1.5,215,05/26/2008 18:24:39&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt; &lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#333399;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-6549525107402581202?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/6549525107402581202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=6549525107402581202&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6549525107402581202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6549525107402581202'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/05/var-192.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-1451431271731787367</id><published>2008-05-24T19:52:00.000-07:00</published><updated>2008-05-24T20:30:03.801-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DOS'/><category scheme='http://www.blogger.com/atom/ns#' term='CMD.EXE'/><category scheme='http://www.blogger.com/atom/ns#' term='Subnet Range Finder'/><title type='text'></title><content type='html'>Okay, so let's try to start rewriting some CMD.EXE skillsets in Powershell.  Here's something common: ping a range of subnets to see if the hosts are up and what their latency is.  In CMD exe we first need some to code to produce an accurate timestamp because there is no native way to do this. Thus this complicated and idiosyncratic use of the set command to parse out time/date stamps:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;:: realtd.cmd&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;@echo off&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt; set realdate=%date:/=.%&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;set realdate=%realdate:* =%&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;set realtime=%time::=.%&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;set timestamp=%realdate%_%realtime%&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we need some nearly unreadable spew, some help fron gawk, some hard coded ping options, a hard coded subnet range...:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;:: TestSubnet.cmd&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;@echo off&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;set ThreeOctets=%1&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;for /l %%i in (1,1,255) do set #=%%i &amp;amp;&amp;amp; call :label&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;goto EOF&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;:label&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;@(call realtd)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;@(ping -l 1 -n 1 -w 2 %ThreeOctets%.%#% | findstr Reply | gawk '{print "%timestamp%" ":" $1 ":" $3$5}' )&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;:EOF&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and last we can put a collection of  the first three octects into text file and call them like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;for /f %i in (subnets) do call Testsubnet %i&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This gives us some reasonably parseable output:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;D:\&gt;call Testsubnet 193.0.0&lt;br /&gt;....&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;05.24.2008_19.43.04.01:Reply:193.0.0.232:time=173ms&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;05.24.2008_19.43.05.51:Reply:193.0.0.236:time=169ms&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;05.24.2008_19.43.06.01:Reply:193.0.0.238:time=171ms&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;05.24.2008_19.43.07.01:Reply:193.0.0.241:time=171ms&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;D:\&gt;call Testsubnet 194.0.0&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;05.24.2008_19.43.40.01:Reply:194.0.0.53:time=100ms&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Okay, so you can see quite a bit of inelegance here to start with. Let's list some issues:&lt;br /&gt;&lt;br /&gt;(1) a separate cmd file needs to run each time to log the timestamp&lt;br /&gt;(2) the ping options are hardcoded...that probably could be fixed...but more inelegance&lt;br /&gt;(3) we don't really need the field 'Reply' or 'time='.  but they are hard to parse out.  Once again more awk or perl code would probably do this but at what cost of complexity&lt;br /&gt;(4) I don't really want to have to call the file that calls THE file...I just want  to point to an XML file with all the correct options....&lt;br /&gt;(5) requires Cygwin or GNU-Win32 gawk in your path....&lt;br /&gt;&lt;br /&gt;I could go on, but you get the picture.  Let's assemble this tool with less complexity, more readability and more functionality in Powershell in the next post...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-1451431271731787367?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/1451431271731787367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=1451431271731787367&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1451431271731787367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/1451431271731787367'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/05/okay-so-lets-try-to-start-rewriting.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-920157608493514220</id><published>2008-05-18T16:31:00.000-07:00</published><updated>2008-05-18T16:37:05.804-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Snort'/><category scheme='http://www.blogger.com/atom/ns#' term='NBT'/><category scheme='http://www.blogger.com/atom/ns#' term='CMD.EXE: IP'/><title type='text'></title><content type='html'>&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The world of Windows  traditional cmd line is full of cumbersome crap. Just extracting the (NBT bound) IP Address takes two lines of idiosyncratic backquotes, escaped pipes, two temp files, Finally a call to snort with BPF options:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;@echo off&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;:: find the NBT tied IP Address&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for /f "usebackq delims=:"  %%i in (`ping -n 1 -l 8 %computername% ^| findstr Reply`) do @echo %%i &gt; IPReplyString.txt&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for /f "tokens=1-3" %%i in (IPReplyString.txt) do echo %%k &gt; IP.txt&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;:: set the IP address to %localIP%&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for /f %%i in (IP.txt) do set localIP=%%i&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;:: start Snort with BPF filters...&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;snort -l D:\SnortLogs -vdeX  dst host %localIP% and !(port 53 or 80 or 110)&lt;br /&gt;&lt;br /&gt;....&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-920157608493514220?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/920157608493514220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=920157608493514220&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/920157608493514220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/920157608493514220'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/05/world-of-windows-traditional-cmd-line.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-4639018131214250361</id><published>2008-05-14T11:02:00.000-07:00</published><updated>2008-05-14T11:12:02.628-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='log queries'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell:  AWK: Querying Authlogs'/><category scheme='http://www.blogger.com/atom/ns#' term='OPENBSD'/><title type='text'></title><content type='html'>I will confess to being nearly a complete loser when it comes to successfully implementing sed, awk and regex. to search logs.  I usually end up parsing my Authlogs with something really clueless like:&lt;br /&gt;&lt;br /&gt;(IP Address and Port of invalid users with failed passwords)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$ grep "Failed password for invalid user" Sampleauthlog.txt | cut -b 75-110| uni&lt;/span&gt;q&lt;br /&gt; from 202.163.221.227 port 43985 ssh&lt;br /&gt;from 202.163.221.227 port 44553 ssh2&lt;br /&gt; ...&lt;br /&gt;&lt;br /&gt;or (the IP Address of valid users with failed passwords )&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 153);"&gt;$ grep Failed Sampleauthlog | grep -v invalid | awk '{print $11}'| uniq -c&lt;/span&gt;&lt;br /&gt;      5 202.163.221.227&lt;br /&gt;&lt;br /&gt;I have some idea that I can break down each time, user, IP address, port, ssh type into a typical Powershell objects and do more informative and complex queries, but this needed some work:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; $var=Select-string Failed SampleAuthlog.txt | Where-object {$_ -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;PS D:\Microsoft\Powershell&gt; $var&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;SampleAuthlog.txt:3:Apr 26 01:20:29 rmfbsd sshd[30534]: Failed password for invalid user test5 from 202.163.221.227 port 43985 ssh2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;SampleAuthlog.txt:5:Apr 26 01:20:32 rmfbsd sshd[11478]: Failed password for root from 202.163.221.227 port 44267 ssh2&lt;/span&gt;&lt;br /&gt;....&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Select-object $var&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Select-Object : Cannot convert System.Management.Automation.PSObject to one of the following types {System.String, System.Management.Automation.ScriptBlock}.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;At line:1 char:14. &lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;One way around this is to massage a log file into a CSV format which AWK does easily, then use Powershell import-csv routine&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;and manually add headers to the first line:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$ grep Failed authlog | grep -v invalid | awk '{print $1","$2","$3","$9","$11","$13,$15}'&lt;/span&gt;&lt;br /&gt;Apr,26,01:20:32,root,202.163.221.227,44267&lt;br /&gt;Apr,26,01:20:36,root,202.163.221.227,44411&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$ grep Failed authlog | grep -v invalid | awk '{print $1","$2","$3","$9","$11","$13,$15}' &gt;&gt; /cygdrive/D/Microsoft/Powershell/Powershell.out&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$PWSH = import-csv Powershell.csv&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$PWSH | ft -auto&lt;br /&gt;PS D:\Microsoft\Powershell&gt; $PWSH | ft -auto&lt;br /&gt;&lt;br /&gt;Month Day Time     User IP              Port&lt;br /&gt;----- --- ----     ---- --              ----&lt;br /&gt;Apr   26  01:20:32 root 202.163.221.227 44267&lt;br /&gt;Apr   26  01:20:36 root 202.163.221.227 44411&lt;br /&gt;Apr   26  01:20:47 root 202.163.221.227 44725&lt;br /&gt;Apr   26  01:21:02 root 202.163.221.227 45354&lt;br /&gt;...&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Now we have part of  an OPENBSD Authlog stored as a Powershell object.  Thanks AWK!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-4639018131214250361?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/4639018131214250361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=4639018131214250361&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4639018131214250361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/4639018131214250361'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/05/i-will-confess-to-being-nearly-complete.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-2095481124658627906</id><published>2008-05-09T23:57:00.001-07:00</published><updated>2011-05-19T09:14:42.834-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Sequential File and Directory Creation'/><title type='text'>Sequential file and Directory Creation</title><content type='html'>Sequential file and Directory Creation. Useful for Test Engineers.&lt;br /&gt;&lt;br /&gt;creates directories&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #333399;"&gt;1..100 | %{ni ( "NewDirectory-{0:0}" -f $_ ) -type directory }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;creates files with sequential content&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #333399;"&gt;1..100 | %{ni ( "NewFile-{0:0}" -f $_ ) -type "file" -value "Number $_ of 100 files."}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-2095481124658627906?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/2095481124658627906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=2095481124658627906&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2095481124658627906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/2095481124658627906'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/05/sequential-file-and-directory-creation.html' title='Sequential file and Directory Creation'/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-6710603058280115206</id><published>2008-05-09T23:49:00.000-07:00</published><updated>2008-05-10T23:15:37.877-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell:  Query GAC'/><category scheme='http://www.blogger.com/atom/ns#' term='Query .NET Collections'/><title type='text'></title><content type='html'>Use these two functions to query  the  supported assemblies [GAC]  and .NET Collections  (from Windows Powershell in Action, Bruce Payette)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 153);"&gt;function Get-Assemblies {[AppDomain]::CurrentDomain.GetAssemblies()}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 153);"&gt;function Get-Types ($Pattern=".") { Get-Assemblies | %{ $_.GetExportedTypes() } | where {$_ -match $Pattern} }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Get-Types System&lt;br /&gt;Get-Types System.Collections&lt;br /&gt;Get-Types System.Collections | more&lt;br /&gt;Get-Types System.Collections.Specialized | more&lt;br /&gt;Get-Types System.Collections.Specialized.StringDictionary&lt;br /&gt;Get-Types System.Collections.Specialized.StringDictionary | gm&lt;br /&gt;Get-Types System.Collections.Specialized.StringDictionary | gm | more&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-6710603058280115206?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/6710603058280115206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=6710603058280115206&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6710603058280115206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/6710603058280115206'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/05/use-these-two-functions-to-query.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6313390886970291384.post-5110382519112118847</id><published>2008-05-09T23:40:00.000-07:00</published><updated>2008-05-13T18:20:02.646-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell: Network Info from Win32_NetworkAdapterConfiguration'/><title type='text'></title><content type='html'>&lt;span style="font-family:arial;"&gt;The "Get-WmiObject" query below retrieves information from all network adapters.  Piping to a Select-Object query produced a table sorted  by Adapter Index. The  Win32_NetworkAdapterConfiguration provides lots of configuration data so additional Network Adapter Query functions could be derived from it.&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div  style="text-align: left;font-family:verdana;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 153);"&gt;$NetworkInfo =gwmi -query "SELECT * FROM Win32_NetworkAdapterConfiguration"&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 153);"&gt;&lt;br /&gt;function NetworkInfoSort {$NetworkInfo | Select-Object IPAddress,Description,Index,DefaultIPGateway | sort-object Index}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;PS C:\&gt; NetworkInfoSort | ft -auto&lt;br /&gt;&lt;br /&gt;Also useful:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;gwmi -class win32_NetworkAdapterConfiguration | %{ $_.IPAddress }&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6313390886970291384-5110382519112118847?l=horizontal-logic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://horizontal-logic.blogspot.com/feeds/5110382519112118847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6313390886970291384&amp;postID=5110382519112118847&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5110382519112118847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6313390886970291384/posts/default/5110382519112118847'/><link rel='alternate' type='text/html' href='http://horizontal-logic.blogspot.com/2008/05/get-wmiobject-query-below-retrieves.html' title=''/><author><name>Ryan M. Ferris</name><uri>http://www.blogger.com/profile/03122603266808854365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='21' src='http://4.bp.blogspot.com/_-L4HUu8oKmI/TTUwJCh4LQI/AAAAAAAAHb4/vzx_aHDltF4/S220/SleepingLionWillRise.jpg'/></author><thr:total>0</thr:total></entry></feed>
