r/PowerShell • • May 12 '22

Thank you all.

I just want to say that I started learning powershell and scripting with it just over a year ago. This reddit group has helped me a lot along the way. I can safely say that each time I come to view the posts and the comments, I ALWAYS learn something new that makes my brain go "WHA you can do that?" or "HUH why haven't I been doing it that way?!"

You guys n gals truly are some awesome folks. Though I haven't posted here often, you all show support to anyone who does post here and usually give more than one route to use as we all know every network is different and some methods work, some don't.

I'm still in the learning stages but I've been able to create multiple scripts for my team because of you guys and your info, knowledge, and support. Alright soppy time over.

127 Upvotes

70 comments sorted by

32

u/GamerWithAKid May 12 '22

Keep at it 👍🏻

Would recommend using Visual Studio Code instead of ISE. Alot of addins to help your code have better readability etc.

11

u/LittleManMichael May 12 '22

Unfortunately at work I'm only authorized to utilize ISE. I would like to use visual studio code and other tools that would help me, but I feel if I use them at home, I'll get used to them and it'll cause a conflict of 'workability' at home. But I may just be overthinking it.

13

u/fatherjack9999 May 12 '22

Use it at home and then you can form a good set of reasons and benefits for swapping to it.

For starters: ISE is getting no further development from Microsoft where VSCode gets monthly updates. Code formatting and syntax highlighting help with debugging and vice maintenance which are both time savers and your time = your employer's $$$ ...

2

u/LittleManMichael May 12 '22

That's definitely an idea. I will have to do that! It'll allow me to garner reasonings and maybe present it to my management.

5

u/GamerWithAKid May 12 '22

This 100%, I couldn't use anything else when scripting.

2

u/Thotaz May 12 '22

syntax highlighting

Ironic that you mention that when this is one of the few areas that ISE does objectively better than VS code. Try pasting this into VS code, ISE and a PS console with PSReadline loaded: Get-ChildItem -Path $PSScriptRoot\whocares

In VS code Path and whocares will both have the same color. In ISE and PSReadline they each have a distinct color. If you enable the semantic color feature in VS code it will correctly identify the parameter as a parameter but the default dark theme will color the parameter and variable the same color. You may think "Great, I'll just enable semantic coloring and adjust my theme" but if you do that you'll have to deal with other inaccuracies, like this: Get-ChildItem -Path C:\whocares where it identifies the C:\whocares path as a command.

3

u/SeeminglyScience May 12 '22

Bookmarking for when I tackle semantic highlighting ♥

If you can think of any other gripes with it, hmu


Also FWIW your feedback has been super helpful. I have a PR open that fixes most of the intellisense issues you brought up in the update thread (except intellisense in the console. Also haven't fixed linebreaks in tooltips yet but that drives me crazy too, so for sure on my list).

Should be a dramatically different experience once that's in, so thanks for the kick!

PR link for the curious

3

u/Thotaz May 13 '22 edited May 13 '22

This snippet includes examples of all the different token types ISE lets you customize and includes examples that highlights odd behavior in VS code:

using namespace System
using namespace System.Buffers
using module @{ModuleName = "Microsoft.PowerShell.Utility"; Maximumversion = "9.0.0"}
function Test-Me{}
function Test
{
    param
    (
        #This is a comment
        [Parameter()]
        [string]
        $Param1 = [string]::Empty.Length.GetType().FullName
    )
    process
    {
        :loopLabel foreach ($x in $y)
        {
            (DemoCommand -Param1 C:\Windows -Param2 $PSScriptRoot\whocares `
            -Param3)
            break looplabel
        }
        100 * 100
    }
}

I'll list all issues from top to bottom:
1: System and System.Buffers have 2 different token types, neither of which seem accurate for what they mean in this context. ISE classify them as CommandArgument.
2: @{ doesn't have a semantic token at all. This isn't really a problem because textmate covers it fine and it enables bracket pair colorization to work but this makes @ stand out from {. Is there a way to include it in the bracket pair colorization feature?
3: ModuleName is correctly classified as a property but I think it's a shame that the default themes make variables and properties share the same colors because the whole point of syntax highlighting is to have different elements stand out from each other and when you have something like $SomeVar.SomeProperty.SomeOtherProperty it just looks like one long variable when you glance over it.
4: Test-Me has a semantic token while Test doesn't. The semantic token is function which is fine but I like that ISE classifies function definitions differently from function calls. In ISE it's classified as a CommandArgument.
5: Parameter is classified as a type, ISE classifies it as an attribute. I think it's very useful to have attributes stand out from types when looking at the parameters in a param block so you don't have to scan through a bunch of attributes to find the type constraint for a parameter. PSReadline has the same issue but attributes are rarely used in the shell so it's not that big of a deal.
6: :loopLabel has no semantic token or textmate scope so it cannot be customized whatsoever.
7: -Param1 is correctly classified as a parameter but like in 3, the default theme makes it share colors with variables.
8: C:\windows is classified as a command when it should be a CommandArgument.
9: \whocares has no semantic token or proper textmate scope so like the looplabel it cannot be customized. It should be a CommandArgument IMO.

I didn't mention things that the textmate grammar seems to handle fine like the backtick but ideally everything should be handled by the semantic tokens. The whole concept of using a separately maintained regex pattern list to tokenize scripts seems absurd when there's a perfectly good parser built-in that shows the user exactly what PowerShell sees. The textmate grammar falls apart when dealing with intentionally obscure or incorrect code which is exactly the time when you want it to be most accurate.


I'm glad my venting serves a higher purpose 😁. VS code has been so frustrating to me because from my perspective we had a perfectly good editor in ISE where PowerShell was a first class citizen but we lost it and was told to use another editor with a bunch of compromises in the user experience just so it could work with other languages and on other operating systems.
VS code does have some nice features that ISE can't compete with like the project handling and git integration but I feel that if all the work that was put into the PowerShell extension since 2015 had been spent on improving ISE and possibly porting it from WPF to Avalonia we would have ended up with a much better product than what we have today.
Rant aside, with the rewrite from rjmholt and all your contributions both before and after you've joined the team it does feel like it's finally getting close to a state that I'm happy with.

PS. It would certainly be nice if the linebreak issue could be fixed, but I'm afraid it's a VS code issue that you cannot fix from the extension side.

2

u/SeeminglyScience May 13 '22

This snippet includes examples of all the different token types ISE lets you customize and includes examples that highlights odd behavior in VS code:

Much appreciated tyty ♥

VS code has been so frustrating to me because from my perspective we had a perfectly good editor in ISE where PowerShell was a first class citizen but we lost it and was told to use another editor with a bunch of compromises in the user experience just so it could work with other languages and on other operating systems.

Yeah I can definitely empathize with that.

VS code does have some nice features that ISE can't compete with like the project handling and git integration but I feel that if all the work that was put into the PowerShell extension since 2015 had been spent on improving ISE and possibly porting it from WPF to Avalonia we would have ended up with a much better product than what we have today.

Well so from what I understand the control used for the ISE wasn't something we (as in the PowerShell team) owned and the team that did was sort of done with it. I know that's an absolutely nothing answer that is frustrating in it's own way, but it is what it is.

Because of that they probably would have needed to rewrite it from scratch anyway. This is just speculation, but my guess is we would have ended up with a just-as-or-even-more-janky editor that only works with PowerShell and has significantly less features than VSCode. And also less support for PowerShell in other editors.

I know that explanation doesn't really help anything, and I completely understand why the situation is frustrating.

Rant aside, with the rewrite from rjmholt and all your contributions both before and after you've joined the team it does feel like it's finally getting close to a state that I'm happy with.

♥ yeah with Rob's rewrite done, and Andy and I at the helm, hopefully folks will soon be arguing about which LSP enabled editor to use 😁

PS. It would certainly be nice if the linebreak issue could be fixed, but I'm afraid it's a VS code issue that you cannot fix from the extension side.

I think I found a different field you can use in the completion item message. I have a change locally that uses that + some string manipulation that looks a lot better. Still not perfect, but a whole lot closer. Still testing it, but it's promising!

2

u/SeeminglyScience May 20 '22

PS. It would certainly be nice if the linebreak issue could be fixed, but I'm afraid it's a VS code issue that you cannot fix from the extension side.

Here's my current draft of it btw. Ended up dialing the string manipulation up to 100 since all I'm workin' with is the same tool tip text. But it's looking pretty solid I think

2

u/Thotaz May 20 '22

❤ That looks amazing!. I love that you moved the namespaces and added colors to the different elements.

2

u/SeeminglyScience May 20 '22

ty :) fortunately you can give it markdown. Unfortunately, it won't wrap if you do. So I had to get a little creative with the namespaces and adding some extra new lines for parameters. I never liked the "always include the full name" bit anyway so not mad at that going away 😁

Still testing and tweaking but I'll update when it's in a preview! ♥

2

u/SeeminglyScience May 21 '22

It's in the latest preview :)

Some little things that need tweaking and a couple more tool tips need prettifying still but looking good

Also Get- should be reliable, if you can still repro that lmk

Also space is in completion triggers so validate set, enums like error action, all that works now

There are still some individual spots that don't generate completions as reliably or at all but I'm workin' through 'em

2

u/SeeminglyScience May 21 '22

Also Get- should be reliable, if you can still repro that lmk

Btw this was a very reliable way to repro a specific issue that sort of plagued completion in general and has now been fixed. Essentially the completion request was getting cancelled every time a documentation change event was sent, so it was a race between these two to complete first.

I knew something was up, but having a consistent way to repro was super helpful in actually getting it fixed so thanks!

→ More replies (0)

2

u/atem_nt May 12 '22

Debugging alone is the sole reason I’d demand vscode, saves me sooo much stress and time.

16

u/sdbaa May 12 '22

If your job doesn’t allow VSCode I’m seriously questioning management’s decision making

6

u/LittleManMichael May 12 '22

Well though I can't say who I work for, that probably gives you an idea who I work for.. So yeah management isn't amazing, but it is what it is.

4

u/PMental May 12 '22

Doesn't really give any hints. Both ISE and VSCode are Microsoft products.

1

u/LittleManMichael May 13 '22

I agree. I work in a SAP. So that's why they are so stingy about it. But if you don't ask you don't know, so I'll put forward a request!

2

u/[deleted] May 12 '22

This. Make a case for it and argue against whatever crap logic they have, it’ll be worth it if you can get approval to use it!

3

u/P1nCush10n May 12 '22

Sometimes it's not even management. There's a certain sector, at least here in the US, where every piece of software has to go though layers of bureaucracy, testing and approvals. Then, even after approved, has to be packaged and pushed through to a deployment tool, because most end users don't even have administrative rights on their own systems. That takes a different set of approvals, and testing.

Legit can take more time and coordination than it is worth. These same places will roll with out of date software and workflows until absolutely forced to change by external forces.

2

u/sdbaa May 12 '22

Roll it out with Autopilot OOBE/MDM. Assign each user a share for development, or use Scrum for teams. The actual logistics of pushing it to the users is quite simple. Even with extensions.

2

u/P1nCush10n May 12 '22

Oh, i know how easy it could be, and so do the people that would be in charge of building and maintaining the deployment tools, but they're hands are tied as well. If the app isn't on an approved list they don't build a package.

If an app has been approved, it's not necessarily approved for self-service deployment because of .... reasons .... Getting an app on the self-service list is a process of its own, few things get that far.

An app like VSCode has it's own challenges on the road for approval due to the inclusion of an extension system. Applications that can have their behavior modified tend to have an uphill battle especially if there isn't a way to restrict that behavior via some mechanism like Group Policy.. Though, if there was an admx for it, getting it imported and implemented is... you guessed it... another overly burdensome process.

The only time something 'fast' (and i have to laugh at that term) happens is when a massive security issue is publicly disclosed. Like the semi-recent Solarwinds hack. It got ripped and folks are tripping over each other while pilots of alternatives are being spun-up and evaluated. Though even at the accelerated pace, it's been ~2 years and we still don't have a permanent solution.

2

u/LittleManMichael May 13 '22

Without even trying, you describe my issue haha

2

u/weldawadyathink May 12 '22

If the restriction is just “IT doesn’t feel like installing it”, you can install it yourself without admin. You can even install it from the Microsoft store.

1

u/LittleManMichael May 13 '22

If there was a microsoft store. Besides, installations, unless done under admin credentials, even then are monitors and reported have to be approved. Users are denied access from running anything not .exe approved. Help admins can't even open browsers.

2

u/weldawadyathink May 13 '22

Are you allowed to share what sector this is? That seems unnecessarily locked down. I’m surprised they even let you run power shell scripts at all.

1

u/LittleManMichael May 14 '22

Can't share what sector, it's not known. We can only run scripts as compiled code created by sysadmins is 'too volatile' for us.

3

u/raip May 12 '22

So your work only allows an application that is no longer in active development over the current Microsoft recommendations that is not only free, but also can run completely within the user's profile and run space?

Bruh...

Even the TS-SCI environments I've worked in allow for VSCode. What's wrong with your company?

1

u/LittleManMichael May 12 '22

They are STUPID STINGY on what is allowed. Even if it's by the people who run the fricken operating system. And I'm only one man on the team that scripts / utilizes powershell mainly, so there's that as well.

2

u/raip May 12 '22

You had me at "They are stupid"

4

u/xCharg May 12 '22

I've tried to use it multiple times and I can't seem to understand why everyone praise it so much. It feels like I'm using robotic arm to scratch my butt with - too complex too heavy to do simple task. Not even mentioning that you have to install it and probably configure it in some way since you mentioned addins, while ISE is literally everywhere, just open and use.

But still lots and lots of people praise VS Code - why?

3

u/Big_Oven8562 May 12 '22

People do not understand the beauty and elegance of simplicity. They think if something is more complex it must necessarily be superior. A simple tool that does what it's supposed to is invaluable.

3

u/kibje May 12 '22

I understand the beauty of simplicity, but I also want to use git repos, program in PS 7.1 and use dark mode and fonts with programming glyphs. Those are some things that make programming much more enjoyable for me than an ancient interface.

I can imagine someone could be used to the old interface and it's always hard to switch to something new when you're getting a bit older 😉

1

u/LittleManMichael May 13 '22

Now that you mention it. I suppose the esthetics of something like that do make fixing every error a little easier haha.

1

u/Big_Oven8562 May 13 '22

Why do people keep insisting that ISE doesn't have dark mode?

Last time I tried to use VS Code, I just got frustrated that the shell and intellisense kept breaking, forcing me to relaunch the thing and it takes forever to launch. That makes for a dogshit workflow, so it holds no appeal for me.

ISE just works, which is what I ask of a tool.

1

u/kibje May 13 '22 edited May 13 '22

With very minimal configuration VSCode is stable, launches fast, has many more features than ISE and is actively developed so will keep becoming better over time.

That you were unable to figure out to do this is not a great argument to be honest. The generalisation that people would think 'more complex is better' is absurd. Most people in my team chose to go with VSCode out of annoyance at the many additional tools necessary to make cooperative workflows work when using ISE.

I can see the appeal to choose the tool that can't be extended easily, is missing commonly used features, doesn't support modern development workflows or debugging and testing practices and doesn't receive any fixes anymore, but pretty much only when you don't use those and are used to ISE.

In that case, yes... why would you change?

0

u/Big_Oven8562 May 16 '22

Why would I spend time learning to fix a broken tool when I have one that's fully functional out of the box and fulfills my exact needs perfectly?

VSCode fanboys are all cope.

1

u/kibje May 16 '22 edited May 16 '22

"I don't understand it and I don't need it so anyone who likes it is a fanboy".

Yikes, guess I got trolled into trying to give some insight

0

u/Big_Oven8562 May 16 '22

This from the guy who couldn't figure out how to enable dark mode.

Laughable.

1

u/kibje May 16 '22

Your trolling is getting worse mate.

→ More replies (0)

4

u/GamerWithAKid May 12 '22

I don't think it's complicated at all and I only use a few addins.

One to automatically close your brackets, one for different colours for your comments.

Also dark mode is much better than ISE 😎

But each to their own 👍🏻

2

u/BuddhaStatue May 12 '22

Powershell ISE isn't even an option for pwsh

If you don't need the features that's ok. But there are so many features available in VSCode compared to the ISE, it's like arguing you don't need a tractor because you can plow a field with a horse.

Debugging alone is enough to make VSCode worth the time to learn. The first time I was able to debug someone else's API by stepping through a script I didn't even write? That feeling is what it must have felt like to the first human that discovered fire

3

u/xCharg May 12 '22

Powershell ISE isn't even an option for pwsh

Okay, we, people who used it for years, didn't know.

2

u/kibje May 12 '22

You can only use ISE with pwsh (7.1) by using some binary hacked version otherwise it just doesn't work

3

u/Thotaz May 12 '22

Have you ever heard about Enter-PSHostProcess? It works similar to Enter-PsSession by allowing you to enter another PS process on your computer. You can use that from ISE to enter a pwsh process and it will work just like any other remote session. The only problem with this is that ISE doesn't support the ANSI/vt-100 codes used to color things and 7.3 added it to all the headers for lists and table views so reading output can be a bit challenging.

1

u/kibje May 13 '22

That's the only problem you have with pwsh 7 in ISE? Not the issues with debugging that happen when you do this?

1

u/Thotaz May 13 '22

I never use the PowerShell debugger. I find it easier to manually run small sections of the code and make adjustments than saving the script, setting a breakpoint and running things from the top.

1

u/kibje May 13 '22

Yes I can imagine. I would probably not do it either if I had to deal with the ISE debugging experience.

2

u/Thotaz May 13 '22

Alright, I'll bite, explain how the VS code debugging experience is better? Does it allow you to set a line breakpoint, run that code section with F8 and have the breakpoint triggered? Or does it force you to run the whole script from the top with F5.

→ More replies (0)

2

u/Artaois May 12 '22

Which plugins do you recommend? I tend to use ISE atm.

2

u/GamerWithAKid May 12 '22

I only use a few: Better Comments - Allows you to have multiple colours for your comments Bracket Pair Colorizer - Colors your brackets to help readibility

1

u/CongrachuBot May 14 '22

Congrachulations, out of all posts made on 12th May (UTC) in r/powershell, yours was the topmost comment (out of 276 total comments).

Keep rocking!

0

u/[deleted] May 12 '22

[deleted]

2

u/GamerWithAKid May 12 '22

I only use a few: Better Comments - Allows you to have multiple colours for your comments. Bracket Pair Colorizer - Colors your brackets to help readibility

7

u/OPconfused May 12 '22

My favorite is mklement on stackoverflow. That guy has taught me at least half of what I know about PowerShell, and he doesn't even know I exist.

1

u/LittleManMichael May 12 '22

Sounds like someone I will definitely need to check out!

5

u/OPconfused May 12 '22

Also Mathias Jessen has some great replies. They're both prolific answerers.

Mklement basically formats almost all of his replies like stand-alone passages that could be in-depth summaries from a book. In fact, if all his answers could be compilated into a book, I think it would be among the best resources out there. Most people just answer a question, but he takes a lot of time to make the reply as complete a resource as possible. When I first began, I never knew about Powershell in a month of lunches; I had 18 months of majority his stack overflow posts.

But no reason to search for him. If you google questions about PowerShell and click on the stackoverflow responses, you'll invariably come across them.

2

u/LittleManMichael May 12 '22

That's amazing. Such an awesome person! Thanks for the recommendation!

4

u/BlackV May 12 '22

mklement on stackoverflow

I assume this person

https://stackoverflow.com/users/45375/mklement0

2

u/OPconfused May 12 '22

Yep!

2

u/BlackV May 12 '22

yeah there is some glorious stuff there

3

u/endowdly_deux_over May 12 '22

He also helps Microsoft with the OSS repo for PowerShell Core -- very knowledgeable!

2

u/Br41nsy May 12 '22

Way a go at keeping on top of the power shell learning.

Just out of interest what has been the most useful script you’ve created?

2

u/LittleManMichael May 13 '22

Thank you! I'm always learning, I guess that's the most enjoyable part. Powershell itself is so indepth and complex, that I'm learning something new every day.

I'd have to say in terms of most useful for them, I've created a GUI script that allows admins to select different servers from a selected OU and read their drive space via details and progress bar. Showing 12 drives a page, with a next and previous page button, then also allowing them to expand it to view more specific details like it's filesystem, where it's located etc. After that, they can export all the drives to either a .CSV file for easy implementation somewhere else, or to a custom edited .xlsx file that is color coded. Took me a while to make it and a lot of learning, but they love it as they do weekly drive space reports and it saves them time from logging into each server, or running commandline.

2

u/Billi0n_Air May 12 '22

your welcome.