Wednesday, February 25, 2009

SLMgr Commands and Options

I’ve been dealing a lot lately with activation of Server 2008. It’s not been as easy as I’d like. In searching for some help, I came across a great article on SLMgr: SLMgr Commands and Options with Windows Vista Product Key Activation. This article provides a good look at the options with this SLMgr.ext tool.

Technorati Tags:

Tuesday, February 24, 2009

OCS, WMI and PowerShell

This past week, I was teaching OCS Voice Ignite in Munich and a colleague (superstar Robin Edwards). During the week, we chatted about how to configure OCS’s Address Book service. This is a topic that comes up a lot in our OCS training, especially as the Address Book seems to be one of the key troubleshooting issues our delegates encounter.

As it turns out, you cannot do much with the GUI. There’s nothing there to enable you to do much more than view SOME of the settings. For example, by default, OCS ABS keeps 30 days worth of delta address books. If you login to Office Communicator, OC will download only the deltas since the last time you logged in, up to a certainly value – by default 30 days. This is a great feature for very large address books that don’t change a lot week to week.

The problem is, you can’t see this value in the GUI, nor can you set it. To view or change this, you need to use WMI in a direct way. Which leaves you three options: WBEMTest, VBS, or PowerShell. For most admins, WBEMTest is way too ugly and unfriendly and that probably is true for VBS. But PowerShell makes it very, very easy (assuming you know PowerShell of course).

The key settings for the Address Book Server are found in the WMI Class MSFT_SIPAddressBookSettings. This class is defined in MSDN at http://msdn.microsoft.com/en-us/library/bb632067.aspx.

This class has some useful properties, including:

DaysToKeep – specifies the number of days to keep the delta data files. The default is 30.

ExternalURL - An HTTPS URL that specifies the external location for address book file downloads

InternalURL - An HTTPS URL that specifies the internal location for address book file downloads.

MaxDeltaFileSizePercentage - The maximum percent of change for which a delta file is created. A delta file is not created if the percent of change is greater than this number. Multiply the value by 0.01 to derive the percentage. The minimum value for this property is 0 and the maximum value is 9999 (99.99%). The default value is 1250 (12.5%).

OutputLocation - Specifies the directory in which the files are stored.
PartitionOutputByOU - Controls whether data is partitioned by organization unit (OU).
RunTime - Specifies the service start time. The minimum value for this property is 0 and the maximum value is 2359. The default value is 130.

SynchronizeNow - When true, triggers the Address Book Server to perform a synchronization pass.

SynchronizePollingIntervalSecs - Specifies the number of seconds between checks for synchronization. The minimum value for this property is 5 and the maximum value is 9999.

UseNormalizationRules - Controls whether normalization is performed.

So much for what it does, now to how to do it with OCS R2. To get this class, using Standard Edition, you just use:

Get-WMIObject –Class MSFT_SipAddressbookSetting

However, using EE, it’s a bit more complex and you have to use a slightly different variation on the Get-WMIObject sytax, as follows:

PS C:\foo> gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee

Backend : dc1
DaysToKeep : 30
ExternalURL :
IgnoreGenericRules : False
InstanceID : {D265A402-BD08-4BCB-BEB3-CC7AFBD47C08}
InternalURL :
https://Cookham.gktrain.net/Abs/Int/Handler
MaxDeltaFileSizePercentage : 1250
OutputLocation : \\ocs-ee\absfiles
PartitionOutputByOU : False
RunTime : 130
SynchronizeNow : False
SynchronizePollingIntervalSecs : 300
UseNormalizationRules : True
WebServiceEnabled : True

So to make some changes, you could do something like this:

PS C:\foo> $abs = gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee
PS C:\foo> $abs.daystokeep = 45
PS C:\foo> $abs.runtime = 0230
PS C:\foo> $result = $abs.put()

PS C:\foo> gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee

Backend : dc1
DaysToKeep : 45
ExternalURL :
IgnoreGenericRules : False
InstanceID : {D265A402-BD08-4BCB-BEB3-CC7AFBD47C08}
InternalURL : https://Cookham.gktrain.net/Abs/Int/Handler
MaxDeltaFileSizePercentage : 1250
OutputLocation : \\ocs-ee\absfiles
PartitionOutputByOU : False
RunTime : 230
SynchronizeNow : False
SynchronizePollingIntervalSecs : 300
UseNormalizationRules : True
WebServiceEnabled : True

And finally – a bit tip of the hat to superstar Robin Edwards who showed me this class last week. Thanks Rob – you rock!

Technorati Tags: ,,

Thursday, February 19, 2009

Hotkey Keyboard Shortcuts in Windows 7 beta 1

Some time ago, I posted a blog article describing the short cut keys for Vista.  Looking at the statistics for this site, I see that this article is still being accessed (via Google). While many of those keys still work in Vista, there are some new hotkeys too, as described in a TechNet article.

These new  hot keys are as follows:

  • Win+Home: Clear all but the active window
  • Win+Space: All windows become transparent so you can see through to the desktop
  • Win+Up arrow: Maximize the active window
  • Win+Down arrow: Minimize the active window or restore the window if it's maximized
  • Win+Left/Right arrows: Dock the active window to each side of the monitor
  • Win+Shift+Left/Right arrows: If you've got dual monitors, this will move the active window to the adjacent monitor
  • Win+T: Shift focus to and scroll through items on the taskbar
  • Win+P: Adjust presentation settings for your display
  • Win+(+/-): Zoom in/out
  • Shift+Click a taskbar item: Open a new instance of that particular application

I’ve been using Win7 exclusively on my new laptop for a couple of weeks and am convinced! There are a couple of defencies, but these are driver related issues (and driver makers who do the “we do not support beta OSs” excuse.  But despite that, I’m sufficiently happy with Win7 beta to not want to reboot back to XP.

Technorati Tags: ,,,

Tuesday, February 17, 2009

Swapping variables with PowerShell

I’ve often had cases with programming where I want to swap the contents of two variables. For example, suppose I have two variables $a, and $b, and what we want is to have $a contain the value of $b and $b contain the value of $a.

As an old fashioned programmer, I’d do it this way:

# Assign some values
$a = 1
$b = 2
# now switch
$temp = $a
$a = $b
$b = $temp

Now that works, but it requires the use of a third variable ($temp). If $a and/or $b were large arrays (e.g. all the file objects on a system for example) this would waste a lot of RAM and cause a GC collection.

As it turns out, with PowerShell, there’s another way:

# Assign some values
$a = 1
$b = 2
# now switch
$a,$b = $b, $a

In this case, PowerShell treats the two sides of the “=” as arrays and does the necessary transposition of values.

Thanks to Tobias Weltner for pointing this out.

Technorati Tags: ,,

Tuesday, February 10, 2009

PowerShellPlus v2.1 Beta – A Cool Feature

As I noted in in a recent blog post, Idera has released a new beta for PowerShell Plus 2.1. I’ve  been using it a bit lately and I can’t wait for it to go final!

One really neat feature I discovered today is the Shft+Enter feature. If like me, you find CMD.EXE still has the occasional feature that PowerShell doesn’t quite meat (dir /s and dir /ad are two that are much harder in PowerShell), then you can enter the command and instead of hitting Enter, hit Shift+Enter and the cmd will be run by CMD.EXE. So inside PowerShell Plus, it looks like this:

 

PSH [C:\]: dir foo*.* /s         <--- plus Shift+Enter
Volume in drive C is XP_32bit
Volume Serial Number is 44B8-CFED

Directory of C:\

10/02/2009  16:59    <DIR>          foo
               0 File(s)              0 bytes

Directory of C:\foo

10/02/2009  16:59                 7 foo.foo
16/05/2008  13:18           121,306 foo.txt
               2 File(s)        121,313 bytes

Directory of C:\WINDOWS\Help\Tours\htmlTour

04/08/2004  12:00             1,777 footer.htm
               1 File(s)          1,777 bytes

     Total Files Listed:
               3 File(s)        123,090 bytes
               1 Dir(s)   8,188,985,344 bytes free
PSH [C:\]:

Super cool!  Yet another reason for serious scripters to buy PowerShell Plus!

Technorati Tags: ,

Saturday, February 07, 2009

/n software inc. Sponsors PowerShell.com Community Site

Tobias Weltner this week announced that /n software, a provider of software components for Internet, security, and E-Business development, has become the latest sponsor for the PowerShell.Com community site. This is a great thing as it can improve the visibility, viability and hopefully the usefulness of the PowerShell.com site.

Friday, February 06, 2009

InstEd – A Replacement For Orca

As many of you know, Orca is an MSI editor. I wrote about it a long time ago (here), but have used it ever since! I find Orca particulary useful to fix the many MSIs that stop code running on, for example Server 2003 that runs fine on XP (e.g. drivers from OEMs). Often, there’s just a line in the MSI that needs to be taken out and the MSI functions fine.

Tonight I found a neat replacement – and it’s free. Called InstEd – you can get it from the web site (http://www.instedit.com). What can I say – it does what it says. For more information, see the Online Help.

Technorati Tags: ,,

Wednesday, February 04, 2009

PowerShellPlus v2.1 Beta

This is sort of exciting - PowerShellPlus v2.1 Beta is live! I’ve used PowerShell Plus for some time and love it. But there are things that I’d like to see, in particular the CTP3 support. Well, now we have that – and I’m downloading it as I write this post. The features in 2.1 that catch my eye are: VBS support, STA MOde, Code Sharing and of course, CTP3 support. I’ll be posting more once I have the code running and have a chance to give it a good test!

Technorati Tags: ,,

Tuesday, February 03, 2009

The Official Scripting Guys Forum

Just a heads-up that those cool Scripting Guys from Microsoft now have a on-line web forum for help on scripting. Just launched, The Official Scripting Guys Forum is a part of the overall TechNet forum and is a web-only forum (sadly no NNTP).

The forum is a one stop shop for all scripting questions, including questions on Perl, VBScript and of course PowerShell. There are a number of scripting gurus there already and I’ve agreed to be one of the moderators!