3 ms·
I believe the best way to learn powershell is by using it as your shell, everyday, for real-world tasks, particularly in your job. Start small, with ls, cp and
by YeGoblynQueenne 10y ago
I believe the best way to learn powershell is by using it as your shell, everyday, for real-world tasks, particularly in your job.
Start small, with ls, cp and cat, and don't force the pace. psh is a shell first and foremost- a shell with a very nice language, but a shell all the same. So get comfortable using it as a shell.
First thing is to create your $PROFILE. Google for an example and see if you can edit it to suit you. Then get chocolatey, PSCX (psh community extensions), posh-git and vim, and get used to doing most of your work on the command line (like you'd do with bash, on Linux). See what tasks you can automate by writing a few short scripts- very simple things at first, like copying and renaming files, setting up directory structures and so on, then progress to processing xml and setting up scheduled tasks, and sending email, setting up credentials etc. After a few months you'll find that you can wean yourself of windows GUIs for most of your everyday tasks and probably all of your not-so-everyday ones.
psh being a command-line tool, it's far easier to learn it like that, than trying to learn the language first. You can learn the basics of the syntax allright, but there's a bazillion commandlets that you will never be able to remember, unless you use them in your everyday work, and incorporate in your scripts, and those commandlets are often integral to the use of psh. Basically, you can't separate the language from the use of the shell, so you shouldn't try. Learn them both at the same time.
% % %
Here's my personal example: I learned psh to avoid the long rdp queues in a past workplace.
I guess that company didn't want to shell out for more windows server licenses and so there was a limit to the number of people who could rdp to a server at the same time- just two or three people per server. So there was always a bit of a queue and I often had to wait between a half hour and a couple of hours before I could get a slot. Or someone would go for lunch and forget to log out, and you had to kick them out and it was generally a big drag.
At some point I started using psh as my windows shell, and then I found out about windows remoting [1], which sounded a lot like ssh on Linux- basically, it lets you open a shell on a remote computer. Next time I had a slot on a remote machine, I enabled remoting and suddendly I could do all the work I needed on the command line, while everyone else still had to wait in line for an RDP slot [2]. Needless to say, this made my life and my job a hell of a lot easier, not to say pleasant (I might have had a few smug smiles on my face, at times).
I'll note there was only one thing I couldn't do remotely: running a proprietery installer for the company's platform, that only had a gui and no command-line options. Everything else, including a whole bunch of SQL stuff, I could do it remotely, on psh [3].
All this naturally pushed me to do more psh scripting, as it was easier to run a script than key in a dozen commends on the command-line. So I left that job feeling very comfortable with powershell, and although I didn't quite have to use it that much in any other job since, I still use it as my primary shell at home.
____________________
[1] I think it started with this article, whose title immediately caught my attention:
http://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/ http://www.howtogeek.com/117192/how-to-run-powershell-comman...
[2] Noone else cared to learn powershell. I did ask. They said they didn't want to have to learn a new programming language. To be fair, I never explained my remoting setup to anyone, because they would probably tell me to stop using it (I was just a junior dev at the time). Note also that I never enabled remoting on any of our public-facing servers, just in case there was some vulnerability that could be exploited.
[3] I also used vim and netrw to edit my scripts on the remote server directly, over a UNC path, so I didn't have to re-upload them every time I needed to change them. This was a very Linux-y way to do stuff and really unusual where I worked.
- fencepost 10y agoUnrelated to PowerShell, that sounds like information wasn't making it to the right people if the limit - 2 administrative connections were being used like that for regular terminal services access, or like it would have made sense to split services across more systems if you had multiple people routinely doing simultaneous system changes on single servers. RDS CALs aren't cheap, but they're a one time cost and insignificant compared to the cost of staff sitting around waiting for RDP sessions to free up.
- YeGoblynQueenne 10y agoAye right, there was no reason for all that. But, this was far from the only case where the company could have optimised its processes. For instance, as a junior dev, my work primarily consisted of copying some stuff off a spreadsheet (as in, with Ctrl+C), pasting it into a text file and creating some xml structure around it by hand. That was an extremely time-consuming and error-prone process and it caused all sorts of delays and frustrations, to myself as well as everyone that depended on my work. I spoke up about those inefficiencies very early on, but I was very inexperienced at the time and, to be honest, I had no idea how to properly communicate this sort of thing, so I never got anywhere. I only managed to come across as snotty and get a reputation as a trouble maker. After that I just kept to myself and focused on getting some experience with C# and learning psh and so on, generally learning as much as possible until I felt confident enough to look for a better job- which I took as soon as I found it. Generally, I was really unhappy in that company, but at the same time, exactly because I had to jump through hoops and learn how to automate my work, I taught myself a whole bunch of stuff that were very useful in my next job (where, btw, I had a great mentoring relation with my boss). So it all turned out alright.