.NET isolated Storage in PowerShell: user store vs machine store

by ravikanthchaganti on June 3, 2010
166 Views

This post has been in draft for a long time. So, clicking publish today :)  

In a couple of earlier posts, I wrote about using .NET isolated storage and an example showing a use case for this. In today’s post, I will explain the differences between user store and machine store. I admit, this has nothing to do with PowerShell. This is more of a .NET related post but as always, I will use PowerShell to explain this. 

When you look at the .NET namespace to create/manage isolated storage in PowerShell, you will find that there are different methods to create isolated storage. These methods include 

GetUserStoreForAssembly()
GetUserStoreForApplication()
GetUserStoreForDomain()
GetMachineStoreForAssembly()

GetMachineStoreForApplication()
GetMachineStoreForDomain() 

So, there are two types of stores and different ways to create/manage these stores. For the sake of today’s discussion, I will talk about GetUserStoreForAssembly() & GetMachineStoreForAssembly() 

.NET isolated storage types

.NET isolated storage types

So, when you use GetUserStoreForAssembly(), isolated storage will be created under the AppData folder within the the user’s profile folder. For example, C:\users\User1\AppData\Local\isolatedStorage. In case of a machine store, you will find an isolatedStorage folder under C:\users\AllUsers profile. 

How do we create these stores? 

Easy. You have already seen an example of user store in my earlier use case post. To create a machine store, all you need to do is — replace GetUserStoreForAssembly() with GetMachineStoreForAssembly(). Simple..! 

So, when do we use these two stores? 

User store should be your choice when you don’t have to share any data between different users. For example, you want all your users to have their own ISE preferences.
And, you use machine store when data needs to be shared between all users of a system.  For example, you want to enforce all users to have the same ISE settings everytime they open PowerShell ISE. 

That is it for today. Hope this is helpful..! 

 

Related Posts

{ 1 trackback }

Leave a Comment

Previous post:

Next post: