Determine which properties of an object can be changed in Powershell

This is actually the example no 8 from Get-Help Get-Member

C:\PS>$file = get-item c:\test\textFile.txt

C:\PS> $file.psobject.properties | where-object {$_.issettable} | format-table -property name
 
Name
—-
PSPath
PSParentPath
PSChildName
PSDrive
PSProvider
PSIsContainer
IsReadOnly
CreationTime
CreationTimeUtc
LastAccessTime
LastAccessTimeUtc 
LastWriteTime
LastWriteTimeUtc
Attributes

C:\PS> [appdomain]::CurrentDomain.GetAssemblies() | foreach-object { $_.getexportedtypes() } | foreach-object {$_.getproperties() | where-object {$_.canwrite }} | select-object reflectedtype, name

Description
———–
This example shows how to determine which properties of an object can be changed.  The example uses a file, but you can use this command format to find the changeable properties of any object in Windows PowerShell.  The first command uses the Get-Item cmdlet to get a text file, and then it saves the file object in the $file variable.  The second command gets all of the changeable properties of the file object in the $file variable and displays the names of the properties in a table.  The third command gets the changeable properties of all objects in your Windows PowerShell session. 

Advertisements

Tagged:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

smsagent

Tips, tricks and time-savers for the Windows and ConfigMgr administrator

To The Point

Anything about Technology and Business

Brian's Power Windows Blog

Microsoft in the Enterprise. Windows, Hyper-V, Exchange, SQL, and more!

PowerScripting Podcast

Shownotes and links for the PowerScripting Podcast, a podcast to help people learn Windows Powershell

Learn Powershell | Achieve More

What is this Powershell of which you speak?

%d bloggers like this: