PowerShell for Windows Admins

Oct 14 2016   12:09PM GMT

Current location

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Bash
Powershell
Windows 10 gives you the option of installing BASH on Ubuntu – https://msdn.microsoft.com/en-us/commandline/wsl/about also known as the Windows Subsystem for Linux (WSL). More information from https://blogs.msdn.microsoft.com/wsl/
I thought it would be interesting to compare some of the bash commands with their PowerShell equivalents.
First off – current location.
Its not obvious from the bash prompt where you are in the file system so you use pwd
root@RSsurfacePro2:~# pwd
/root
In PowerShell you use Get-Location
PS> Get-Location
Path
—-
C:\test
Interestingly you can use pwd in PowerShell
PS> pwd
Path
—-
C:\test
That’s because pwd is an alias for Get-Location
PS> get-alias pwd | fl
DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location
If you want to discover all existing aliases for Get-Location
PS> get-alias | where ResolvedCommand -like ‘get-location’ | fl
DisplayName       : gl -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location
DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location
You’ll find that many core PowerShell cmdlets have aliases corresponding to Linux commands. Note that they are removed for PowerShell on Linux to avoid confusion.
Look out for other comparisons soon.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: