commands detail - w

wc -l

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

to show the number of <i>non-blank</i> lines:

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

whoami

This shows the user that you are logged on as:

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

whence or type

There isn’t a close equivalent to the unix whence command, because within Powershell there isn’t a PATH variable for scripts. The environment’s PATH and PSMODULEPATH list the folders for windows executables and for Powershell modules.

get-command shows the location of the windows executable, the name of the Powershell module or the translation of the alias, as follows:

 1 get-command whoami,Get-Command,invoke-sqlcmd,sserv,schtasks.exe | select name,versio\
 2 n,source,DisplayName
 3 
 4 Name          Version      Source                           DisplayName             \
 5          
 6 ----          -------      ------                           -----------             \
 7          
 8 whoami.exe    10.0.17134.1 c:\windows\system32\whoami.exe                           \
 9          
10 Get-Command   3.0.0.0      Microsoft.PowerShell.Core                                \
11          
12 Invoke-Sqlcmd 1.0          sqlps                                                    \
13          
14 sserv         0.0          WindowsStuff                     sserv -> show-nonstandar\
15 dservices
16 schtasks.exe  10.0.17134.1 c:\windows\system32\schtasks.exe                         \
17