Learning PowerShell – Using PowerShell Community Extensions

Tags

ps The PowerShell Community Extensions are a set of additional cmdlets, providers, functions and scripts which the community asked for and have been written for us to use and take advantage of.

Once you download PSCX you’ll want to add this module to something called your PowerShell Module path, this is the place you’d normally put your PowerShell Modules so that you can import them for using in your scripts. To check what your PowerShell Module path is from within PowerShell type:-

$env:PSModulePath

Add PSCX to your $env:PSModulePath so you can import it and use it anytime you start using PowerShell, to add PSCX type the following:-

$env:PSModulePath = $env:PSModulePath + “;C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\;”

the last part should be where you chose to install PSCX.

Ok so no we have this added to our PowerShell Module path lets see if we can start using it.

To check what PowerShell modules are already imported type:-

Get-Module

The screen shot below shows me which modules have been imported:-

get-module

To add PSCX you need to import the module, so lets do that by typing:-

Import-Module PSCX

And that’s it we can call any of the PSCX cmdlets from our scripts, the list of which are extensive and include:-

Write-Zip
Format-XML
Get-XML
UnBlock-File

and many more

Hopefully this is enough to whet your appetite.

Learn PowerShell – Piping

Tags

Piping in PowerShell is awesomesauce and best explained by some examples, but firstly a quick explanation of piping, lets say we want to get a list of files from the c:\windows folder on your machine, order them by the last modified date and select the first 50 files and output the list to a text file in the current folder, simple requirements and here it is:-

Set-Location c:\windows
Get-ChildItem | Sort-Object LastWriteTime -Descending | Select-Object -First 50| Out-File files.txt

  • Set-Location is the cmdlet which is roughly the equivalent to the cd command found in a command prompt.
  • Get-ChiLdItem is the cmdlet which is roughly the equivalent to the dir command found in a command prompt, but you can use it with objects, lists and so on.
  • Sort-Object is the cmdlet to sort obviously and can be used against your objects, lists and much more.
  • Select-Object tis the cmdlet to select a number of objects (files, records, results), you can use this with -first, -last, -skip and much more
  • Out-File will is the cmdlet to simply write output to a file.

Obviously a very simple example but you take A pass the results to B, B then does work on it, passes it to C and you got the idea. This is a how piping works and can yield the data your looking for quickly and in very little code indeed.

PowerShell Blog Posts

Learn Powershell – ExecutionPolicy

Tags

psCheck what the script execution policy is currently set to on your system:-

Get-ExecutionPolicy

The options are AllSigned, ByPass, Default, Remote Signed, Restricted or undefined

You can read about each of these by typing in the following command:-

Get-Help Set-ExecutionPolicy -online

This will load the online help for this command, if your ever needing help with PowerShell then you can search for help like so, Get-Help *services*, this will show you what commandLet’s are available for working with Services, i.e. starting them stopping them and so on.

I set the execution policy to RemoteSigned so that I can run my own PowerShell scripts but ones I download from the internet wont run unless I change the setting, so that my system is secure from any unwanted side effects from other peoples scripts.

PowerShell Blog Posts

PowerShell useful Tools

Tags

ps

As part of my blog post series on learning PowerShell I thought it might be a good time to list the tools I have came across and give them a shout out as I reckon the list of tools have been very helpful in learning some good practices when writing PowerShell scripts.

Lets get to the list:-

  • PowerShell ISE Steroids – this is a great add-on for PowerShell ISE, its not free but you get 10 days to check it out and I recommend you do.
  • PowerShell Script Browser Script Browser for Windows PowerShell ISE enables you to search for script samples in the TechNet Script Center, invaluable tool in my opinion for looking at example scripts
  • Power GUI PowerShell Editor with a few nice extras

I will add more as I come across them ;)

Learn PowerShell – Getting Started

Tags

ps

To Start PowerShell, click Start, and type in PowerShell, choose Windows PowerShell ISE and run this as an Administrator (right click).

Tip:-  To check which version of PowerShell you have type $PSVersionTable, this will show a table of results and your looking for the top one which is the PSVersion, if this is 2.0 then you really should update before we go any further. At work I have been using PowerShell 3.0 and now 4.0 is out.

To update to version 3.0 the download link is PowerShell 3
To update to version 4.0 the download link is PowerShell 4

Tip:- PowerShell has in-built help which is really great, make sure its up to date by typing in Update-Help

PowerShell Blog Posts

Adventures into Powershell

Tags

psOver the last couple of months I have been working with PowerShell on a daily basis, I had initially looked at PowerShell at home a little bit and thought yeah its fairly cool and left it at that, if you haven’t looked at PowerShell and want to learn some quick tips for getting started then stick around.

At work I was tasked with doing a small project using PowerShell and I can now report that I think PowerShell is pretty awesome, I have even found myself thinking you could do that using PowerShell.

The learning curve for PowerShell is not that high and if you put a little bit of effort into learning the basics it starts to become pretty easy to do most things.

This will be the first post covering a number of topics within PowerShell and I will cover what I have been learning as we go.

NDC London – Day Three

Tags

Miguel%20Castro
Day 3 – Knocking it out the park, with KnockoutJS by Miguel A. Castro (@miguelcastro67)
The first talk I attended on day 3 was Knocking it out the park, with KnockoutJS by Miguel A. Castro

Miguel’s talk walked you through KnockoutJS, what you would use it for and showed you several demos as he went building upon each one as he covered more and more on KnockoutJS. Miguel is a very good speaker, his talk was very well delivered and flowed excellently – his demos were useful and were very well explained.

Damian%20Edwards
Day 3 – ASP.NET SignalR 2.0 and beyond by Damien Edwards and David Fowler(@DamianEdwards)
The second talk on day 3 I attended was ASP.NET SignalR 2.0 and beyond by Damien Edwards and David Fowler

Damien Edwards and David Fowler introduced everyone to a new major version of SignalR and what has been added/updated.
There is tighter integration with OWIN, .NET 4.5 server dependency, full support for self-hosting, new clients, massively improved cross-domain/CORS support, API usability improvements, easier hub unit testing and better error handling. We’ll cover all this and give a sneak peak and new features in upcoming releases in this information packed session. Very informative talk which I enjoyed.

Mads%20Torgersen%20324
Day 3 – The future of C# by Mads Torgersen (blogs.msdn.com/b/madst/)
The third talk I attended on Day 3 was The future of C# by Mads Torgersen

Mads talked about how the past several years, the Microsoft C# team has been focused on rebuilding the compilers and editing experiences as part of Project Roslyn. He also introduced us to potential new language features are on the designers’ minds. Features discussed included read only auto properties, multiple return values, null checking, structural typing is ‘on the radar’.

Jessica%20Kerr3%20256
Day 3 – Object Oriented Design in the Wild by Jessica Kerr (@jessitron)
The fourth talk I attended on Day 3 was Object Oriented Design in the Wild by Jessica Kerr

Jessica talked about the reasoning behind object-oriented design principles, and how we find their application in the wider world. This session will challenge you to go beyond rules and standards and ask, when is clean code worth your time? Go beyond OO and come back with new insight. Interesting talk all about OO in different languages.

David%20Fowler1%20324
Day 3 – ASP.NET SignalR 2.0 and beyond by Damien Edwards and David Fowler(@davidfowl)
The fifth talk on day 3 I attended was Using ASP.NET SignalR in Anger by Damien Edwards and David Fowler

Damien Edwards and David Fowler What showed off the best patterns for using SignalR in a real application – both guys walked through code samples of how to go about doing such a thing and discussed a number of topics including when best to use SignalR as opposed to other technologies.

NDC London 2013 – Day Two

Scott%20Guthrie%20London
Day 2 – Build Real World Cloud Apps using Windows Azure Part I and II by Scott Guthrie (@scottgu)
The first and second talks I attended on day 2 were Build Real World Cloud Apps using Windows Azure Part I and II by Scott Guthrie

Scott gave a two part covering the following:-

•Automating Everything
•Source Control Best Practices
•Continuous Integration/Delivery
•Enterprise Identity and SSO Integration
•Web Development Best Practices
•Data Storage Options
•Data Storage Partitioning Approaches
•Using unstructured Blob storage
•Designing to survive failures
•Monitoring and Diagnostics
•Transient Fault Handling
•Distributed Caching
•Using the Queue Centric Work Pattern

Was a really great insight into the capabilities of Azure and how as developers we can use these features for building applications right now.

Jeremy%20D%20Miller
Day 2 – Automating Testing in the big, bad Enterprise World by Jeremy D. Miller (@jeremydmiller)
The third talk on day 2 I attended was Automating Testing in the big, bad Enterprise World by Jeremy D. Miller

Jeremy discussed how his team has a strategy for faster and more productive manual testing and troubleshooting when using RavenDB and just how easy it is to use RavenDB for in memory creation and deletion of the entire database for unit testing purposes. He talked about how automated testing efforts frequently fail because the tests are too time-consuming to author, too brittle when the underlying application changes and showed examples of how he tried to make this process easier.

Robert%20C%20Martin
Day 2 – Functional Programming: What? Why? When? by Robert C. Martin (Uncle Bob) (@unclebobmartin)
The fourth talk I attended on Day 2 was Functional Programming: What? Why? When? by Robert C. Martin (Uncle Bob)

Uncle Bob talked about a number of things from the past to the future and was as always very entertaining but also thought provoking – this guys a legend and listening to him talking was a pleasure.

Burke%20Holland%20324
Day 2 – AngularJS Directives And The Computer Science Of JavaScript by Burke Holland (@burkeholland)
The fifth talk I attended on Day 2 was AngularJS Directives And The Computer Science Of JavaScript by Burke Holland

Burke gave us a run through of Directives in AngularJS, what they are and how they work showing code samples.

TimGThomas%20324
Day 2 – Test Your Javascript…with the Help of D&D by Tim G. Thomas (@timgthomas)
The fifth talk I attended on Day 2 was Test Your Javascript…with the Help of D&D by Tim G. Thomas

Tim talked about how testing JavaScript—the modern Web’s ubiquitous development language—can be a daunting task. In his session he introduced us to some methods to do just that…but with a Dungeons and Dragons twist.

NDC London 2013 – Day 1

Tags

Dan%20NorthKeyNote with Dan North – JackStones: the Journey to Mastery (@tastapod)

Dan’s talk was about how you go about becoming a Master at something and was very insightful, Dan talked about a lot of cool stuff and talked about learning how you learn to become at whatever it is your trying to master.

Dan described some of the many facets of craftsmanship and talks about trying to figure out exactly what the craft is that we programmers do.

Venkat%20SubramaniamDay 1 – Cleaning up Code Smell by Venkat Subramaniam (@venkat_s)
The first talk I attended was Cleaning Up Code Smell by Venkat Subramaniam – his talk was covering ways to identify code smell, how to clean them up. We will also discuss proactive ways to avoid smells in the first place.

Venkat is a superb speaker and covered a lot within 1 hour, his talk was well delivered and he cracked a few good jokes along the way, very entertaining talk.

Mark%20Rendle%20324Day 1 – Simple.Web 101 by Mark Rendle (@markrendle)
The second talk I attended was Simple.Web 101 by Mark Rendle – his talk was covering his .NET/Mono web framework Simple.Web.

Simple.Web applies the SOLID design principles to web application development, and makes building web applications an experience of the deepest joy. Simple.Web makes keeping your code clean, and building real REST/HATEOAS APIs.

Mark talked about why he wrote Simple.Web, showed us some of the code and then showed off some examples of how to use Simple.Web in an application

Scott%20Guthrie%20London
Day 1 – Introduction to Windows Azure Part I and II by Scott Guthrie (@scottgu)
The third and fourth talks I attended was Introduction to Windows Azure Part I by Scott Guthrie

Scott gave a two part talk which provided an overview of Windows Azure – including a number of demos, and how you can take advantage of it to build great applications in the cloud. His talk was a superb introduction to what Azure is and how you can leverage Windows Azure to build great applications. As always his talks were very informative, every question was given a detailed answer and was a really great way to learn about what Azure can do.

Michele%20Bustamante%20324
Day 1 – Windows Azure Essentials by Michele Leroux Bustamante (@michelebusta)
The fifth talk I attended was Windows Azure Essentials by Michele Leroux Bustamante

Michele’s session was aimed at getting you up to speed on the essential features developers should be aware of, and how to apply them in practical scenarios on all aspects of Windows Azure.

Michele showed off the differences between web sites and cloud services, as well as other practical tips for building Azure apps such as storing content, sending email, working with queues and choosing the right technology, and collecting important metrics for visibility into application health.

Dan%20North
Day 1 – Why Agile doesn’t scale – and what you can do about it by Dan North (@tastapod)
The sixth and final talk I attended was Why Agile doesn’t scale – and what you can do about it by Dan North

Dan talked about shared guiding principles, a clear vision and a common understanding enable what he called contextual consistency. He also talked about delivery assurance, governance and portfolio management in the enterprise.

Was a very interesting talk and a nice end to the day.

NDC London 2013 – big thank you to all

Tags

ndc_london_Ben_front2

NDC London was last week and I have to say I enjoyed every second of it.

This was my first conference and I will hopefully be back, the content each day was fantastic, the choice of content varied enormously and the people who run it, sponsor it and attend it deserve huge credit.

Having the chance to talk to developers from all over the world working on all sorts of projects and that was probably my favourite part of the conference, hugely grateful to my company for giving me this opportunity.

I will cover the 3 days I attended in a separate blog post but for now I just wanted to take the time to thank everyone involved, I managed to chat with of attendees and met some folks I chat to on twitter which was pretty cool.

Big thanks to the guys at Redgate who I managed to chat to and get a demo of some of their tools which I haven’t had the chance to try out as yet, was really nice to put a face to some of them.

I now have my blogging mojo back and have lots of content to go off and learn about – the next blog post coming soon will cover each of the 3 days I spent learning new technologies.

Thanks once more to all involved – hopefully see you again.

Follow

Get every new post delivered to your Inbox.

Join 28 other followers