PowerShell

PowerShell is not very discussed on Sup Forums for some reason, although it has it's merits in the Windows World

Do you use it?
What is your opinion on it?
Any cool scripts that you can share?

>Windows World
/thread

it sucks
microsoft should have made it in 1995 when NT 4.0 came out when people wanted it. Fuck powershell and fuck Microsoft.

i guess its actually really nice for developers or admins but to me, a consumer, its just another one of those weird Post-Vista replacement programs ment to bring cohesion to the wild native windows ecosystem.


Maybe i've just spent too much time with linux, and the KISS + pseudo-UNIX philosophies, but windows is a fucking mess and a real pain to deal with when you just want to find out why its SUDDENLY slowing down or freezing when nothing on your end has changed.

It has a mind of its own and it delve into that you need tons of programs. I imagine programs like powershell are ment to somehow make it easier, but overall its just nigger rigging

foreach ($i in 1..$args[0])
{
$fizzarray = @($i,"fizz","buzz","fizzbuzz")
$o = 0
if ($i % 3 -eq 0) {$o += 1}
if ($i % 5 -eq 0) {$o += 2}
write-host $fizzarray[$o]
}


Here's a fizzbuzz script I wrote :^)

but I gave up on powershell because I have adhd and can't focus

Virtually irrelevant with the advent of WSL.

>Do you use it?
Every day
>What is your opinion on it?
Beautiful language
>Any cool scripts that you can share?
Nah

>2017
>cli

Just kill yourself.

does anyone know of a good book to learn powershell?

>not cli
>2017
t. normie babby

t. retard

But it runs on Linux...

PowerShell in a month of lunches would be your best bet.

Better than bash
Objects > Text

>Unstrutured text in a structured system
>In the year of our Lord 2011+6

the windows users here are gamers. they dont need command lines.

PowerShell is a clusterfuck for end users. I use it every day, to bypass AntiVirus solutions and carry out my duties as a pentester. It's really scary how much lateral movement, persistence, and evasion you can do with PS. AV doesn't pick it up, so its a quick way to get DC creds.

Better than bash, zsh.
ISE is a dream.

Come at me.

Makes managing active directory and exchange a fuck load quicker

>AV doesn't pick it up
Depends on the AV, Defender will on Windows 10 and newer.
Also if you're trying to get around anyone competent they'll have PS logging setup to track everything.
But for now it's pretty much a free lunch in most places.

I use PowerShell professionally for quite a few years now. It's all because of this one fuck in my company who keeps pushing every single stupid Microsoft product which nobody fucking ever uses. Shit always boils down to "but it's integrated with office hurrdurr", managers eat it up and the office plugins/extensions are always abandoned so nobody uses it. The fucking TFS build/release workflow is the most cancer-inducing shit. Microsoft never responding to bug-reports unless you're a billion-employee company. Fucking updates removing important features every once in a while and adding retarded fucking eye candy similar to desktop stripper. But to get back to the point - I fucking hate PowerShell. I hate everything about it. There is no reason for it to exist or to replace the old command prompt. The syntax rules gave me terminal leukaemia. The inconsistent usage of cmdlets murdered my daughter. The fact that you can find "TODO: add documentation" comments on MSDN. The fucking comparison operators. The fucking occasional case-(in-)sensitivity of random tokens. Fucking lists. Fucking string concatenation and interpolation. The ISE sucks big dick. Debugging is a nightmare. No remote execution except for RDP (full GUI) and/or turning on WinRM and then using goddamn Invoke-Command where half of the calls execute on your local machine. The piss-drinking syntax for using .NET types and namespaces. For fuck's sake it created a new "level" of DLL hell: you are able to load different fucking versions of the same DLL and then everything using either one of them stops working always throwing an exception saying it couldn't find the type/class in the assembly. Oh and you cannot unload the DLLs - you gotta start a new session. The fact that scripts continue executing if a cmdlet threw an exception. The fact that if you run an external program the last exit code is stored in a global variable so there's no way to do parallel execution of external programs. It's just bad.

What features got removed in an update?

I don't think you know how to use PowerShell.

>. No remote execution except for RDP (full GUI) and/or turning on WinRM and then using goddamn Invoke-Command where half of the calls execute on your local machine.

Most cmdlets can execute with cum, you should use that.

>For fuck's sake it created a new "level" of DLL hell: you are able to load different fucking versions of the same DLL and then everything using either one of them stops working always throwing an exception saying it couldn't find the type/class in the assembly.

V5 has the using key word now to let you specify different versions now. Still can't remove them after but you really should be importing them in a module anyway.

>The ISE sucks big dick. Debugging is a nightmare.
VS Code has addresses this part, it eases the trouble of using the built-in debugging tools.

>The fact that scripts continue executing if a cmdlet threw an exception.

Most cmdlets don't throw terminating exceptions, you need to set the ErrorAction.

>The fact that if you run an external program the last exit code is stored in a global variable so there's no way to do parallel execution of external programs.

However your starting the programs is wrong, look into Start-Process with the -PassThru parameter.

Really powerful but holy fuck is it a nightmare to write in

Holy shit, this is tenfold worst than bash. Disgusting.
for i in {1..100} ; do
out=""
(( $i % 3 == 0 )) && out="Fizz"
(( $i % 5 == 0 )) && out="${out}Buzz"
echo ${out:-$i}
done

My first scripting language was Bash but my first time playing with objects is in PS.
I use it at work for Systems automation. As of now, 100% of our user onboarding/offboarding is a powershell workflow and we have a handul of autorecovery routines written in powershell that are fired off by solarwinds.

The only thing I don't like is that some features are tied to the powershell version and some are tied to the version of the operating system. I'm never completely certain a script will work across the entire enterprise because of it.

Also if you're YOLOing in prod, there's a lot of ways to be dangerous with powershell. All it takes is fucking up a pipeline to start your very own rm -rf disaster. Powershell uses your own level of accesses, but just because I want a helpdesk operator to be able to disable an AD account doesn't mean I want them to be able to run "get-aduser | set-aduser -enabled $false"

>Do you use it?
No.
>What is your opinion on it?
It's stupid. Most servers run Linux with Bash built in, so it's useless for work.
>Any cool scripts that you can share?
No.

For fizz buzz, sure but it's much nicer for system administration.

For example getting all files over 10mb in PS is very straight forward.
ls | where Length -gt 10MB
In bash you deal with textual data sort you need to hack and slash the output. Not bad but you loose gaurantees on what you get back.

>piping ls

In PS ls is an alias for get-childitem.

The language is fucking terrible, so I never looked too much further into it. Why couldn't they adopt a proper modern programming language since they made it so recently? They could have made it run even with python ffs.

>Microsoft never responding to bug-reports unless you're a billion-employee company.

to be fair they probably can't fix it because they already have like a shitload of other bugs to fix. But ya, M$ insider favoring si fucking cancer.

M$ needs to nuke their shit from orbit or refactor their whole fucking software stack.

I fucking hate it. I manage an IIS serv and I needed to write an archiving script and it was the most awkward "thing". I ended up caving and just writing it in ruby.

python isn't not made there, that's why.

I'm surprised they got the ansible cucks to develop powershell garbage just for winusers.

They started it back in 2002 .... with the first public beta for xp back in 2005

It's great for windows malware.

you forgot pajeets

A blue command prompt that nobody asked for. Absolutely useless.

>blue
hmmmM?

Console 2 is the shit

This is untrue. PoSh has a use case, which is in managing Windows and Windows servers, that WSL cannot accomplish in its current state. It's a scripting language for those who want to script less painfully than in cmd: a middleware scripting layer between COM-enabled applications and the sane world.

>Linux fags will never experience the glory of powershell.

You don't deserve it anyway.

>You have to have an admin enable scripts before running any userscript
>Even then you still need to confirm running one
>Still no elevation support
>Doesn't look or work like any existing language

I hate Microsoft. I fucking hate them.

As a minor consolation, vbscript can do most of what powershell does for non-network usages and it's a lot less confusing. Otherwise there's Autoit which can compile standalones.

woah dude did you just literally list ALL the files in the current directory? fucking amazing

People have been asking for a scripting language that was more powerful than command prompt.

it's a great language. some features are missing. Easy debugging with the ISE, Try-Catch for errors is pretty cool, WMI .NET give you barely any limitations. Good AD module. Sadly ACL is still clunky to use and so on, but made life easier as sysadmin.

Used it for the first time yesterday to automate unzipping or archivea and deleting leftover files.
Took me a while to get it to work but it's actually really easy and nice

>not knowing how to customize the CMD
awwwwwwwww

I got called to managers office one time because they got the report that I was installing shit at the servers.

>ok show me the evidence
This screenshot, you installed an alternate command...
>excuse me, I had the font size changed because I was in remote desktop from a cellphone attending this midnight call from a smartphone
>surely the person that reported this to you forgot to tell that we needed to roll back a change he made in the middle of the night of the payroll day
>I attended the case as soon as possible but I had no access to my work computer and I would not connect to our systems from an untrusted computer
grrrrrrr you can go user

true story.gif