Skip Navigation

Is there any reason to use Powershell on Linux?

I have used bash, zsh, ksh, and now powershell. I am by no means an expert on UNIX shells. I could get all my work done on any one of these. My main shell is Zsh with some oh-my-zsh plugins because I'm lazy. What can you do in powershell that you can't do in any other shell? Also, does the shell you use even matter? Sorry if this is a dumb question.

29 comments
  • The best reason to use PowerShell on Linux is if you are working in a mixed/complex environment, or think that you might pursue a career in enterprise IT and want to learn about working in mixed environments. With PowerShell you can remotely manage Windows systems without having to RDP into them, you can just open a remote PowerShell session and issue commands to the target machine.

    I've used this to do things like loop through a list of endpoint hostnames, open a session to each one and get an inventory of installed applications on that system and also flag any hosts that didn't respond to the remote session and then spit out all the results in a .CSV, fully automatic. Run monthly or as needed.

    You can also interact with the Windows registry via .NET classes, which PowerShell understands natively because it is .NET. You can do this locally and remotely, which looks something like this:
    \ [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, "<hostname>").OpenSubKey('<registry key path>').GetValue('<key value name>')
    \ So if you wanted to check if a particular registry key was set on a group of Windows machines, you could write a PowerShell script that could just do that for you with no interaction. It's also possible to modify registry keys remotely with .SetValue('<key value name>'), so if you need to do that in bulk it's very convenient.

    Basically PowerShell can take previously arduous and time-consuming Windows sysadmin tasks and make them scriptable. And not just Windows, anything and everything .NET can be easily managed via PowerShell.

  • (don’t forget fish, nushell, ion, pdksh, mksh, rc, es, and however many others)

    as for picking one, really comes down to personal comfort

    if you’re developing shell scripts, then two options to keep in mind:

    • POSIX shell (ex. ash, dash) – focusing on portability
    • bash – most commonly currently installed shell so access to a broader audience
    • I forgot about fish. I've read it isn't POSIX compliant. It's my distro's default shell but I really didn't feel like using it so I installed zsh instead. I mostly use Zsh because it's a lot easier to find unformation about it online. I don't currently write shell scripts but I may wish to in the not-so distant future. Is Zsh a good choice for that? Thank you!

      • You can whatever shell you like and still write scripts in bash, as bash is a part of (practically) every system. When you write a .sh script the first line will indicate which shell to use, so you can run bash scripts from any shell so long as you have it installed.

  • I got pretty late into the Linux world after having been a Windows admin for years. I got so used to powershell that I still can't really put together a decent bash script without going over previous scripts or going online for help, but I can still smash out a powershell script easily.

    Use what your most comfortable with, but you'll need bash at some point if you manage Linux servers.

29 comments