Get Computer name using PowerShell

ad+1

How to find your computer's host-name? What users are you logged in as? Sometimes this information is what you need when you are invited to troubleshoot an issue. How to find basic information about your computer in a handy way? Use PowerShell!

How to find your computer's hostname in 3 easy ways?

# Checking current computer name using PowerShell
Hostname

OR

$env:computername

OR

gwmi win32_computersystem


Bonus! 
How to change a computer name using PowerShell?

# Rename a computer -
$(gwmi win32_computersystem).Rename("NewCompName")

This one would need:
1) Local Admin Credential
2) Domain controllers must be available

Some more tips available here -  like Adding a computer to the domain using PowerShell.
Powershell is cool, huh!


0 comments:

I welcome you to write your comments here..