commands detail - w

wc -l

  1. gc c:\temp\file.txt | measure-object | select count

to show the number of non-blank lines:

  1. gc c:\temp\file.txt | measure-object -line

whoami

This shows user that you are logged on as:

  1. [Security.Principal.WindowsIdentity]::GetCurrent() | select name

whence or type

There isn’t a single equivalent to the unix whence command, but there are a couple of things worth mentioning.

This shows the sort of thing (exe, bat, alias, function) that you’re looking at:

  1. get-command whoami
  2. CommandType Name ModuleName
  3. ----------- ---- ----------
  4. Application whoami.exe

….and if what you’re looking for is a file in your path, then this will find it

  1. foreach ($FOLDER in $ENV:PATH.split(";") ) { dir $FOLDER\whoami.exe -ea Si | select fullname }
  2. FullName
  3. --------
  4. C:\Windows\system32\whoami.exe

This splits the path into its constituent folders, then does a dir to see if
the file (in this case I’m looking for whoami.exe) exists in each.