January 18, 2011 3:45 PM
Posted by: Richard Siddaway
PowerShell v2,
User Group
When: Tuesday, Feb 8, 2011 7:30 PM (GMT)
Where: Live Meeting
*~*~*~*~*~*~*~*~*~*
An introductory session showing how to get the most out of PowerShell’s utility cmdlets. These are
Compare-Object
ForEach-Object
Group-Object
Measure-Object
New-Object
Select-Object
Sort-Object
Tee-Object
Where-Object
Suitable for beginners and the odd possible surprise for experts
Notes
Richard Siddaway has invited you to attend an online meeting using Live Meeting.
Join the meeting.
Audio Information
Computer Audio
To use computer audio, you need speakers and microphone, or a headset.
First Time Users:
To save time before the meeting, check your system to make sure it is ready to use Microsoft Office Live Meeting.
Troubleshooting
Unable to join the meeting? Follow these steps:
- Copy this address and paste it into your web browser:
https://www.livemeeting.com/cc/usergroups/join
- Copy and paste the required information:
Meeting ID: 5D2B4R
Entry Code: h_>SF*D9q
Location: https://www.livemeeting.com/cc/usergroups
If you still cannot enter the meeting, contact support
Notice
Microsoft Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.
January 16, 2011 1:09 PM
Posted by: Richard Siddaway
PowerShell,
User GroupPlease note the following dates for your diaries:
8 February – PowerShell utility cmdlets
An introductory session showing how to get the most out of PowerShell’s utility cmdlets. These are
Compare-Object
ForEach-Object
Group-Object
Measure-Object
New-Object
Select-Object
Sort-Object
Tee-Object
Where-Object
22 March – Regular Expressions
PowerShell MVP Tome Tanasovski will present on Regular Expressions. This is an opportunity to learn more about an under used part of PowerShell.
Tome is a Windows engineer for a market-leading global financial services firm in New York City. He is a recipient of the PowerShell MVP award, the founder and leader of the New York City PowerShell User group, a blogger, and a regular contributor to Microsoft’s Windows PowerShell forum. He has been featured four times on Hey Scripting Guy, and he is currently working on the PowerShell Bible, which is due out in 2011 from Wiley.
http://powertoe.wordpress.com
http://twitter.com/toenuff
12 April – PowerShell and COM
PowerShell has great support for WMI and .NET but don’t forget that many applications still only have a COM interface. This session will also cover accessing the Windows Scripting Host functionality.
All sessions start at 7.30pm UK time unless stated otherwise. (Note that UK goes to daylight saving time on 20 March)
January 13, 2011 1:57 PM
Posted by: Richard Siddaway
PowerShell v2,
Registry
One point I didn’t cover in my series on working with the registry was how to get the type of a registry value.
|
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018
|
$regtype = DATA { ConvertFrom-StringData -StringData @’ 1 = REG_SZ 2 = REG_EXPAND_SZ 3 = REG_BINARY 4 = REG_DWORD 7 = REG_MULTI_SZ ‘@ } $HKLM = 2147483650 $key = "SOFTWARE\Microsoft\Windows\CurrentVersion" $computer="." $reg = [wmiclass]"\\$computer\root\default:StdRegprov" $data = $reg.EnumValues($HKLM, $key) $x = ($data.snames).Length for ($i=0; $i -le $x; $i++){"{0,-30} {1}" -f $($data.snames[$i]), $regtype["$($data.types[$i])"] }
|
The easiest way is to use the EnumValues() method. This returns integer values for the type.
Define a hash table that contains the integer and its meaning. Define the hive and the key. Create an instance of StdRegProv and invoke the EnumValues method. Loop through the returned values and use a formatted string to display the results
January 13, 2011 12:49 PM
Posted by: Richard Siddaway
Books,
PowerShell v2,
WMIChapter 4 has been released for PowerShell and WMI. It is available through the Manning Early Access Program (MEAP) at http://www.manning.com/siddaway2/
The first 4 chapters cover:
- Solving Administrative Challenges
- Using PowerShell
- WMI in Depth
- Best Practices
Chapters 5 and 6 covering System Configuration Information and Disk Systems respectively are in the pipeline. I’m currently working on chapter 7 on the registry. Chapters 5 onwards include lots of lovely scripts.
January 11, 2011 3:12 PM
Posted by: Richard Siddaway
PowerShell v2,
User GroupEd Wilson – Microsoft Scripting Guy – gave a superb presentation to the UK PowerShell group tonight. If you missed it the recording will be available for the next 365 days
You have been invited you to view a Microsoft Office Live Meeting recording.
View Recording
Recording Details
Subject: Windows PowerShell Best Practice
Recording URL: https://www.livemeeting.com/cc/usergroups/view
Recording ID: PPS9QQ
Attendee Key: M5<|wdK;8
I would recommend this to everyone interested in using PowerShell. You need to listen to the end if you want to find out Ed’s number one, must do, best practice
January 9, 2011 7:40 AM
Posted by: Richard Siddaway
Books,
PowerShell v2There are a lot of PowerShell books on the market. Whether you are just starting with PowerShell, want to dig further into the subject or need some help with using PowerShell with a particular product it is often helpful to find a book on the subject instead of learning from scratch.
NOTE: This is my own personal view of the books. There are other books available. Some I have looked at and won’t recommend others I have not yet looked at. I am also restricting my list to English language books
These are the books I would recommend. I use many of these on a regular basis.
| Title |
Author |
Publisher |
ISBN |
| Learn Windows PowerShell in a Month of Lunches |
Don Jones |
Manning |
978161790213 |
| Windows PowerShell Scripting Guide |
Ed Wilson |
Microsoft Press |
9780735622791 |
Windows PowerShell Cookbook
First Edition
Second Edition |
Lee Holmes |
O’Reilly |
9780596528492
9780596801502 |
| Windows PowerShell 2.0 Best Practices |
Ed Wilson |
Microsoft Press |
9780735626461 |
| PowerShell in Practice |
Richard Siddaway |
Manning |
9781935182009 |
| PowerShell and WMI |
Richard Siddaway |
Manning |
9781617290114 |
| Managing Active Directory with Windows PowerShell |
Jeffery Hicks |
Sapien Press |
0977659798 |
| Managing VMware Infrastructure with Windows PowerShell |
Hal Rottenberg |
Sapien Press |
0982131402 |
PowerShell in Action
First Edition
Second Edition |
Bruce Payette |
Manning |
1932394-90-7
9781935182139 |
Comments:
Learn Windows PowerShell in a Month of Lunches by Don Jones. This is still being written at the time of posting. It is a beginners guide to PowerShell. If you haven’t used PowerShell before this is the place to start.
Windows PowerShell Scripting Guide by Ed Wilson. This takes over where Don’s book stops. It supplies a good introduction to automating basic windows admin tasks with PowerShell
Windows PowerShell Cookbook by Lee Holmes. Now in its second edition it supplies a lot of scripts for using PowerShell. This book is PowerShell orientated and doesn’t cover using Exchange, AD etc. The techniques are useful for using with some of the more advanced or technology specific books.
Windows PowerShell 2.0 Best Practices by Ed Wilson. Builds on his Scripting Guide and contains good information on designing and testing scripts. Even if you don’t agree with all of the ideas they are worth reading to make you think about how you want to perform these tasks in your organisation.
PowerShell in Practice I wrote as a “PowerShell for Administrators” book. Contains lots of examples for working with AD, WMI, DNS, IIS, Exchange, SQL Server and Hyper-V. I wrote it but I still refer to it for syntax & ideas.
PowerShell and WMI is still being written. WMI is a really powerful technology but the lack of documentation and the difficulty of using it in the past has meant admins have been reluctant to use it. This book is designed to shine a light on to WMI, make it accessible and provide many ready to use scripts
Managing AD with Windows PowerShell by Jeffery Hicks. A second edition is in preparation. This overlaps with PowerShell in Practice to some extent but if you just want to automate AD then start here.
Managing VMware Infrastructure with Windows PowerShell by Hal Rottenberg. If you are using VMware you need this. Admin becomes a lot easier.
PowerShell in Action by Bruce Payette. This is the book for the in depth details on the PowerShell language. If you want to know how and why PowerShell works the way it does this is the book for you. Be aware that it is an advanced text and is NOT recommended for PowerShell newcomers.
This is my view of the PowerShell book world. No doubt other people will have different views. If you think I’ve missed a book that should be one this list please let me know but I will only recommend books I have read.
January 2, 2011 5:23 AM
Posted by: Richard Siddaway
PowerShell v2Some thoughts on highly effective PowerShell users. They:
- Get the job done. This isn’t as obvious as it seems. PowerShell is an automation tool. Use it. Don’t agonise over the last bit of polishing for your script. Get it into use and gain the benefits. It can always be modified another day. Remember the 80:20 rule. You’ll get 80% of the benefits with 20% of the effort.
- Don’t forget interactive use of cmdlets. An awful lot of useful work can be performed by using cmdlets. This is especially true if working with Exchange or remote systems (don’t forget WMI)
- Use the pipeline. PowerShell is about the pipeline. Use the inbuilt power as much as you can but don’t forget habit 1
- Use scripts, functions and modules. This is all about reuse. Don’t re-write every time. Modules are great for organising your scripts and loading as required.
- Use comments You will see this one in every scripting guide. You need to be able to understand what you meant to do with the script. This is especially important if you are sharing your scripts
- Write PowerShell not VBScript A lot of PowerShell examples are VBScript that has been translated directly into PowerShell. Don’t bring the VBScript habits into PowerShell – but don’t forget habit 1
- Are part of the PowerShell community. By this I mean that they use the PowerShell community to find out how to do things and where possible they contribute back to the community.
January 1, 2011 5:19 AM
Posted by: Richard Siddaway
PowerShell v2This is something I fell foul of recently. I had a calculation that produced a non integer answer e.g. 2.1
I needed to get the integer part of the number. Without really thinking about it I did this
PS> [int]2.1
2
I was then a bit surprised when I didn’t always get the right answer. Still not thinking I was scratching my head until I realised that using [int] rounds to the nearest integer.
PS> for ($i=2.1; $i -le 3.0; $i+=0.1){"$i $([int]$i)"}
2.1 2
2.2 2
2.3 2
2.4 2
2.5 3
2.6 3
2.7 3
2.8 3
2.9 3
This is no good because I need to round down.
The .NET Math class has a Truncate method that works however.
PS> for ($i=2.1; $i -le 3.0; $i+=0.1){"$i $([math]::Truncate($i))"}
2.1 2
2.2 2
2.3 2
2.4 2
2.5 2
2.6 2
2.7 2
2.8 2
2.9 2
And the moral of the story is that you need to think about what you are doing and not assume that things work the way you think they do
January 1, 2011 5:01 AM
Posted by: Richard Siddaway
PowerShellHappy New Year to everyone
At the start of a New Year it is time to take stock and decide what you want to achieve in the next 12 months. My PowerShell list is fairly straight forward:
- complete PowerShell and WMI
- produce a good programme for the user group
- good guest speakers
- start a series of sessions for people new to PowerShell
- add more modules to the PowerShell Admin Modules (PSAM) on codeplex
- blog more than last year
We’ll see how well I’ve kept them this time next year