A Unix Person's Guide to PowerShell
  • ReadMe
  • About this Book
  • Introduction to PowerShell for Unix People
  • Commands Summary
  • Command Detail - A
  • Command Detail - B
  • Command Detail - C
  • Command Detail - D
  • Command Detail - E
  • Command Detail - F
  • Command Detail - G
  • Command Detail - H
  • Command Detail - I
  • Command Detail - J
  • Command Detail - K
  • Command Detail - L
  • Command Detail - M
  • Command Detail - N
  • Command Detail - O
  • Command Detail - P
  • Command Detail - Q
  • Command Detail - R
  • Command Detail - S
  • Command Detail - T
  • Command Detail - U
  • Command Detail - V
  • Command Detail - W
  • Command Detail - X
  • Command Detail - Y
  • Command Detail - Z
  • Command Detail - Non-alphabetical
  • To-do
Powered by GitBook
On this page
  • wc -l
  • whoami
  • whence or type

Command Detail - W

wc -l

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

to show the number of non-blank lines:

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

whoami

This shows the user that you are logged on as:

[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:

get-command whoami,Get-Command,invoke-sqlcmd,sserv,schtasks.exe | select name,version,source,DisplayName

Name          Version      Source                           DisplayName                      
----          -------      ------                           -----------                      
whoami.exe    10.0.17134.1 c:\windows\system32\whoami.exe                                    
Get-Command   3.0.0.0      Microsoft.PowerShell.Core                                         
Invoke-Sqlcmd 1.0          sqlps                                                             
sserv         0.0          WindowsStuff                     sserv -> show-nonstandardservices
schtasks.exe  10.0.17134.1 c:\windows\system32\schtasks.exe
PreviousCommand Detail - VNextCommand Detail - X

Last updated 7 years ago