Monthly Archive

Categories

ComputerName

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.

Comments are closed.