Posted on January 2nd, 2007 by Mark Sheppard
PowerShell Community Extensions is a great addition to PowerShell that supplements the out-of-the box set of cmdlets. However, it doesn’t work out-of-the-msi on an x64 platform.
When installing, I opted to use the Shared Profile, but got the following when I tried to run PowerShell:
Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. All rights reserved.Add-PSSnapin : Windows PowerShell snap-in Pscx is not installed on the machine.
At C:\Documents and Settings\Mark\MyDocs\WindowsPowerShell\profile.ps1:38 char:13
+ Add-PSSnapin <<<< Pscx
Transcript started, output file is C:\Documents and Settings\Mark\MyDocs\WindowsPowerShell\Transcripts\20070102.1
43613.7364.txt
[C:\Documents and Settings\Mark]
1> Get-PSSnapinName : Microsoft.PowerShell.Core
PSVersion : 1.0
Description : This Windows PowerShell snap-in contains Windows PowerShell management cmdlets used to manage components
of Windows PowerShell.Name : Microsoft.PowerShell.Host
PSVersion : 1.0
Description : This Windows PowerShell snap-in contains cmdlets used by the Windows PowerShell host.Name : Microsoft.PowerShell.Management
PSVersion : 1.0
Description : This Windows PowerShell snap-in contains management cmdlets used to manage Windows components.
Name : Microsoft.PowerShell.Security
PSVersion : 1.0
Description : This Windows PowerShell snap-in contains cmdlets to manage Windows PowerShell security.
Name : Microsoft.PowerShell.Utility
PSVersion : 1.0
Description : This Windows PowerShell snap-in contains utility Cmdlets used to manipulate data.
[C:\Documents and Settings\Mark]
2> Get-PSSnapin -Registered
Name : PowerGadgets
PSVersion : 1.0
Description : Generates Charts, Gauges and Maps Gadgets from Windows PowerShell data
Well the snap-in isn’t registered on my system, let’s try PowerShell (32bit):
1 Comment »
Filed under: PowerShell
Posted on January 2nd, 2007 by Mark Sheppard
I just needed to know how long it was since my box was last rebooted. Windows Vista has a nice feature where this is now a property of the Performance tab in Task Manager. But alas, there’s no such nice functionality in Windows 2K3. Usually I end up in PerfMon to get the number of seconds the box has been up and then in calculator to convert this into real time.
Enter PowerShell to the rescue:
function GLOBAL:Get-SystemBootupTime([String]$computer=”localhost”) {
  $wmiOsInformation = Get-WmiObject -computer $computer -class Win32_OperatingSystem
  $wmiOsInformation.ConvertToDateTime($wmiOsInformation.LastBootUpTime)
}
function GLOBAL:Get-SystemUptime([String]$computer=”localhost”) {
  $wmiPerfOsSystem = Get-WmiObject -computer $computer -class Win32_PerfFormattedData_PerfOS_System
  $wmiPerfOsSystem.SystemUpTIme
}
# Get System Bootup time
PS C:\> Get-SystemBootupTime
21 December 2006 17:16:02
# Get system uptime in seconds
PS C:\> Get-SystemUptime
1016328
Not bad, I can now see the system uptime in seconds, but I want the result formatted
function GLOBAL:Get-SystemUptimeFormatted([String]$computer=”localhost”) {
  $wmiPerfOsSystem = Get-WmiObject -computer $computer -class Win32_PerfFormattedData_PerfOS_System
[TimeSpan] $systemUptime = New-TimeSpan -seconds $wmiPerfOsSystem.SystemUpTIme
  [String]::Format(”{0:G}”, $systemUptime)
}
PS C:\> Get-SystemUptimeFormatted
11.18:53:16
Job done! As a developer, I tend towards using .NET all over, so I’ve probably missed some rather subtle ways of achieving the formatting with PowerShell.
You can get a lot of other useful information from the WMI classes that could be the focus of other functions:
PS C:\> $computer = “localhost”
PS C:\> $wmiOsInformation = Get-WmiObject -computer $computer -class Win32_OperatingSystem
PS C:\> $wmiOsInformation SystemDirectory : C:\WINDOWS\system32
Organization : My Org
BuildNumber : 3790
RegisteredUser : Me
SerialNumber : xxxxx-xxx-xxxxxxx-xxxxx
Version : 5.2.3790
4 Comments »
Filed under: PowerShell
Posted on September 10th, 2006 by Mark Sheppard
Windows PowerShell is an fantastic tool that will become part of my “used daily†toolkit. I came across Jeffrey Snover’s blog a couple of weeks ago and have really enjoyed reading it. I also recommend the 10 part series on managing Active Directory with powerShell on the /\/\o\/\/ PowerShelled blog, it is very insightful but I felt that I need something more basic to learn the product from the ground up.
Enter Jeffrey’s recently published presentation (from tech-Ed 2006) on PowerShell – this guy makes an hour and 15 minutes of the command line amusing to watch and very informative. I’d prescribe it to all IT Pros as this is going to be your tool of choice in the future.
A couple of things stand out from the presentation. One is that all other scripting mechanism shipped with windows are “feature complete†and two is that in Exchange 2007 (E 12), the MMC admin interface calls PowerShell to perform functions.
The implications of the first one are massive, cscript/wscript/WSH will not be extended in the future and CMD will not get any more features added! PowerShell will be the ONLY scripting tool for admin scripting and will I imagine replace CMD. This is a big shift and if you don’t embrace PowerShell in the Longhorn Server timeframe, you’ll find yourself without any scripting tools and without any community support!
No Comments »
Filed under: PowerShell
Posted on September 10th, 2006 by Mark Sheppard
It’s now been almost 3 months since I purchased and built my monster desktop and I’ve had quite a bit of excitement with it.
To start with, the SATA II RAID 5 controller on the ASUS motherboard wasn’t up to spec. It just about worked until I wanted to perform more than one disk operation, then it just died. For example, say I was copying a large file across the network at 100Mbs and wanted to do something else at the same time, the LUN would grind to a halt and windows would error.
To get round this I configured the system to have a RAID 0 LUN instead, forgetting the reasons why I wanted RAID 5 in the first place.
This worked well for a couple of weeks until S.M.A.R.T. started reporting that one of the disks in the system was bad! To be honest, I was surprised at this because Weston Digital run each and every one of their disks in a lab before selling them, but they it was: Disk is about to fail messages and the Windows log full of errors when the disk system stopped.
This is the exact reason I specified RAID 5 when coming up with the specification for the computer. So I decided to implement RAID 5 whilst the failed hard disk was being RMA’ed with Weston Digital – an excellent and hassle free service by the way, I completed a form on their web site, keyed in my credit card details (insurance only) and WD sent be a new HDD within a couple of day. I then had 30 days to send the defective drive back to them else they’d chare by credit card.
No Comments »
Filed under: 64 bit
Posted on June 15th, 2006 by Mark Sheppard
Historically I’ve upgraded my computer quite often, a pattern that changed when I purchased a my Dell workstation almost 4 years ago. At the time I thought that the 2 x 2.4GHz Xenon processors, its 1GB of RAM and its 2 x 80GB HDD’s would last for a good couple of years. And it has, I’ve upped the HDD’s to 200GB ones, added a DVD burner, upped it to 2GB RAM and gave it a SATA upgrade in the process.
Fast forward to now and I’ve been itching to upgrade to something with a lot more snap in order to meet my requirements, which are as follows:
- Have at least 2 monitors plugged in – If you haven’t tried it yet two monitors rock from a productivity point of view and you get a free workout moving your mouse over bigger distances.
- Run Visual Studio 2005 – My primary role in life is to write code and integrate systems, so this is a given.
- Run at least 2 virtual machines (hosted with MS Virtual Server 2005) all the time – A domain controller and a TFS server.
- Allow for the creation of 2 additional virtual machines at any point in time for evaluation and test purposes – for playing with Longhorn Server and Office 2007 server products.
- Allow general PC usage – Office (using 2007), Internet Explorer, blog reader etc.
- Allow my partner to access and author content in Japanese (‘cause that’s where she’s from)
No Comments »
Filed under: 64 bit
Posted on May 13th, 2005 by Mark Sheppard
Today I scripted a SQL Install Task Sequence for Automated Deployment Services (ADS) for a non-default instance. Part of the sequence does a DIR on the SQLSERVER.EXE item in the SQL Server folder which in any instance other the the default is in the \MSSQL$INSTANCE folder.
I created the sequence and went to test it so I tried to run it and the ADS Management console came back with the following error:
Code: 80040861
Description: Failed to validate the command syntax in the task sequence XML document.
Because ADS uses $ (dollar) signs to mark a device variables, putting a single $ in somewhere in the sequence forced it to break.
To work around this issue, you need to escape the single $ sign with $$ (dollar dollar).
With this change I was able to finish my Task Sequence to install SQL Server and SP4 and now have a daily build test environment being build and completly configured that consists of 4 IIS applciation servers (2 load balanced pairs) and a SQL Server 2000 servers.
The whole environment, including all custom applications to be installed takes about an hour to build on a Virtual Server.

No Comments »
Filed under: Automated Deployment Services (ADS)
Posted on May 10th, 2005 by Mark Sheppard
You can speed up your image deployments with Automated Deployment Services (ADS) by adding the parameter -nonetencrypt to the /imaging/imgbmdeploy.exe task as shown in the following example:
<!– download images –>
<task description=”Download image”>
<command>/imaging/imgbmdeploy.exe</command>
<parameters>
<parameter>imagename</parameter> <!– image to be deployed–>
<parameter>\device\harddisk0\partition1</parameter> <!– deploy to partition1 –>
<parameter>-r</parameter> <!– specifies deploy mode –>
<parameter>-client</parameter> <!– required parameter –>
<parameter>-nonetencrypt</parameter> <!– turn off encryption –>
</parameters>
</task>
Of cause, this does mean that images are deployed without encryption, so only use this if you trust the LAN in your data centre.
One final caveat with this option is that there is no interface in Sequence Editor to support it and setting this option (using Notepad or similar) results in Sequence Editor freaking out when you try to open the sequence.
I have noticed a 60% deployment time reduction with this switch on and a massive drop in CPU usage on my Image server.Happy deploying!
No Comments »
Filed under: Automated Deployment Services (ADS)