Finding Changeable Properties

by Oct 8, 2014

All PowerShell Versions

When you get back results from PowerShell cmdlets, the results are objects and have properties. Some properties can be changed, others are read-only.

Here is a simple trick to find out the object properties that you can actually change. The code uses the process object of the current PowerShell host, but you can use any cmdlet result.

$myProcess = Get-Process -Id $Pid

$myProcess | 
  Get-Member -MemberType Properties | 
  Out-String -Stream | 
  Where-Object { $_ -like '*set;*' } 

The result looks like this:

EnableRaisingEvents        Property       bool EnableRaisingEvents {get;set;}     
MaxWorkingSet              Property       System.IntPtr MaxWorkingSet  {get;set;}  
MinWorkingSet              Property       System.IntPtr MinWorkingSet  {get;set;}  
PriorityBoostEnabled       Property       bool PriorityBoostEnabled  {get;set;}   

Twitter This Tip! ReTweet this Tip!