Return to Level1Techs.com

Almost 3 Million people using PowerShell on Linux

Whaaaaaaaat? That’s crazy.

@sgtawesomesauce @injinj @reavessm @MichaelLindman Spawned a new conversation so we didn’t get too off topic :grin: SGTAwesome, you were saying, if asked to use PowerShell that’d be a resume generating event? :grin: :grin:

@Eden @Ruffalo @thro @anon36666293 cuz they use PowerShell? :thinking:

In my old sysadmin gig, I would have paid for this. We were issued Macbook Pros and had to RDP into Windows boxes to launch PowerShell scripts. This would have solved so many problems. Honestly impressed with the number.

Noteworthy

PowerShell 6 is also known as “PowerShell Core”, which strips away a lot of the core modules of PowerShell 5, such as AD management and other things. You will have to PSRemote into a box that has PowerShell 5 to utilize or import those modules. At least, that’s how it was a few months ago. Things might have changed.

5 Likes

I have powershell installed on both my Mac and my Linux box, but it’s pretty useless on those platforms until they enable powershell remoting to be properly cross-platform.

I use powershell a bit in my Windows admin work (get-adcomputer | restart-computer -force) :smiley: j/k … mostly.

I’ve written a couple of powershell modules for internal use - bulk user account generation, user termination, etc.

I’m been drilling it into my minion (PFY, me BOFH) that if he needs to do something more than 5-10 times in a row then he should be looking to see how difficult it is to script it. Work smarter, not harder, etc.

1 Like

I’m still unsure as to why I would use powershell for… anything really. I can’t tell it to do unix commands, can I?

1 Like

Powershell can do stuff like:

  • script administration of vSphere
  • script administration of active directory
  • remotely bulk-manage Windows PCs via command line

It takes some getting your head around (you need to get your head space out of piping text around and more into SQL style select statements and piping objects), but Powershell is MUCH more powerful than the traditional unix command line. When it works.

1 Like

LOL. Great blog series

Yeah, when it first released it was pretty lackluster for me as well. I had it on all three.

The automation is key, that’s what it was built for. We had guys start small that are now contributing actively to the projects via PowerShell and C#.

Interfacing with MS SQL Server (DBA Tools)
Bulk interfacing with Active Directory or Exchange
Automation
Infrastructure as Code

Windows never claimed to be Unix. Technically, neither is GNU (GNU’s Not Unix).

If you don’t have a use case for PowerShell, that’s fine. But there is an entire ecosystem of incredible developers, systems engineers, database admins, and architects that use PowerShell every day to contribute to DevOps culture.

StackExchange uses PowerShell and C# as their primary stack.

PowerShell works with Objects instead of text, like the Bash/Linux shells.

1 Like

I’m genuinely keen to see what becomes of powershell.

It’s been in development for almost/about 15 years at this point (started as monad shell on Windows 2003 IIRC).

It would be cool if it gained traction on other platforms because much as it confuses me and much as ps-remoting often breaks or times out, and slow as it is… the power at your fingertips is truly amazing. Having that as a cross-platform thing would be neat.

As they say, even a broken clock is right twice a day. Microsoft does a lot of stuff I don’t like, but occasionally they put something out that is genuinely neat. Powershell is one of those things, I think. Active Directory is another.

edit:
Powershell can be extended to interface to pretty much anything via additional modules. You can also poke at most things in windows which don’t have a module via interfacing directly with WMI. Sure you can do that with VBscript, but Powershell its often a 1 liner…

e.g.

get-wmiobject win32_bios

for example

1 Like

Yeah, we use powershell on linux all the time to manage windows hosts. That’s pretty much it.

1 Like

Ok, I took the PS on Linux challenge. First step, vi command line editing…

PS > Install-Module PSReadLine
PS > Import-Module PSReadLine
PS > Set-PSReadlineOption -EditMode vi
3 Likes

ls works in PowerShell…

1 Like

Wow. I can use ls. Yippee.

1 Like

You seem to be ignoring other peoples comments and not bothering with basic research.

We get it, you don’t use PowerShell.

There are literally millions of others that have a use case for it.

1 Like

ls was huge for me. Also there is tab completion.

1 Like

Actuay I was going to look into the automation stuff. All I know for automation is apple’s automator and uh I don’t think thats the most apt comparison.

One basic q though. Can you set up aliases in PS?

yes, it is: Set-Alias [alias] [path to program]

[edit]
or that is how i have used it, there might be better ways though

[edit 2]
you should look into the powershell $profile for a place to put the config you want

2 Likes

I’m used to writing scripts for aliases its kind of annoying.

I can manipulate structured data in PS, for example:

PS > $y = echo "[1, 2, 3]" | ConvertFrom-Json                                                                                                                                                                        
PS > $y[0]                                                                                                                                                                                                           
1
PS > $y[1] += 100
PS > $y                                                                                                                                                                                                           
1
102
3

I want to store this data in redis, like stackoverflow does. I can’t find a module that will allow me to do this, is there such a module?

If there is not a module that does what I want, I would need to write one. I’d guess that means a visual studio environment under Linux?

1 Like

vscode is available for Linux and has a redis module to add redis command support;

There are also better PosH modules for VSCode and you can also run a PoSH or BASH console in VScode to execute code segments in.

2 Likes

That is interesting. It looks like the vscode-redis pulls in node js. I’m curious of the performance difference between marshalling PoSH objects through node vs through .Net. At what point does it make a big enough difference where a .Net module makes sense?

Has anyone compared the perf of say Python scripts vs PoSH scripts? These seem to be the two major devops toolbox options. With Python, I could link in C code to for data intensive activities. With PoSH, it appears that .Net is where I would have to go, and I haven’t found a way of doing that under LInux.

1 Like

Wouldn’t .net core give you what you need on Linux? I know it’s missing some stuff compared to traditional .net on Windows though.

Yes, apparently MS does have the core libraries ported… PoSH dev on OSX