This months meeting covered working with the registry.
The slides and the demo script are available from
The recording is available
Richard Siddaway has invited you to view a Microsoft Office Live Meeting recording.
Subject: PowerShell and the Registry
Recording URL: https://www.livemeeting.com/cc/usergroups/view
Recording ID: CB99JS
Attendee Key: mm$2!",$G
Tomorrow is the PowerShell UG Live Meeting on the Registry, PowerShell, .NET and WMI.
Full details from
Most organisations have a degree of heterogeneity in their infrastructure for example:
- mainly Windows with a few Unix or Linux servers
- multiple versions of SQL Server because of application restrictions
- a mixture of fat client and thin client systems because of application and mobility drivers
- virtual and physical servers
Cost can also be a contributing factor to heterogeneity – for instance an organisation wants to virtualise its whole infrastructure but can’t afford to perform the migration in a single project under the current economic conditions.
Complexity, in infrastructure terms, may seem to be the same as heterogeneity in that a complex infrastructure is usually heterogeneous however a heterogeneous infrastructure isn’t necessarily complex.
Complexity arises from a number of sources:
- multiple systems performing the same task
- manual administration processes across multiple, disparate systems
- multiple technologies - “just because we can”
- wrong choice of technology
- infrastructure driven by technology rather than business need
- adopting new technologies without a clear business need
The last point may need some clarification. There is a simple progression of needs:
- organisations have business processes
- business processes need applications to make them work
- applications need to be hosted on and supported by infrastructure
If we approach this list in a top down manner we build infrastructure that meets the business requirements. If we supply technology and attempt to make the applications and business processes fit the result may well not meet the requirements and almost certainly will be more complex.
Complexity can be removed from a heterogeneous environment e.g:
- use Active Directory for authentication\authorisation on your handful of Unix/Linux servers
- extend your management tools across the whole environment
- determine a strategic approach to infrastructure and ensure there is a governance/enforcement mechanism
I’ve stated before that infrastructure seems to a forgotten subject. There is a lot published on software architectures but very little on the infrastructure. We don’t even seem to have a set of guiding principles. I’ll offer one here:
Heterogeneity driven by business need should be embraced. Complexity should be removed from the environment.
One other aspect we need to cover is deleting individual values
Open the key for writing and use the DeleteValue() method.
Having created some keys lets add some values
This is very similar to the script we used to change the values – open the key for writing and use SetValue(). Just make sure we use the right data type.
Having seen how to read, change and delete keys – lets add some
Set the hive and call the CreateSubKey method. Note the second example where we create a further depth of subkeys. It isn’t necessary to create each step in the chain we can create the lot in one go
Now is the time to delete a registry key
If there is a tree of subkeys then we can use the DeleteSubKeyTree() method
Lets look at changing registry values. In http://msmvps.com/blogs/richardsiddaway/archive/2010/07/16/registry-1.aspx I showed how to read the registry. We’ll change the 4 values we found in that post
Open the key as we did before except this time add a second parameter. $true indicates that the key is opened in a readable state. The SetValue method can be used to set the appropriate values. The parameters are the name of the value, the new value and the data type. Notice that for the multi-string value we supply and array of strings.
The acceptable data types are:
PS> Get-Enum Microsoft.Win32.RegistryValueKind
How we can use PowerShell, WMI and .NET to work with the registry
Richard Siddaway has invited you to attend an online meeting using Live Meeting.
Join the meeting.
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.
Unable to join the meeting? Follow these steps:
- Copy this address and paste it into your web browser:
- Copy and paste the required information:
Meeting ID: CB99JS
Entry Code: mm$2!",$G
If you still cannot enter the meeting, contact support
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.
In the previous post I showed this line
$reg = [Microsoft.Win32.Registry]::LocalMachine
which we used to determine which registry hive we would work with.
LocalMachine is a member of the Microsoft.Win32.RegistryHive enumeration.
An enumeration is a closed list.
I’ve added this function to my profile
so that I can quickly find the members of an enumeration.
Use it like this
PS> Get-Enum Microsoft.Win32.RegistryHive