10 ms·
PSKoans: A simple, fun, and interactive way to learn the PowerShell language
- motohagiography 4y agoA strange game. The only winning move is to write scripts in powershell.
- baal80spam 4y agoGreetings, professor Falken.
- rideontime 4y agoThank you for this, I've avoided learning powershell for as long as possible but recent circumstances have left me no choice in the matter.
- waste_monk 4y agoPowershell has plenty of warts and weird design choices, but hopefully once you immerse yourself in it you'll find it's actually fairly nice to work with. The "object pipeline" nature of it means that working with complex structured data is far easier than trying to mangle the same data as lines of text in a traditional shell.
- beoberha 4y agoI’m with you. Powershell is a jarring experience for someone not used to it. Heck, it’s still jarring for me and I’ve been working at Microsoft for over 5 years. I truly dislike writing it. That said, it’s so much more “usable” than any other shell or scripting language. It’s hard to explain to someone who hasn’t used it, but I even reach for Powershell over Python in my daily work.
- reassembled 4y agoJust today I used ChatGPT to turn our existing batch scripts into PowerShell, and convert the existing environment variables into command line options. Worked flawlessly and saved a ton of time.
- ellipticaldoor 4y agoyes, that is very useful
- celadin 4y agoNice! GPTs have proven invaluable for PS stuff. I have it add comment-based help blocks when I don't feel like writing them myself :) super easy.
- mnadkvlb 4y agoNice :). I would have loved if this existed a few years back (story below). A few years back when i was consulting, my manager threw me in a meeting for a client wanting to use ping identity to synchronize their identity data for sso. The client wanted a cheap solution as their ping sso budget was overblown already so i tried making a call with powershell to ping sso which worked. We agreed on a day next week to write this client in powershell (which i didnt have much clue about at that time). Took a book called powershell in a month of lunches and just started doing the lessons in my train rides from my work to home over the week (2hrs in total a day). The next week when i met the client, we finished writing the sync client in less than a day including testing. The client later told my ex-manager, that it was the cheapest and fastest IT solution they got. Tl;dr: amazing book to learn powershell: powershell in a month of lunches.
- ainar-g 4y agoI'll share a bit of personal experience for those who hate PowerShell to maybe make them look at it from a new point of view. As a devoted Unix fanatic, I used to hate PowerShell, because I initially came in with the expectation that it's going to be “just another POSIX-like shell”. After all, it's right in the name! And it uses dollar signs! So every little thing that differed from my unixey expectations made me angry. (Them using awful aliases like wget and curl didn't help. Seriously, what were they thinking?) But once I've realized that PowerShell is much closer to AWK and Perl, I kind of started to almost enjoy it. Don't get me wrong, it's not my favourite language or anything. But these days I think that it is a formidable scripting language with most of the stuff you'd normally need in place, at least in the recent versions. One thing that I still dislike is the absence of something like the Unix manual pages. For some reason, help pages require additional installation, and the learn.microsoft.com search is so awful that it's often quicker to use DDG with "site:learn.microsoft.com".
- mananaysiempre 4y ago> I've realized that PowerShell is much closer to AWK and Perl [than to POSIX shell] For me, what distinguishes[1,2] the former category from the latter one is that the latter one is quick and comfortable to use interactively, as a shell for the OS, to iterate at the command line and not in the editor, while the former one... isn’t. The cost is that a couple hundred lines of AWK are usually fairly OK, while the same amount of shell visibly strains the language. Are we still in the world where the interactive text-based environment (not programming environment) with the best available ergonomics is based on a general framework set in 1979? I’m aware Lisp machines existed and did things differently, but the best you can get in that respect now is Emacs and it still cannot reach that seamless ad-hoc composability of Bourne shell. [1] http://yosefk.com/blog/i-cant-believe-im-praising-tcl.html http://yosefk.com/blog/i-cant-believe-im-praising-tcl.html [2] https://scsh.net/docu/html/man-Z-H-1.html#node_toc_node_sec_1.4 https://scsh.net/docu/html/man-Z-H-1.html#node_toc_node_sec_...
- throw_a_grenade 4y ago> Are we still in the world where the interactive text-based environment (not programming environment) with the best available ergonomics is based on a general framework set in 1979? Yes, because it's not broken (certainly not for interactive use), so it's not in a need for fixing. People who don't understand it are doomed to reinvent it poorly (vide curl/wget aliases in powershell).
- devinprater 4y agoGoodness Powershell is gross. Why would I went to do get-command or some junk. Ah well, I just need to work with it more. Tried the month of lunches book, but it got rather in-depth pretty quickly to me. Maybe ChatGPT can break it down a bit more.
- Joker_vD 4y agoI suspect you find Powershell "gross" only in a sense that "it is not a sh-inspired shell", but that's quite subjective. Now, cmd.exe, that is objectively gross. But Powershell? Unless your first shell experience was bash and it imprinted on you, no, it's not gross.
- ketzu 4y ago> Why would I went to do get-command or some junk. One reason might be to make commands consistent and improve discoverability.
- Joker_vD 4y agoA tangent comment: is there some document with guidelines/list for emoji headers to use in commit messages? I mean stuff like "bug" for bug fixes, "upwards black arrow" for upgrading dependencies, "artist palette" for stylistic changes etc — I like it more than those sad +/-/* headers but I'd like to see this custom written out explicitly.
- WorldMaker 4y agoI think a lot of the emoji choices are personal, but there are plenty of customs written out. One of the most common I see referred to is gitmoji.dev. It's somewhat popular because it also offers a CLI tool to help write commit messages in that style and to setup hooks to do some basic enforcement, if you wish.
- adzm 4y agoI only wish it was easier to put c# code within a powershell script. Would be a great mix of two worlds.
- auxym 4y agoIt's actually pretty easy to "import" a C# class, either from a string or from a separate .cs file, with `Add-Type`, you don't even need to compile it first. See: https://stackoverflow.com/a/24881346 https://stackoverflow.com/a/24881346
- SeriousM 4y agoThere is no fun in a language with little to no help from the "intellisense/autocomplete" and the verb starting the command like "get-item". Ich you're used to autocomplete one will type "item<tab>" to get available commands or just explore the api - not so in pwrsh. I'm a c# dev vor over 20 years and have troubles to like the ps language.
- Guillaume86 4y agoI just type "*item" then ctrl+space and I get this: https://imgur.com/a/bmLWHnU https://imgur.com/a/bmLWHnU
- WorldMaker 4y agoThat is a useful tip that ctrl+space/tab completion supports wildcards. Also, older versions of PowerShell used to include the ISE which offered better auto-completion UI and I found really helpful for learning at times. Today the suggestion is to install the PowerShell extension in VS Code if you want the best auto-completion support and a lot of features lit up for .ps1 files. (That's the closest to a modern ISE.) https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell https://marketplace.visualstudio.com/items?itemName=ms-vscod...
- axus 4y agoBefore version 6, PowerShell would default to writing output files as UTF-16LE. Good to know before reading those in to something expecting UTF-8.
- replwoacause 4y agoI love PowerShell. I've built CLI apps, desktop GUI apps, web apps, and integrations using it. Now that I can use it on Mac, Windows and Linux it's even more valuable to me. It isn't without a few shortcomings, but I've tried picking up other languages and keep returning to what makes me productive and happy: PowerShell. I've read the criticisms, and experienced some of them firsthand, but considering all that I've been able to do with PowerShell the good far outweighs the bad.
- mxuribe 4y agoI'm curious....are the shortcomings that you encounter the types where elements of your scripts need to differe between Mac, windows, and Linux? I ask because i really don't like powershell...but am crafting more and more cli apps on linux, and now (sadly) am starting to spend more time across both linux and windows (forced on windows due to work)...so it makese sense to consider a cross-platform shell.
- WorldMaker 4y agoAnecdotally, I haven't noticed too much pain in crafting cross-platform scripts in PowerShell 7+. Most of the platform differences I've seen in PowerShell are at the "module level" (library of "commands/cmdlets") and most commands that are in platform-specific modules generally are pretty obvious that they are platform-specific modules. A lot of modules are cross-platform. The biggest shift is learning to trust PowerShell commands/cmdlets and operators over platform-specific binaries like awk/sed/grep and so forth. A lot of those tools and manipulation steps can be done with native PowerShell commands/cmdlets/operators, but it's definitely a journey to thinking in PowerShell terms (that the linked repo looks like it can help with) and using/trusting its object-based tools, especially if you are used to the extended Linux shell text manipulation tool chain as "conversion" between the two paradigms isn't always straightforward.
- mxuribe 4y agoAaahhh, ok, i understand now. Thanks alot; very, very helpful!