PowerShell for developers [closed]
I understand why IT administrators like to use PowerShell, but is there a reason why developers should use it daily?
Are there any scripts you run in PowerShell quite often to make your life easier?
For everything you were doing via command scripts/batches, you can now use PowerShell and most of the time it will be much easier because of the cmdlets provided.
For example, if you're a SharePoint developer, you'll really like/should use it for your daily development (to replace stsadm, etc.).
Next to that, you can use PowerShell to download podcasts and videos (downloading MIX11 videos as we speak), converting videos, parsing CSV files, ...
Use it in every scenario where you need some quick scripting. I'd take a quick PowerShell script to parse a CSV file over writing a full .NET application to do the same.
I wrote a blog post about some areas I find useful: How PowerShell can help programmers. You might find some tips there.
I'm not a system administrator and more of a developer and usually have at least one PowerShell session open here. Reasons are:
- Handy as a calculator
- You can play around with .NET objects without firing up Visual Studio or write a C# class (I do that too, but having a REPL makes things so much easier ...)
- I golf in it.
- Some automation tasks. I still use
cmd
frequently, but PowerShell too at times. - Tiny functions and scripts that come in handy. For example, I do my own time tracking and have a little function that tells me how long I still have to work today.
I know very little of PowerShell. But I usually prefer it over cmd.exe simply because I can copy with right-click-drag and paste with single right-click, instead of going through the popup menu.
Sometimes it's the little things..
Here are some of the uses I have found:
- Great for validating XPath syntax and general XML "handling", especially in the ISE (integrated shell environment), where you can validate objects in memory without having to sift through a bunch of logs
- Database updating: Lately, I have been using PowerShell to pull the latest (or some specific changeset) on my database projects from TFS, compile via MSBuild, and deploy both the updated schema and any additional data scripts to my development environment. I have several database instances that require this effort, so I have been using a single PowerShell script as a batch manager that dumps the other scripts into a series of jobs that handles this asynchronously. It's like getting an extra 2 hours to my day and who couldn't use that?
- Along with use #1, I have a series of RDL files (basically XML format) that have certain fields that must be aligned with entries in a database table. One PowerShell script I have can actually validate if an entry is in the RDL and not in the database table and either write the SQL script necessary to deploy the change or can write the change straight into the table. A regular report writer might be able to do something like this, if they had to, but probably could only validate 3-4 reports a day. My script can do all 70+ reports in a few minutes or so, and back-up the changes made to a CSV file so I can track the differences.
Now, considering how much of what I just mentioned is database-centric, you would think I was a "database developer." You would be right, but PowerShell keeps this stuff off my plate and lets me code for my real job.
If it's a simple script, it's less code to do the job. I found you can access a web service API with the URL and a few lines of code.
精彩评论