Skip to content

Instantly share code, notes, and snippets.

@Jaykul
Last active March 27, 2022 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jaykul/e14600dd8caef3c44aff7a7bfcebe9ce to your computer and use it in GitHub Desktop.
Save Jaykul/e14600dd8caef3c44aff7a7bfcebe9ce to your computer and use it in GitHub Desktop.
Adding Attributes to Get-Member

I found an easy way to surface the attributes that are on properties of objects. If you update the MemberDefinition type, you can expose them so they show up when you run Get-Member.

Update-TypeData -TypeName Microsoft.PowerShell.Commands.MemberDefinition `
-MemberType ScriptProperty `
-MemberName Attributes `
-Value { ($this.TypeName -as [Type]).GetMember($this.Name).GetCustomAttributes($true) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment