PowerShell for Windows Admins


April 23, 2011  5:34 AM

System Stability



Posted by: Richard Siddaway
Security

As admins one of the things we need to be able to prove is the stability and reliability of our systems. With Windows 7 and Windows 2008 R2 we have a way to do this

001
002
003
004
005
006
007
008
009
010
011
012
function get-stabilityindex {
[CmdletBinding()]
param
 (
 
[parameter(ValueFromPipeline=$true,
   ValueFromPipelineByPropertyName=$true)]
 [string]$computer="."
) 
 
Get-WmiObject -Class Win32_ReliabilityStabilityMetrics
 `
 
-ComputerName $computer |
 select @{N="TimeGenerated"; E={$_.ConvertToDatetime($_.TimeGenerated)}},
 
 
SystemStabilityIndex
}

Use the Win32_ReliabilityStabilityMetrics class – see http://msdn.microsoft.com/en-us/library/ee706632(VS.85).aspx for details

The function takes a computer name and returns the date and time a metric was computed and its value.

We’ll follow this up with a look at Win32_Reliability records next time

April 21, 2011  1:52 PM

PowerShell and WMI MEAP update



Posted by: Richard Siddaway
Books, PowerShell, WMI

Chapters 8 and 9 of PowerShell and WMI have been released into the MEAP. They are available from http://www.manning.com/siddaway2/

 

Chapter 8 covers the File system

  • Administer shares
  • Compress or encrypt files
  • Monitor file system events

Chapter 9 covers Services and processes including:

  • service load order
  • discover process owners
  • use WMI events to control processes

The code from the chapters is available for download.

Next up is chapter 10 dealing with printers.

Chapter 11 on Networking is complete and I’m working on the IIS WMI provider (chapter 12) and configuring a new server (chapter 13)

Enjoy


April 13, 2011  12:58 PM

Tuesday’s recording



Posted by: Richard Siddaway
PowerShell v2, User Group

The recording from Tuesdays UG meeting is available.

Richard Siddaway has invited you to view a Microsoft Office Live Meeting recording.
View Recording
Recording Details
Subject: PowerShell and COM objects
Recording URL: https://www.livemeeting.com/cc/usergroups/view
Recording ID: Q4DPJT
Attendee Key: 4~_TzB%6w

The slides and scripts are available from

http://cid-43cfa46a74cf3e96.office.live.com/browse.aspx/PowerShell%20User%20Group/2011%20April

Previous meeting’s recordings are still available:

  • Regular Expressions
  • PowerShell utility cmdlets
  • PowerShell best practice
  • Remoting
  • Registry
  • DNS
  • Events
  • Modules


April 11, 2011  1:08 PM

User Group meeting–tomorrow



Posted by: Richard Siddaway
PowerShell, User Group

Don’t forget the user group meeting tomorrow

http://msmvps.com/blogs/richardsiddaway/archive/2011/04/03/powershell-ug-meeting-april-2011-com-objects.aspx


April 9, 2011  2:29 AM

Scripting Games 2011 commentary ||: top 10 mistakes



Posted by: Richard Siddaway
PowerShell v2

See this excellent for tips on what not to do when writing PowerShell scripts

http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/09/top-ten-mistakes-made-during-week-1-of-the-2011-scripting-games.aspx


April 8, 2011  3:15 PM

Scripting Games 2011 commentary I: Line continuations



Posted by: Richard Siddaway
PowerShell v2

No I’m not going to give you the answers – you’ll just have to wait until the events close.

During (and possibly after) the games I’m going to comment on some of the things I’ve noticed about PowerShell usage.

I want to start with breaking a PowerShell line across multiple lines.  The “one liner” is what many PowerShell users aspire to and we can put together some impressive functionality by stringing together some cmdlets using the pipeline – for instance:

Get-Process | sort CPU -Descending | select -First 6 | Format-Table –AutoSize

 

Now we’ll assume we need to break this so that it fits on shorter lines.  The back tick is the line continuation character so we could end up with this

Get-Process | `
sort CPU -Descending | `
select -First 6 | `
Format-Table –AutoSize

which is actually easier to read.  Another alternative could be this

Get-Process `
| sort CPU -Descending `
| select -First 6 `
| Format-Table –AutoSize

which again is easy to read.  The difference is in the positioning of the back tick before or after the pipe symbol.

 

Both of these options take more effort than required.  All we need to do is this

Get-Process |
sort CPU -Descending |
select -First 6 |
Format-Table –AutoSize

The pipeline symbol works as a line continuation symbol as well.  Save typing and make life easier.

Enjoy!


April 4, 2011  11:34 AM

Scripting Games have started



Posted by: Richard Siddaway
PowerShell

The 2011 Scripting Games have started and this year its a PowerShell only contest.  Head over to http://blogs.technet.com/b/heyscriptingguy/ to get the details of the first events


April 3, 2011  1:54 PM

PowerShell UG meeting–April 2011–COM objects



Posted by: Richard Siddaway
PowerShell, User Group


When: Tuesday, Apr 12, 2011 7:30 PM (BST)


Where: Live Meeting

*~*~*~*~*~*~*~*~*~*

COM and see what we can do with COM objects in PowerShell and why COM is on the need know technology list as far as administrators are concerned.

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:

  1. Copy this address and paste it into your web browser:
    https://www.livemeeting.com/cc/usergroups/join
  2. Copy and paste the required information:
    Meeting ID: Q4DPJT
    Entry Code: 4~_TzB%6w
    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.


April 1, 2011  12:39 PM

PowerShell and VMware book



Posted by: Richard Siddaway
Books, PowerShell v2, Virtualisation

My good friends Jonathan Medd and Alan Renouf (together with a number of co-authors) have just had their book “VMware vSphere PowerCLI Reference: Automating vSphere Administration” published. More details on the book contents and for a chance to win a copy visit

http://www.jonathanmedd.net/2011/03/powercli-book-raffle.html

I’ll doing a full review of the book when I can get my hands on a copy


April 1, 2011  11:59 AM

MVP award 2011



Posted by: Richard Siddaway
PowerShell v2

I received the email this afternoon to tell me my PowerShell MVP award has been renewed for another year. Its a great honour to receive an MVP award and I’d like to thank Microsoft for the award and the PowerShell community for the opportunities that have lead to the award.


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: