Skip to content
shellmap

get-memberList properties, methods, and events on a PowerShell object across all 5 shells

Equivalents in every shell

Bashunix
declare -p VAR

bash has no rich object model — variables are strings, arrays, assoc-arrays, or integers. `declare -p VAR` shows the type and value. `type cmd` shows whether something is a builtin / function / alias / external. For functions, `declare -f funcname` shows the body. None of this is "members of an object" — it's the closest bash equivalent.

Zshunix
typeset -p VAR

zsh's `typeset -p` is the equivalent of bash's `declare -p` — shows variable type + value. `whence -v cmd` is the zsh `type` equivalent. zsh modules (`zmodload`) extend the runtime with object-ish APIs (zsh/system, zsh/zutil) but `get-member` style introspection isn't a shell-native concept.

Fishunix
set --show VAR

fish's `set --show` displays the value of a variable across all scopes (global / universal / local) with type annotations. `functions -v funcname` shows function metadata. fish has no object model — variables are strings or lists of strings only.

PowerShellwindows
$obj | Get-Member

Reflects the .NET type. Lists every property (with type), method (with signature), event, alias property, scriptproperty. Aliased as `gm`. Default output groups by member type. `-MemberType Property|Method|Event|All` filters. `-Force` shows hidden members.

cmd.exewindows
powershell -NoProfile -Command "$obj | Get-Member"

cmd has no introspection — variables are strings only. `set VARNAME` displays a single variable; `set` (no arg) displays all. For real object introspection, shell out to PowerShell. Some COM objects can be poked at via `cscript` + JScript but that's a different language.

Worked examples

List all properties of an object

Bash
declare -p user_email user_id user_role
PowerShell
$user | Get-Member -MemberType Property

See what methods you can call

Bash
type cmd_name
PowerShell
$obj | Get-Member -MemberType Method

Inspect a single specific property

Bash
echo "${VAR@A}"  # bash 5+ — A attribute prints declaration form
PowerShell
$obj | Get-Member -Name Email

Gotchas

  • `Get-Member` works PER OBJECT, not per type — `(1, "two") | gm` produces TWO separate outputs (one for `[int]`, one for `[string]`) because the cmdlet runs once per pipeline item and groups by `.GetType()`. To inspect a TYPE's members (without an instance), use `[int] | Get-Member -Static` or reflection: `[int].GetMembers() | Format-Table Name, MemberType`.
  • To inspect members of an ENTIRE array (rather than per-element), pass `-InputObject`: `Get-Member -InputObject $arr` shows the array's methods (`.Length`, `.Clone()`, …) instead of the element-type members.
  • PowerShell adds SYNTHETIC members to many built-in types via `Types.ps1xml` — e.g. `[string]` gets a `Length` property that's native, but `[FileInfo]` gets `Mode` and `LastWriteTime` as alias / script properties. `Get-Member` shows them all; `-Force` is needed to also see the framework-hidden ones.
  • Reflection-based access (`.GetMembers()`) returns the underlying .NET names, sometimes different from the PowerShell-visible names (PowerShell often adds `Get-` / `Set-` prefix wrappers). `Get-Member` shows the PowerShell-visible names — usually what you want.
  • For COM objects, `Get-Member` works but is INCOMPLETE — late-bound COM members (set via `IDispatch`) don't appear because they're resolved at call time. Use `$comobj.GetType().InvokeMember(...)` or examine the type library via `OleViewDotNet` for the full surface.

WSL & PowerShell Core notes

pwsh`Get-Member` is identical on every pwsh platform — same .NET reflection underneath. On Linux/macOS pwsh, fewer COM-related types exist (no COM model outside Windows) so member counts on certain objects differ. Use `Get-Member -Static` to inspect static members of a type without an instance.
WSL`Get-Member` is meaningless from WSL bash directly — bash has no object model. To use it from WSL, invoke pwsh.exe: `pwsh.exe -c "$obj | Get-Member"`. Useful for one-shot reflection on Windows .NET types when developing cross-platform pwsh scripts from a Linux dev environment.

Related commands