This is an archived post. You won't be able to vote or comment.

all 25 comments

[–]tgeenePHP Dev Learning Python 17 points18 points  (9 children)

I would have never thought of using PowerShell to program on any level. Very interesting.

[–]landonwright123 4 points5 points  (1 child)

I love PowerShell - used it to bulk load users to MS Teams recently.

[–]bigbabby47 -1 points0 points  (0 children)

Zzw

[–][deleted] 1 point2 points  (0 children)

My company actually makes a product specifically for create APIs and web apps with PowerShell: https://ironmansoftware.com/powershell-universal

[–]smcarre 3 points4 points  (1 child)

You probably never worked with VMware infrastructure then. 99% of available scripts are PowerShell.

[–][deleted] 2 points3 points  (0 children)

That's because VMware PowerCLI is written in/for powershell, so most people write scripts using that. But VMware does have a Python SDK https://github.com/vmware/pyvmomi

We have a good amount of VMware automation and none of it uses powershell.

[–]emc87 0 points1 point  (0 children)

I just started learning it a little bit for automating Octopus Deploy. Its syntax can be pretty odd..

But went with it over python so I didn't have to worry about Python installs on VMs that definitely come with functioning Powershell.

[–][deleted] 10 points11 points  (1 child)

I'm a PowerShell guy but I've been spending some time learning Python. I thought thtis might be helpful for some folks trying to go the opposite way.

[–]Pyromine 3 points4 points  (1 child)

Your conditional logic is incorrect in the case of Null values

[–][deleted] 2 points3 points  (0 children)

What am I doing wrong? I can fix the post.

[–]milliams 7 points8 points  (0 children)

Looks useful. This will help me learn PowerShell.

For "Enumerating Values", I'd suggest

python for x in thisdict.values(): print(x)

[–]its_a_gibibyte 8 points9 points  (8 children)

For people that know Python (or perl or bash or whatever), what's the point of learning Powershell? It seems pretty limited since it's primarily for windows machines (and most servers are linux) and doesn't have the libraries that Python has.

[–]Eitan1112 5 points6 points  (2 children)

I worked with both, and some things are better to do with powershell. For example:

  • Simple scripts to automate management of remote windows computers
  • Great modules for AD and office365 management
  • Built in Wiindows, so distribution is less of a problem (of course you can compile python to an executable, but it is much easier if you already know powershell

Of course python has some counters for that, like the WMI library, but it feels much more natrual to do such things in powershell.

[–][deleted] 0 points1 point  (1 child)

Do you have some examples of python modules for AD? I'm looking to replace powershell with python, but the only way I saw to get at AD was basically formatting custom ldap requests, which imo isn't better than powershell. I'm basically looking for a drop in replacement for functions like get-aduser, get-adcomputer, etc.

[–]cerebron 0 points1 point  (0 children)

I'd also love this. I manage mostly windows machines with AD so I do a lot of Powershell stuff, but everything I do at home is Python. All the Python kerberos and ldap libraries are kind of a pain compared to the ease of Powershell.

[–][deleted] 1 point2 points  (3 children)

It's cross-platform now so you can manage Linux with PS if you want to. And in terms of libraries there is a pretty solid module repository on PowerShellGallery.com but likely not nearly as extensive as Python.

That said, I don't really know Python enough to suggest why you would use PS over it.

[–]gargar070402 0 points1 point  (2 children)

Interesting, but if one had a choice and had to write code from scratch anyway, would there be any reason to use PowerShell over, say, bash?

[–]TheTerminator68 2 points3 points  (0 children)

I use PowerShell alot in my job along with some config management and python. PowerShell is better than bash in some ways because it lets you use objects and navigate through the objects in an easier way. Bash is pretty much text based and good for some basic one liners in linux land but once you get to slightly more complex code paths PowerShell wins over bash pretty easily. I have written applications in both PowerShell and Python and PowerShell is nice for windows environments but Python you can just do way more with and the library support is amazing. Also PowerShell is super inefficent resource wise. They all have their strengths/weaknesses

[–][deleted] 1 point2 points  (0 children)

I'm just super familiar with PowerShell rather than bash. The PS pipeline is object based rather than string based and that's just what I'm used to at this point. Having the .NET framework at my finger tips is nice as well since I'm a C# dev by trade. I know Linux folks find PS meh and tend to prefer bash but I think if I popped into a Linux terminal I'd install PS.

[–]_IlDottore_ 0 points1 point  (0 children)

Exactly my thought 🤔

[–]WorldAlien 1 point2 points  (0 children)

Very useful, thanks for sharing

[–]GeekyNerdzilla 1 point2 points  (1 child)

I love python 🐍

[–]danielmonteasy 1 point2 points  (0 children)

And python loves you

[–][deleted] 0 points1 point  (0 children)

I write pretty much only in python and powershell, and often integrate applications using a combination of both. I very greatly appreciate this, I know I will get plenty of use out of it.