Part of me critically needs to be concerned in UX. I continually discover issues with nearly each UI through which I interface. This one is gorgeous, however it’s missing. This one is ugly, however works. Perhaps it’s why I like PowerShell; it’s all the time the identical it doesn’t matter what I’m working with. It’s in all probability additionally why I want each web site on the planet was written with APIs first. What a tremendous world, if I might do every little thing utilizing PowerShell: examine the financial institution, register youngsters for college, order Chipotle, and make appointments on the physician, the dentist, the attention physician, the auto store, and so forth. The checklist is countless.
Anyway, again to the subject right here. I’ve typically thought of shopping for a brand new area and declaring terrible, real-world experiences of my very own till somebody comes alongside, realizes I get it, and employs me to cease all of the terrible interfaces… a minimum of for that firm. Us people, residing on this digital world, are continually subjected to awful-looking, unhelpful, and inconsistent interfaces which have develop into a requirement in our lives. If I request that your web site present me 100 rows at a time, then it’s not going I’m going to vary my thoughts after I click on into one file after which return out to the row view once more. And if I do wish to change it, guess what, that’s on me. I might go on for days.
The corporate accountable for these, two paragraphs is the rationale I’m writing immediately. I used to be despatched an inventory of 100 or 200 CIDR ranges. No downside, I’ll simply copy and paste them into that one field on the web site set to just accept each single IPs and CIDR ranges. Nope. That induced an error. It was unable to parse it, and so now it was my job to enter them one by one!? Nicely, it could’ve been had I not recognized PowerShell. Critically, somebody someplace is perhaps doing that. Copy and paste, or choose and drag, or no matter different choice was left. Whichever technique, it could be a lot slower than what I did. So, immediately’s put up is each me venting slightly of my pent-up UX frustration and offering a fast decision for anybody on this identical state of affairs, that didn’t routinely assume PowerShell themselves. You see, the interface would take a comma-separated checklist, it simply couldn’t deal with a line-delimited checklist–if that’s even what that’s referred to as. Perhaps new-line-delimited; I don’t know for certain.
Right here’s what I had (after eradicating the general public IP addresses):
10.138.80.0/22 10.138.87.160/27 10.138.91.160/27 10.138.129.0/29 10.139.33.96/28 10.139.38.0/27 10.224.1.32/27 10.224.41.128/25 10.224.43.0/24 10.224.73.0/25 10.228.21.192/27 10.120.1.0/27 10.128.1.32/27 10.128.11.64/26 10.128.29.0/24 10.128.205.128/26 10.130.66.0/25 10.152.7.160/27 10.152.12.0/24 10.152.13.0/24 10.152.14.0/24 10.152.15.0/27 10.156.20.0/28 10.156.20.16/28 10.156.20.32/27 10.156.20.96/27 10.156.24.0/22 10.156.28.128/26 10.156.29.0/24 10.156.30.0/24 10.156.31.0/24 10.156.32.0/24 10.156.33.0/24 10.156.34.0/24 10.156.35.0/24 10.156.36.0/24 10.156.42.0/24 10.156.43.0/24 10.160.20.0/25 10.161.43.0/25 10.161.43.128/25 10.161.44.0/22 10.161.48.0/22 10.162.2.0/27 10.166.9.0/24 10.192.237.0/26 10.192.238.0/24 10.192.255.0/25 10.193.120.0/25 10.193.120.128/25 10.193.121.0/25 10.193.121.128/25 10.193.122.0/25 10.193.122.128/25 10.193.123.0/25 10.193.123.128/25 10.193.124.0/25 10.193.124.128/25 10.193.125.0/25 10.208.17.0/24 10.208.21.0/24 10.224.21.0/25 10.224.40.0/24 10.224.61.192/26 10.224.71.32/27 10.224.71.160/27 10.224.72.192/27 10.224.74.0/23 10.224.78.0/24 10.224.81.0/25 10.224.81.128/25 10.224.82.64/26 10.224.83.0/24 10.224.100.0/22 10.224.104.0/22 10.224.108.0/22 10.224.112.0/22 10.224.116.0/22 10.224.120.0/22 10.224.124.0/22 10.224.128.0/23 10.224.130.0/23 10.224.132.0/23 10.224.134.0/23 10.224.136.0/23 10.224.138.0/23 10.224.140.0/23 10.224.142.0/23 10.224.148.0/22 10.226.3.0/26 10.229.16.0/23 10.230.12.128/25 10.140.76.0/24 10.140.78.0/28 10.140.102.0/24 10.140.103.0/24 10.140.113.0/24 10.140.138.0/24 10.140.139.0/26 10.120.1.32/28 10.128.167.32/27 10.192.178.64/26 10.194.3.128/25 10.224.5.128/26 10.224.42.0/25 10.224.76.0/24 10.224.77.0/24 10.224.79.0/24 10.224.96.0/22 10.140.100.0/24 10.140.101.0/24 10.140.104.0/24 10.140.105.0/24 10.140.106.0/24 10.193.120.0/21 10.130.169.0/24 10.224.9.0/24
Let’s save this file to my laptop as C:UserstommymaynardDocumentsCIDR.txt
. Now, let’s see what number of entries we’re working with. What sort of time may I save?
$Path="C:UserstommymaynardDocumentsCIDR.txt" (Get-Content material -Path $Path).Rely
117
We’re working with 117 entries, or relatively, 116 commas. Yeah, I’m not transferring these over one after the other; I don’t have the type of time throughout my day. Enter PowerShell. To start testing, I selected a smaller subset of the CIDR ranges. After I was pleased with that, which was virtually instantly, I added the -join operator.
Get-Content material -Path $Path | Choose-Object -First 5
10.138.80.0/22 10.138.87.160/27 10.138.91.160/27 10.138.129.0/29 10.139.33.96/28
(Get-Content material -Path $Path | Choose-Object -First 5) -join ','
10.138.80.0/22,10.138.87.160/27,10.138.91.160/27,10.138.129.0/29,10.139.33.96/28
As soon as I had this, I solely had two issues left to do. One, check to see if the corporate’s UI accepted comma-separated entries like this, and two, if it did, then be part of all 117 addresses with a comma in between every, and stick with it with my day. That’s three issues. Nicely, 4 in case you depend writing up this put up after work. The UI did settle for issues that method, and so I ran the under command, pasted it within the field, saved every little thing, and reported again to my buyer that it was set and carried out, as requested. Subsequent.
(Get-Content material -Path $Path) -join ',' | Set-Clipboard