PowerShell for Windows Admins

Feb 22 2018   2:39PM GMT

ComputerName

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

If you want to find the name of the local computer you use $env:COMPUTERNAME.

Except that doesn’t exist in Linux PowerShell v6 – you have to use $env:HOSTNAME

PowerShell 1 Consistency 0

I can live with having $env:HOSTNAME because I bet that’s what Linux users would look for. It would be nice to also have $env:COMPUTERNAME for Windows users starting out with Linux.

It gets better.

If you create a SSH remoting session using PowerShell v6 to a Linux system – $env:HOSTNAME ISN’T exposed. You have to use the hostname legacy utility.

If you create a SSH remoting session using PowerShell v6 to a Windows system – $env:COMPUTERNAM IS exposed.

PowerShell 2 Consistency 0

Could be worse I suppose.

 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: