get-membervalues.ps1
<#PSScriptInfo
.VERSION 1.0.0 .GUID 4faf08b7-31ca-4096-b482-a653a199718d .AUTHOR Whiggs .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .Synopsis This function sends a file (or folder of files recursively) to a destination WinRm session. .DESCRIPTION This script accepts a .Net object as input and will output all of the properties of the object along with their associated values. Very useful when new learning about new .Net objects. .NOTES Name : Get-MemberValues Author : whiggs DateCreated: 2021-05-03 DateUpdated: .PARAMETER Object The object whose property values will be displayed .EXAMPLE $items = Get-childitem C:\ Get-membervalues.ps1 -object $items[0] This example will display all of the property values for the first directory/file object that is returned by Get-childitem #> Param ( [Parameter(Position = 0, Mandatory = $true)] [System.Object]$object ) $prop = $object | Get-member Foreach ($pr in $prop) { If ($pr.MemberType -like "Property") { If (($object.$($pr.Name) -isnot [String]) -and ($object.$($pr.Name) -ne $null)) { Write-Host "$($pr.Name)" $sub = $object.$($pr.Name) | Get-member Foreach ($su in $sub) { If ($su.MemberType -like "Property") { Write-Host "`t$($su.Name):`t$($object.$($pr.Name).$($su.Name))`r`n" } } } Else { Write-Host "$($pr.Name):`t$($object.$($pr.Name))`r`n" } } } |