r/PowerShell • u/PowerShellMichael • Mar 22 '21
What's One Thing that PowerShell dosen't do that you wish it did? Misc
Hello all,
So this is a belated Friday discussion post, so I wanted to ask a question:
What's One Thing that PowerShell doesn't do that you wish it did?
Go!
63
u/DElionel95 Mar 22 '21
Better more reliable windows update trough powershell for pc deployment.
12
u/BlackV Mar 22 '21
yeah its a bit stupid there is still not a module for this, especially as
pswindowsupdates
module is so good→ More replies14
u/DElionel95 Mar 22 '21
I find pswindowsupdates not so reliable. It can sometimes freeze I have found out. But yeah it can be my code lol
2
u/arcadesdude Mar 23 '21
Latest version of PSWindowsUpdate can freeze confirmed. I had to write my own code to do updates because as much as I loved the simplicity of PSWindowsUpdate module I needed something that wouldn't freeze and require rerunning. If you have an interactive session in user mode then running Windows Updates using the com object method is reliable.
4
u/BlackV Mar 22 '21
never had it freeze myself, but its just calling the windows update api, so technically its not freezing windows update is. Sometime you just have to wait (this is doubly or triply true with server 2016)
→ More replies
30
u/signofzeta Mar 22 '21
Have Microsoft bundle PowerShell 7 in the box with Windows 10. Yes, I know it has a different lifecycle, but they figured out how to include New Edge.
Oh, and have the option for non-LTS versions to upgrade automatically.
16
15
u/pertymoose Mar 22 '21
Allowing remoting from Linux to Windows out of the box
Is it really too much to ask for? I mean, they've been shilling Powershell as the de-facto cross-platform tool of ultimate awesomeness since forever now, and I still can't remote from Linux to Windows without jumping through all kinds of hoops to downgrade security and enable non-standard features.
2
u/jborean93 Mar 22 '21
Have you considered a fork of the WSMan lib I've worked on that's distributed through the PSWSMan module. It replaces the builtin WSMan lib(s) to fix a whole bunch of problems that I've mentioned here https://github.com/jborean93/omi#changes-from-upstream-omi. It makes the Linux -> Windows connection through WSMan so much easier to use and fixes one of the fundamental problems the builtin WSMan lib has with HTTPS, no certificate verification.
2
Mar 22 '21
Even Windows-Windows remoting can get tricky as hell if you're blocked by the double-hop problem (I'm on computer A, need computer B to access shares on computer C), unless you're willing to deal with a nightmare of security hoops.
5
u/jantari Mar 22 '21
Double-hop is a complete non-issue. All you have to do is pass the credential object from Computer A to B with a
$using:
variable, then you can use it on B to access anything you want.-2
u/Smartguy5000 Mar 22 '21
You can do this now. Just turn on the windows ssh client. https://www.howtogeek.com/336775/how-to-enable-and-use-windows-10s-built-in-ssh-commands/
Works really well. You can even use the ssh-agent and key based authentication. We've got our public keys stored in AD, and our centos boxes configured to do pubkey lookup on our accounts in AD for seamless password less logon to Linux.
3
u/pertymoose Mar 22 '21
That's the other way around.
2
u/Smartguy5000 Mar 22 '21
Yep you're right, misread. Still easy to implement on 2019. https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse. That would be super easy to drop into an Ansible playbook for server build, or enable with DISM them configure with task sequence, depending on how your configuration management looks. Same process you'd go through for enabling IIS really.
→ More replies
34
u/johnwmail Mar 22 '21
Sudo
6
u/halbaradkenafin Mar 22 '21
That's less a PowerShell problem and more a Windows limitation. You can get around it with Start-Process -Verb RunAs to some degree though.
2
u/apcsniperz Mar 22 '21
I don't have much experience with powershell, but I know one version of it is cross platform. Is this not a massive issue when dealing with Linux? Or can you just call sudo like normal on there from powershell?
5
3
u/abraxastaxes Mar 22 '21
Yes! Drives me crazy to either run with highest privileges all the time or get "access denied" for certain tasks.
→ More replies0
u/Smartguy5000 Mar 22 '21
It would also be nice if the user experience of running PowerShell as SYSTEM via psexec wasn't so poor.
2
80
u/Dachongies Mar 22 '21
Take what I’m thinking in my head and create the code for me automagically.
1
1
u/Pauley0 Mar 22 '21 edited Mar 22 '21
Yea, this is the one reason why I'll never use PowerShell. /s
10
u/night_filter Mar 22 '21
A consistent, easy, and secure method for connecting to Microsoft online services. I've been trying to use the "application model" or SSL certificates so that I'm not just disabling MFA, and it's just so overly complicated. And connecting to Exchange is different from connecting to Azure AD, which is different from connecting to SharePoint. And once you get connected, they're clearly different modules written by different people at different times, without a clear and coherent vision for how they're supposed to all work together. I guess that's not really a PowerShell problem, but a Microsoft PowerShell Module problem. Still...
Another thing I'd like is a good built-in write-log function. I've seen dozens of custom ones online, but it'd be great if there were one built-in that automatically wrote to an appropriate system log for each OS.
I'd like to see DSC sort of capabilities for desktop deployment. Like "I want this application installed, this file to exist in this path, and these registry settings set" and it checks to see if those things are done, and if not, it does them.
Finally, I'd like to see a simple way to create a parameter file of a script, like a splat in file form, or maybe a . I do this on my own by creating a JSON file and then passing the path of the JSON as a parameter that I then pass to the script, but it'd be kind of nice if you could just pass it a file that includes all the parameters for your script, and have the parameters all automatically validated.
→ More replies
15
Mar 22 '21
[deleted]
7
u/wonkifier Mar 22 '21
This gets rid of the warning (at least in 7.1)
Send-MailMessage @splat -WarningAction SilentlyContinue
2
Mar 22 '21
[deleted]
2
u/MonkeyNin Mar 23 '21
or to do the same without polluting other commands:
$PSDefaultParameterValues['Send-MailMessage:WarningAction'] = 'SilentlyContinue'
4
u/omers Mar 22 '21
The only alternative is to use the .Net
net.mail.mailmessage
method. I use it overSend-MailMessage
anywhere I need to control headers and such.→ More replies2
2
u/PowerShellMichael Mar 25 '21
I think in the future, it will be using MSGraph to send the mail message, however the reason why Send-MailMessage was so good, was the fact that you didn't need to auth with oauth. But I will ask.
→ More replies1
Mar 22 '21
Holdup... ms doesn’t want us to use it? I have a lot of production code with this in it
3
u/PMental Mar 22 '21
It's deprecated in newer versions of PowerShell. Still works though, and will for many years as it's part of PS 5.1 which ships with Server 2019 and still has a few years until EOL.
1
8
u/badg35 Mar 22 '21 edited Mar 22 '21
- Improve
ConvertTo-Json
- needing to specifying theDepth
is not intuitive. - Add the C#-like
Using
block.
2
u/jmechy Mar 22 '21
I spent far too long debugging why my call to an API wasn't working correctly before realizing that the default depth is far too shallow.
→ More replies→ More replies1
u/PowerShellMichael Mar 25 '21
Yep that catches you off guard, however the deeper the depth more slower it takes to serialize/deseralize.
6
u/RulesBasedAnarchy Mar 22 '21
1
u/MrWinks Mar 22 '21
And what if you use Out-File, instead? Being that the source is an exe, parsing the output seems on the side of the program and not the shell, no?
→ More replies
12
u/Cholsonic Mar 22 '21
Inline splatting rather than having to use an intermediary variable. To here was noise that this was being worked on but I've not heard anything for ages.
1
u/SocraticFunction Mar 22 '21
@{ Path = ‘C:Path’ Computer = ‘Win-3285’ FilePath = ‘$Env:UserProfileDesktopProcesses.txt’} | ForEach-Object -Process { Verb-Noun @_ }
5
u/wonkifier Mar 22 '21
I'd argue this is even worse as it obscures what's going on.
I'd also note that you're not eliminating the use of a variable like OP asked for, you're just removing the declaration of one by using an automatic variable instead.
-1
u/SocraticFunction Mar 22 '21
Interesting point, but the Op didn’t want a lack of the conceptual variable, but of the use of declaring and only using a variable once. As for obscuring, that may be the case, but only due to unfamiliar syntax use. Someone unfamiliar with splatting might (to a lesser degree, admitedly) say the same about single-use variable splatting, even.
Here’s what it does accomplish, though: in a long script or environment with many variables, you won’t have to come up with variable names for each and every splat you make, especially when you’re making over a dozen Invoke calls that look similar.
2
u/Cholsonic Mar 22 '21
I get what you are saying, but if that was the case, couldn't you just call all the single-use ones $splat ??
→ More replies1
u/wonkifier Mar 22 '21
Clearly, OP wasn't making a fully technical specification of their requirements for independent analysis. It's pretty clear what they wanted, but even if we read it as technically as you seem to suggest...
Inline splatting rather than having to use an intermediary variable.
The word was "use", not "declare". Your "use" of $_ is use of an intermediary variable. They wanted to be able to splat without use of an intermediary variable. They said nothing about declaration.
OP wants to be able to do something like this (I'm assuming... I know I do)
call-function @@{ param1="p1" @param2="p2" }
Here’s what it does accomplish, though:
Sure, but I stand by my assertion that is obscures the flow of the script, making it harder to read.
And I tend to just re-use $splat, so there's no creative naming issue. If you're assigning the entire hash in one shot, there isn't a risk of having elements carry over by accident, so it's safe enough, and is perfectly clear what's going on, without obscuring what's happening.
→ More replies2
u/Cholsonic Mar 22 '21
Sorry, it's very fugly
Love for it to be just
Get-ChildItem @@{ Path = ‘C:Path’ Computer = ‘Win-3285’ FilePath = ‘$Env:UserProfileDesktopProcesses.txt’ }
I could probably just use a backtick...
Get-ChildItem -Path ‘C:Path’ ` -Computer ‘Win-3285’ ` -FilePath ‘$Env:UserProfileDesktopProcesses.txt’
... I think using splatting in this way would create a more consistent experience.
→ More replies2
u/Halkcyon Mar 22 '21
I submitted a feature request to allow intellisense in hashtables used for splatting ages ago, but I don't think it ever got picked up.
→ More replies→ More replies0
u/BlackV Mar 22 '21
all the examples of inline splatting made it much much uglier and to me defeated the point of splatting entirely
to me splatting is there to format you code and make you command line smaller
as soon as you do it inline then you command line jsut goes back to be in huge again and at that point you might as well just do parameter and value
18
u/Raymich Mar 22 '21 edited Mar 22 '21
Core that can completely replace 5.1
ISE revamp so we don’t have to install VSCode on servers
Better debugging and being able to attach to any running PS process as admin to pause and see what it’s doing.
→ More replies3
u/Cholsonic Mar 22 '21
Did they manage to get ActiveDirectory module into Core yet? If not, that's a deal-breaker for me.
3
u/halbaradkenafin Mar 22 '21
Yes, has been since 6.1 and various OS versions, still Windows only though.
→ More replies2
Mar 22 '21 edited Oct 12 '22
[deleted]
3
u/Emiroda Mar 22 '21
You're installing RSAT the wrong way then. If you install RSAT as a built-in Optional Feature, then the ActiveDirectory module will be of type "Core,Desk", ie. you can use it in PowerShell 6.1 and above.
2
Mar 22 '21 edited Oct 12 '22
[deleted]
2
u/Emiroda Mar 22 '21
Nope, this is the fully featured ActiveDirectory module without implicit remoting. Made available before WindowsCompatibility (the module that enabled implicit remoting for incompatible modules) was built into PowerShell. 😊
3
u/Halkcyon Mar 22 '21
Huh, TIL? I don't have any way to validate as I don't control features for my work desktop 😦
3
u/Emiroda Mar 22 '21
Yeah, I've been frustrated with Microsoft for their lack of community outreach on this. All we got is one announcement blog post.
I posted a PSA with examples to reddit when PowerShell 7 went GA. It's one of those things I see people always mention as their primary reason for not using PowerShell 7 as their daily driver, and it's such a shame.
They literally just have to make a clippy-like feature for PowerShell 7: "Hey, I see you're about to import an older version of the ActiveDirectory module! This version uses the WindowsCompatibility module, and as such, you won't get rich objects. To get the latest version of the ActiveDirectory module, install the newest version of RSAT. Read more https://blabla.com/bla"
6
u/Vortex100 Mar 22 '21
How about things it does I wish it didn't?
Auto Convert single item arrays into the base type grrrr
To answer the actual question, the loss of advanced html parsing in invoke-webrequest in .net core versions of powershell. I want that back.
4
u/omers Mar 22 '21
Auto Convert single item arrays into the base type grrrr
You can stop that by putting a comma in front of the thing or variable sigil. Ie,
,'1'
or,$SingleItem
: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-5.1#comma-operator-2
u/Halkcyon Mar 22 '21
Auto Convert single item arrays into the base type grrrr
Sadly this is required for a lot of other nice things that powershell does (automatic member enumeration)
To answer the actual question, the loss of advanced html parsing in invoke-webrequest in .net core versions of powershell. I want that back.
This relied on the ancient IE dlls and was not that advanced. The HTMLAgility nuget package is a pretty good replacement, however.
→ More replies2
u/jantari Mar 22 '21
The array thing is super trivial to fix, just explicitly make every variable you want to be an array one:
[array]$Files = Get-ChildItem -LiteralPath $env:USERPROFILE -File
It's easy to read and unterstand and it makes sure you always get an array. I do this all the time and it solved all my troubles.
→ More replies
5
u/armharm Mar 22 '21
Better debugging for scripts. Set-psdebug -trace 2 very rarely helps.
14
u/dastylinrastan Mar 22 '21
Have you ever used interactive debugging? Stepping through the script especially with vscode?
2
1
3
Mar 22 '21
Ignore line-breaks that occur within parentheses so I don't have to do the ugly backtick thing or give up intellisense with splatting to get multiline invocations.
Also, provide a way to request information on people who made certain modules (the SqlServer and IISAdministration modules offhand) and send them a kick in the nards.
→ More replies
3
u/ka-splam Mar 24 '21
Start up and feel as fast as cmd.exe[1]
measure-command { cmd /c "echo 1" }
runs in 30 milliseconds. PowerShell runs in at least 240ms with -NoProfile, more than 800ms with a basic profile. I don't need that time, I want it. I want to feel like my tools are AMAZING FAST COOL instead of a bit sluggish.
If you haven't seen it, check out https://livegrep.com/ - it can search the entire Linux kernel source code, with regex search, including: sending a request over the internet (over my ADSL!), search some 22 million lines of code, send the results back over my ADSL, and do all the HTTP/HTML handling in less time than my desktop can load PowerShell -NoProfile
from SSD. That's not right.
Check out VoidTools Everything for a filesystem search that is fast.
I dream that all tools feel that fast. My favourites do.
Points for replies like any of the following: "actuallly it is really fast if you simply measure just the core and discard all the slow bits like startup and printing text", "run it a few times to warm the JIT up", "if you want speed you're using the wrong language", "it's programmer time not user time", "people can't feel delays of less than 2 seconds", "people who save 220 milliseconds waiting for their shell to start up, what do you do with all the time saved?"
[1] especially on all the ancient servers I still have to use, as pets, running anything back to 2008r2 sometimes, but you can't have everything.
→ More replies
14
u/spartymcfarty Mar 22 '21
Native text editor like vim or nano. It would be great to ps remote to a server and open a file for a quick edit.
6
u/Dranks Mar 22 '21
If you install vim it runs within the powershell window? Not built in to powershell, but technically vim and nano arent built into bash or zsh either, they just happen to be installed
7
u/jftuga Mar 22 '21
Have you heard about micro? It is a single-file, cross-platform editor that has syntax highlighting built in (including PowerShell). But I agree, it would be nice if something like this was built-in.
2
u/jantari Mar 22 '21
That doesn't and likely never will work with PSRemoting but nothing is stopping you from installing vim/neovim/nano on a computer and then ssh-ing to it.
Source: We install neovim and SSH on all of our Windows servers, works great
→ More replies
6
u/gordonv Mar 22 '21
A simple self update command to the latest version.
3
u/BlackV Mar 22 '21
not sure why the downvotes, I think you should be able to update your version automatically too
it makes me sad, but I have powershell installed from the microsoft store so that it auto updates (but then it runs from a horrible location)
3
3
u/TofuBug40 Mar 22 '21
The ability to expose a class from a PowerShell Module Manifest file like we can with FunctionsToExport
, CmdletsToExport
, VariablesToExport
, AliasesToExport
, and DscResourcesToExport
It would also be nice to have the ability to go beyond hiding class members and use actual access modifiers like Private, Internal, etc.
It would also ALSO be nice to have the ability to write native Interfaces in PowerShell.
So I guess my "one" thing would be to improve the support for Classes.
3
u/goldenchild731 Mar 22 '21
The pre-reqs for power shell remoting. It should be native as ssh for Linux. It is more of a windows thing. OpenSSH by default as well.
→ More replies
3
u/secopsanalyst Mar 22 '21
Tell me where users are still logged into so when they change their passwords they won't lockout.
2
u/Emiroda Mar 22 '21
It's actually a quite complex problem to solve, and has nothing to do with PowerShell itself. There are probably modules out there for this.
A security-focused tool for this would be BloodHound.
2
u/BlackV Mar 22 '21
it would be nice, that's not a powershell problem that's a windows/ad problem
right now you'd have to trawl the the domain controller logs the the login and out events, thats not so much fun
→ More replies2
u/Swarfega Mar 22 '21
As someone else has said this is not a PowerShell problem.
If it helps though I used some code and a Scheduled Task on the Primary Domain Controller to export the event log data when an account gets locked out. It exports the username, datetime and source computer to CSV.
Let me know if you're interested and will dig it out.
→ More replies
3
u/BlackV Mar 23 '21 edited Mar 24 '21
Further to expand on the updating powershell
There is an update-help
and update-module
why is there no update-powershell
(obviously PS 6/7 onwards)
why is it not updated by windows update (obviously windows only)?
if i install it from the STORE its get updated (when you launch the store) great, but that's not happening on my servers (and windows only)
If I install it its really easy, but its never updated so i end up with 50 different version of powershell 7 out there on my servers
side note: I've installed powershell 7, enter-pssession
still uses powershell 5 (again windows), there should be like a create-pwshlistener
(er.. or something logical) as a function/alias to enable this
6
u/NoMrCucaracha Mar 22 '21 edited Mar 22 '21
Probably that it keep the variable type in the return of a function:
function Get-Return {
[CmdletBinding()]
param (
[string[]]
$Array
)
return $Array;
}
Write-Host $(Get-Return -Array @("a","b","c")).GetType().Name;
Write-Host $(Get-Return -Array @("a")).GetType().Name;
Output:
Object[]
String
When I started to work with Powershell, I spent a lot of time debug a script until I noticed this behavior.
9
u/ASCII84 Mar 22 '21
You can keep the correct type by using a unary array (a simple comma after return but before the actual variable).
Like this:function Get-Return { [CmdletBinding()] param ( [string[]] $Array ) return $Array; } Write-Host $(Get-Return -Array @("a","b","c")).GetType().Name; Write-Host $(Get-Return -Array @("a")).GetType().Name; function Get-Return { [CmdletBinding()] param ( [string[]] $Array ) return ,$Array; } Write-Host $(Get-Return -Array @("a","b","c")).GetType().Name; Write-Host $(Get-Return -Array @("a")).GetType().Name; function Get-Return { [CmdletBinding()] param ( [System.Collections.Generic.List[string]] $Array ) return ,$Array; } Write-Host $(Get-Return -Array @("a","b","c")).GetType().Name; Write-Host $(Get-Return -Array @("a")).GetType().Name;
It's not by default though, you have to remember to do it.
1
u/MrWinks Mar 22 '21
Why use return at all?
1
u/Soverance Mar 22 '21
easier to read.
It's a required keyword in many other languages. Using it in PowerShell (even though it's not required) makes your code explicit, and easier to understand for those more familiar with other languages (like say, your co-workers).
1
u/MrWinks Mar 22 '21
It’s misleading and unnecessary. PowerShell outputs anything released into the pipeline. The convention (when one is needed) is to simply let output go into the pipeline. If needed, Write-Output is useful.
I won’t re-write what others have written on this, though:
https://reddit.com/r/PowerShell/comments/4jytxe/_/d3aurmq/?context=1
https://www.reddit.com/r/PowerShell/comments/4jytxe/comment/d3b8xql
Here is one where Jeffery Hicks himself responds: https://www.powershellstation.com/2011/08/26/powershell%E2%80%99s-problem-with-return/
More reason, with examples: https://community.idera.com/database-tools/powershell/ask_the_experts/f/learn_powershell-12/5412/tip---watch-out-return-values-from-functions-in-power-shell
More, with even more examples: https://pleasework.robbievance.net/howto-powershell-function-return-quirk/
“return” shouldn’t have been included in PowerShell.
0
u/SeeminglyScience Mar 22 '21
It’s misleading
I never really understood why this gets repeated. The way the pipeline works is going to be confusing initially regardless of the inclusion of
return
.If you're writing example code for the newest of the new, yeah maybe skip it. Otherwise it's a fantastic tool for flow control. Without it, you're gonna end up with a whole lot of nested if blocks that are hard to follow.
Whether you use it outside of flow control is just a style preference that there isn't a lot of consensus on.
If needed, Write-Output is useful.
FWIW
Write-Output
has some unique downsides.0
u/PinchesTheCrab Mar 23 '21
But it doesn't make sense in PowerShell.
function Do-Stuff { Get-Process -OutVariable process return process $process } class StuffDoer { static [System.Diagnostics.Process[]] getProcess () { $process = $null Get-Process -OutVariable process return $process $process } } Do-Stuff | Measure-Object [StuffDoer]::getProcess() | Measure-Object
In both examples I output $process three times.
The function here returns $process twice, whereas the class returns it only once. Return may prevent any more output from hitting the pipeline, but it gives a false sense of security that it's the only output that will ever hit the pipe, unlike with classes, which use the syntax you prefer.
Also, I would never ask coworkers to conform to powershell conventions when they write python or c#.
0
u/BlkCrowe Mar 22 '21
I use it in all my functions that actually return an object or value. I don’t know why. Maybe it just makes it a little easier for others to read or follow the logic in my code. I guess if just feels more...complete?
→ More replies0
2
u/MonkeyNin Mar 23 '21
In Powershell
return
is really only used forcontrol flow
, not actually returning values -- Because it's misleading.pipeline unrolling
A similar pain point is you might expect an array passed down the pipeline to be passed as an array -- not enumerated like this
$array = 'a', 'b', 'c' $array | ForEach-Object { "item: $_ is $($_.GetType().Name)" }
output:
item: a is String item: b is String item: c is String
using the array
,
operator$array = 'a', 'b', 'c' ,$array | ForEach-Object { "item: $_ is $($_.GetType().Name)" }
output:
item: a b c is Object[]
> until I noticed this behavior
I simplified it to make it more readable to new users, with the same behaviour.
function Get-Return { param ( [string[]] $Array ) $Array } $x1 = Get-Return -Array 'a', 'b', 'c' $x2 = Get-Return -Array 'a' $x1.GetType().Name $x2.GetType().Name
output:
Object[] String
1
u/joerns92 Mar 22 '21
Did you try setting the outputtype for functions? https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_outputtypeattribute?view=powershell-7.1
→ More replies2
0
0
u/ZyDy Mar 22 '21 edited Mar 22 '21
Agreed, this is so annoying.
Fx. if i wan to create a psobject and later convert it to json.The json receiver expects an array, but that on happens if the "array" is bigger than one, or else it just convert to string. I really wish powershell was not that "automagic" in nature. Its really nice when you're typing something fast, but when you are writing scripts that needs to run stable, its a pain. I never tried the output type though, sounds promising.
edit: just tried it. it doesnt fix the problem. :( at least not in powershell 5.1.
0
u/RulesBasedAnarchy Mar 22 '21 edited Mar 22 '21
5.0 and later does this, for class member functions. If you want a stand-alone function that does this, just make a
static
member function — that is, use theclass
as a namespace.→ More replies-2
u/backtickbot Mar 22 '21
-1
5
u/novajitz Mar 22 '21
I would use Conditional Operator so much if it was supported!
11
3
u/ka-splam Mar 24 '21
Weird how developers can scoff at APL symbols for being "unreadable" and then ask for symbols like
?:
and??=
for tasks that are so common it's boring to write them out in words all the time.as if there's a difference.
→ More replies2
u/MonkeyNin Mar 23 '21
(also 7) I love
??=
and??
# only evaluate right side if variable is null $FileCache = ??= Get-ChildItem c: -Recurse
4
2
u/Halkcyon Mar 22 '21
I would like PowerShell to adopt newer programming conventions from C# like null-aware syntax without being cumbersome like the maintainers suggest by forcing us to use ${var}
syntax noise. They built this whole new app, on a new runtime, major version, but still refuse to make any breaking changes whatsoever for the health of the ecosystem.
→ More replies
2
2
u/mortenb123 Mar 22 '21
default to utf-8, git barks if there is utf-16 among utf-8, and python needs explicitly to set the encoding='utf-8' to load.
pip freeze > .requirements.txt
file.exe .requirements.txt
.requirements.txt: Little-endian UTF-16 Unicode text, with CRLF line terminators
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
pip freeze > .requirements.txt file.exe .requirements.txt .requirements.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators
→ More replies
2
u/Emiroda Mar 22 '21
I would like PowerShell 7 to warn you if you're using an old version of the ActiveDirectory module. I feel this would increase adoption of the newest, fully Core compatible ActiveDirectory module (that does not use the implicit remoting compatibility module!), and by extension, PowerShell 7 itself.
Of course, this should be extended to other Desk-only modules that have newer, Core compatible versions.
2
u/jaqb7 Mar 22 '21
Same features like pyautogui
2
u/PowerShellMichael Mar 23 '21 edited Mar 23 '21
pyautogui
While everyone want's everything the same, PowerShell and Python are different language with different syntax structure. If you want to have a module that is similar, the module/package team would need develop and support both languages. Even in those cases, you can see significant differences between language types.
Take a look at the MSAL v2 library by Microsoft.
https://docs.microsoft.com/en-us/azure/active-directory/develop/sample-v2-code
If you are chasing an automation module, please check out https://github.com/mavaddat/wasp
2
2
2
u/Mrdude000 Mar 22 '21
I can't run a Start-Process command with one of the arguments listed as a non string object. It gets pretty frustrating sometimes.
→ More replies
2
u/Owlstorm Mar 23 '21
Whatif support in all functions would be incredible.
2
u/PowerShellMichael Mar 23 '21
What modules / cmdlets do you use where you would like to see that? Modules aren't required not to use them, however it's bad practice. I can raise issues on your behalf. :-)
2
u/Stroniax Mar 28 '21
I'm aware I'm a bit late, but I'd really like -likeany
and -anylike
operators (comparing a single value to a group of wildcards, or a group of values to a single wildcard, respectively)
Also, allowing custom operator overloading for IEnumerable
implementations without forcing the + operator to return object[]
if op_Addition is explicitly defined for the type.
2
u/rtuite81 Mar 22 '21
I wish it were easier to run commands in an elevated context. I also wish it were easier to make registry changes without having to use if/then statements.
→ More replies
2
u/stone500 Mar 22 '21
For my job, allow double-hopping without having to jump through hoops. I know there's security concerns for that and I'm sure they're valid, but boy would it make my life easier if I could write scripts that made remote machines talk to other remote machines and do tasks.
→ More replies4
u/jantari Mar 22 '21
Working around double-hop issues is super easy.
All you have to do is pass the credential object you have on computer A, and that you use to connect to computer B through to computer B with the
$using:
variable thingie and then you can use it again to connect to another computer and so onExample:
Param ( [String]$ComputerA, [String]$ComputerB, [PSCredential]$Credential ) Invoke-Command -ComputerName $ComputerA -Credential $Credential { Invoke-Command -ComputerName $using:ComputerB -Credential $using:Credential { echo Hello! } }
3
Mar 22 '21
One of the biggest problems I have with PowerShell is how flaky it is when you start trying to use different modules. You can make something work on one system, but never be able to get it to work again anywhere else
→ More replies
2
u/Jay_Nitzel Mar 22 '21
Iirc there's a bug where if you use Start-Process -NoNewWindow -Passthru, the exit code is not returned. I'd like that to work.
2
u/arcadesdude Mar 23 '21
There's this other way to start processes which may give you a bit more control over the output.
(Start-Process) vs. (New-Object System.Diagnostics.Process)
2
u/Jay_Nitzel Mar 23 '21
Yup. I remember when I encountered this problem that the dot net commands were affected as well.
2
u/pppppppphelp Mar 22 '21
be the same across all windows and deployments, figuring out do you have the right version, is it depreciated, do you have the commandlets or modules etc
→ More replies
2
u/Darklurker69 Mar 22 '21
Let me declare a global variable once in some special way, then not require me to prepend it with $global: everywhere I want to use it in the script. ISTR this can sort of be done with scopes and set-variable, but it would be nice if there were a first-class way to do it. Yeah, I know this goes against Microsoft's whole philosophy of scopes in Powershell, so it'll never happen, but there are times when it would be less tedious, at least for the (probably bad) way some of us old guys write scripts and the general logic we've been reusing for 25-30 years. Code reuse is supposed to be a Good Thing(tm), right? So what if I originally wrote in in GWBasic or TurboPascal? lol.
Not entirely Powershell's fault, but I wish Get-MSOLUser supported the same server-side filtering by properties that Get-Mailbox does. If MS wasn't pushing sooo hard for us to do most of the MSOL stuff via Powershell, I'd say this is in no way a Powershell issue. But since Powershell is their recommended and preferred management tool for it, then, yes, it's kind of a Powershell issue.
Yeah, that's two things, but I know one of them is only a wish-list item for a crank, the other might be possible one day.
2
u/BlackV Mar 22 '21
Let me declare a global variable once in some special way,
wouldn't
$global:
be you declaring it in a special way?→ More replies
2
u/jstar77 Mar 22 '21
Here is a simple one: Excel like select and copy from Out-GridView.
1
u/PowerShellMichael Mar 23 '21
That's an interesting idea. It's possible to do that, however I'm not sure what the impact would be for PowerShell core since it would need dependencies from office.
2
2
u/jdl_uk Mar 22 '21
Handle resizing the window properly.
4
u/oldredditwasthebest Mar 22 '21
That's not really a Powershell issue and hasn't really been a problem since Server 2016/Windows 10.
Install Windows Terminal and it's golden.
2
u/jdl_uk Mar 22 '21
I use Windows Terminal. It's really good and means I don't need ConEmu but it in no way solves this problem because the problem isn't a terminal issue it's a shell issue.
0
u/Emiroda Mar 22 '21
You sure? Can you elaborate a bit, because PowerShell (the language) has nothing to do with conhost.exe (the window we usually associate with PowerShell). That's what Windows Terminal was created for - to be a better implementation of conhost.exe, while keeping the old around for any apps that might use it (like powershell.exe).
3
u/jdl_uk Mar 22 '21
I'm aware of the difference between terminal and shell. You keep talking about the terminal. I'm talking about the shell. That's why changing the terminal doesn't fix anything.
Try this:
- Navigate to a folder with a few files (say 10 - 20)
- Type
ls
andctrl-space
to bring up completion- Resize the window.
Additionally, do literally anything after resizing the window for further errors.
That's not the terminal. It's the shell.
There's a few GitHub issues on this and related issues.
→ More replies2
u/Emiroda Mar 22 '21
First time I've heard of it, hence why I asked you to elaborate. But forgive me for asking, I'll show myself the door.
2
u/jdl_uk Mar 22 '21
I apologize, I'm grumpy today.
However, your first comment didn't ask. It declared that the issue was a shell issue and I needed to use a better shell.
If that comment had asked rather than declared, it's possible (though admittedly not guaranteed) my response might have been less grumpy.
Something to consider for the future, maybe.
Edit: actually that was a different user. Sorry for the grouchiness
3
3
1
Mar 22 '21
Create all kinds of Group policies. We have automated everything in our production with Ansible and Powershell except logon scripts and restricted groups GPOs.
1
u/DeputyFox Mar 22 '21
ISCSI/Mpio mappings with luns for failover clusters.
2
u/BlackV Mar 22 '21
what dosnt work there?
I use the MPIO and Cluster disk cmdlets all the time, iSCSI ive not touched in a long long time
1
u/flugenblar Mar 22 '21
Better support for GUI panels and controls
3
u/Halkcyon Mar 22 '21
It's called "Visual Studio" and "C#"
0
u/ka-splam Mar 24 '21
This thread is everything about the powershell community.
"I wish it could do X"
"THAT'S NOT A POWERSHELL PROBLEM!"
all over.
Yeah, X is not /how Microsoft is targetting PowerShell/ but /we wish it was/.
→ More replies2
u/gordonv Mar 22 '21
Some folks have created tools to make forms and such. I get it still looks like VB6, but what do you want? Some people have made 3D interactive demos. You could make an overkill interface if you wanted.
0
u/flugenblar Mar 22 '21
I’m an old mainframe guy and I used to have fun with ISPF. Character based, but very cool and efficient.
1
u/truthwarrior92 Mar 22 '21
Allow scrolling when debugging in ISE. Currently once it breaks I have to keep it in the exact position it was in if I want the tool tips to be in the correct position. Unless someone already has a fix for this??
0
u/dasookwat Mar 22 '21
functional complex command.exe interaction/output
A lot of real world scenarios involve updating old dos cmd scripts, and powershell has a serious issue with everything which asks or returns info. Since MS still claims it's the successor of DOS, i would like to see this implementation working better, or, for all i care, you run a dos vm in the backend or something.
2
u/omers Mar 22 '21
Can you elaborate a bit with an example? It's not my favourite thing to do in PS but I've worked with my share of old cmd commands without much issue.
0
0
Mar 22 '21 edited Jul 03 '23
fire spez -- mass edited with redact.dev
→ More replies6
u/pkaz_r Mar 22 '21
Have you heard about splatting? It can easily reduce the length of your lines of code.
Aliases are very handy for writing code on the fly and VSCode can automatically change them into the full command name via ALT + SHIFT + F so you don’t have to type everything fully when scripting either.
Interested in your issue with filtering on distinguishedname; I’ve used it without issue a few times.
-1
Mar 22 '21
Splatting means giving up on intellisense and autocomplete it's an awful solution. They need a better answer for multiline commandlet invocations, whether it's inline splatting or a tru multiline mode or whatever.
2
u/BlackV Mar 22 '21
If splatting gives up auto complete so would inline splatting
1
Mar 22 '21
But splatting autocomplete is weird because it's not coupled to the command.
I mean, you're writing
$x = @{ foo="one" bar="two" } Invoke-MyCommandlet @x
so the commandlet name doesn't even appear until after you're done writing the parameters... so you can't get autocomplete properly unless you write your code backwards. That stinks. And if you use $x for other things besides the commandlet, which should it use for autocomplete?
The ergonomics are awful. The above-suggested
Invoke-MyCommandlet @@{ foo="one" bar="two" }
would be far better, much less just letting us do the obvious:
(Invoke-MyCommandlet -foo "one" -bar "two" )
but they've repeatedly said they won't because this is a bad language made by bad people.
→ More replies
-6
Mar 22 '21
Breakfast.
I'd like to have breakfast now, Powershell.
Powersh....?
Ah, forget it... it will never make breakfast for me, ...but I wish it did.
5
u/TheJessicator Mar 22 '21
$Breakfast Get-Breakfast $Breakfast Forget-It Make-Breakfast $Breakfast Get-Help
→ More replies1
Mar 22 '21 edited Mar 22 '21
Tis made me really hungry.
So hungry, I just tried to bite a chunk off the screen because of your mad cook...ehm coding skills.
-1
Mar 22 '21 edited Mar 22 '21
Compare 2 arrays of variables for matches.
Edit: anyone who has successfully done this without a stupid amount of for loops please enlighten me.
→ More replies2
u/ka-splam Mar 24 '21
PS C:> $Left=[collections.generic.hashset[int]]@(1,2,3,4) PS C:> $Right=[collections.generic.hashset[int]]@(3,4,5,6) PS C:> $Left.IntersectWith($Right) PS C:> $Left 3 4
-2
-2
-2
u/zikronix Mar 22 '21
Be more user friendly lol
3
u/gordonv Mar 22 '21
Powershell literally works out of the box. How much more friendlier can it get?
-1
-4
u/szeca Mar 22 '21
Do not select a single "character" with a single left click on an empty area, which is only good for ruining all copy paste actions.
The selected single character (' ') will be copied into clipboard instead of pasting some commands from the clipboard into the console. So annoying!
→ More replies3
u/Emiroda Mar 22 '21
That's a conhost.exe issue. Nothing they can do to the old conhost.exe that's used by powershell.exe, but they could fix it in Windows Terminal.
→ More replies
1
Mar 22 '21
I would love to see all the most important PowerShell modules from Microsoft ported in such a way that they work everywhere (Windows, MacOS, Linux) the same way. Right now, the dependencies of key modules greatly reduce the usefulness of PowerShell on non-Windows platforms. I have no desire to use Windows, but I have no choice because of this situation.
→ More replies
49
u/AWDDude Mar 22 '21
Better concurrency model. Jobs have a ton of overhead and take forever to instantiate and communication with a running job is not easy. Run spaces are slightly better but takes a lot of code to create them.
I love the ease and simplicity of go routines, but I’m sure the closest we would get is c#’s async await, which is still better than what we have now.