Search found 12369 matches

by jvierra
Sun Jul 08, 2018 3:04 pm
Forum: Windows PowerShell
Topic: year and countryname extract
Replies: 22
Views: 365

Re: year and countryname extract

You wanted the newest file and that is the first file.
by jvierra
Sun Jul 08, 2018 3:02 pm
Forum: PowerShell GUIs
Topic: SendPingAsync makes form freeze
Replies: 15
Views: 252

Re: SendPingAsync makes form freeze

I updated the the demo because I found a bug in my code. It no longer fails intermittently.
Download from the previous post.
by jvierra
Sun Jul 08, 2018 12:12 pm
Forum: Windows PowerShell
Topic: year and countryname extract
Replies: 22
Views: 365

Re: year and countryname extract

Works fine for me:

('abc_China_2017_1' -split '_')[2]
by jvierra
Sun Jul 08, 2018 11:35 am
Forum: PowerShell GUIs
Topic: SendPingAsync makes form freeze
Replies: 15
Views: 252

Re: SendPingAsync makes form freeze

Great. I actually learned a bit about the newer Net Ping as it now does its own threading and likely uses some good threading tricks. Because I was not familiar with this I decided to build a quick demo. Here is a full demo of a good way to use this in a form.
by jvierra
Sun Jul 08, 2018 11:33 am
Forum: Windows PowerShell
Topic: year and countryname extract
Replies: 22
Views: 365

Re: year and countryname extract

More like this:

Code: Select all

Get-ChildItem -File -Path $sourcedir|
    select *, @{n='Year';e={($_.Basename -split '_')[2]}}
    Group-Object Year | 
    ForEach-Object {
      $_.Group | Sort-Object LastWriteTime -Descending |
        Select-Object -First 1
    }
by jvierra
Sat Jul 07, 2018 9:50 pm
Forum: PowerShell GUIs
Topic: SendPingAsync makes form freeze
Replies: 15
Views: 252

Re: SendPingAsync makes form freeze

The tasks are faster but will not work in a form. You can try to use a job and monitor the job for completion.

Just tested. It works in a form if it is run in job. A 'C' subnet takes about 2 seconds.
by jvierra
Sat Jul 07, 2018 8:02 pm
Forum: PowerShell GUIs
Topic: SendPingAsync makes form freeze
Replies: 15
Views: 252

Re: SendPingAsync makes form freeze

A little research. TTL or TImeToLive is the number of hops before setting a return status. TTL less than 5 will not be normally honored as the ping will complete even in fewer hops and will not terminate at the fifth hop. Only the "TimeOut" on the send will terminate the wait at a specific time (see...
by jvierra
Sat Jul 07, 2018 4:53 pm
Forum: PowerShell GUIs
Topic: SendPingAsync makes form freeze
Replies: 15
Views: 252

Re: SendPingAsync makes form freeze

The following should be a bit faster and it will return results as each thread completes. workflow Send-ParallelPing{ Param($servers) foreach -parallel -throttlelimit 64 ($server in $servers){ InlineScript { Try{ $P = [System.Net.NetworkInformation.Ping]::new() $result = $P.Send($using:server) [pscu...
by jvierra
Sat Jul 07, 2018 4:47 pm
Forum: PowerShell GUIs
Topic: SendPingAsync makes form freeze
Replies: 15
Views: 252

Re: SendPingAsync makes form freeze

This will likely be faster and easier to manage. It also avoids async issues with PS. THe ping object can be moe easily tailored using PingOptions. workflow Send-ParallelPing{ Param($servers) foreach -parallel -throttlelimit 64 ($server in $servers){ Try{ $P = [System.Net.NetworkInformation.Ping]::n...