TechNet
Products
IT Resources
Downloads
Training
Support
Products
Windows
Windows Server
System Center
Microsoft Edge
Office
Office 365
Exchange Server
SQL Server
SharePoint Products
Skype for Business
See all products »
Resources
Channel 9 Video
Evaluation Center
Learning Resources
Microsoft Tech Companion App
Microsoft Technical Communities
Microsoft Virtual Academy
Script Center
Server and Tools Blogs
TechNet Blogs
TechNet Flash Newsletter
TechNet Gallery
TechNet Library
TechNet Magazine
TechNet Wiki
Windows Sysinternals
Virtual Labs
Solutions
Networking
Cloud and Datacenter
Security
Virtualization
Updates
Service Packs
Security Bulletins
Windows Update
Trials
Windows Server 2016
System Center 2016
Windows 10 Enterprise
SQL Server 2016
See all trials »
Related Sites
Microsoft Download Center
Microsoft Evaluation Center
Drivers
Windows Sysinternals
TechNet Gallery
Training
Expert-led, virtual classes
Training Catalog
Class Locator
Microsoft Virtual Academy
Free Windows Server 2012 courses
Free Windows 8 courses
SQL Server training
Microsoft Official Courses On-Demand
Certifications
Certification overview
Special offers
MCSE Cloud Platform and Infrastructure
MCSE: Mobility
MCSE: Data Management and Analytics
MCSE Productivity
Other resources
Microsoft Events
Exam Replay
Born To Learn blog
Find technical communities in your area
Azure training
Official Practice Tests
Support options
For business
For developers
For IT professionals
For technical support
Support offerings
More support
Microsoft Premier Online
TechNet Forums
MSDN Forums
Security Bulletins & Advisories
Not an IT pro?
Microsoft Customer Support
Microsoft Community Forums
Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Skip to locale bar
Post an article
Translate this page
Powered by
Microsoft® Translator
Wikis - Page Details
First published by
Aman Dhally
When:
27 Feb 2012 10:03 PM
Last revision by
Maheshkumar S Tiwari
When:
5 Sep 2013 8:53 AM
Revisions:
2
Comments:
1
Options
Subscribe to Article (RSS)
Share this
Can You Improve This Article?
Positively!
Click Sign In to add the tip, solution, correction or comment that will help other users.
Report inappropriate content using
these instructions
.
Wiki
>
TechNet Articles
>
Set Computer Name using PowerShell.
Set Computer Name using PowerShell.
Article
History
Set Computer Name using PowerShell.
Hi,
Yesterday I faced a problem in which I need to change the computer name using PowerShell. First I was looking for some cmdlet which can do this job for me but there is not any inbuilt cmdlet for it.
Then I searched and finally find a way by which I can do this within the PowerShell. This method is using WMI to do the task.
Get-WmiObject
Win32_ComputerSystem
We are using Get-WMI to give us all the value of Win32_ComputerSystem.
You can see in the Output that the "Name value contain our Computer name "
WINANAL-088y8gx
" with mach with our above screenshot.
$computerName
=
Get-WmiObject
Win32_ComputerSystem
We are putting the command in to the
$computerName
variable. And you can see that the output of
$computerName
is same and above screenshot in which we run the command alone.
$name
=
Read-Host
-
Prompt
"Please Enter the ComputerName you want to
use.
"
In
$name
variables we are using
Read-Host
cmdlet with
-
Prompt
argument with asking users to provide a computer name to be use.
Whatever user provide to
Read-Host
, the value is stored in the
$name
variable. In First example in below screenshot we didn't provide anything to Read-Host and you can see that output of
$name
is blank. In next example we provide "Test-Laptop" to
Read-Host
and you can see that now $name contains the value of "Test-Laptop"
$computername
.Rename(
$name
)
The
Win32_ComputerSystem WMI class
contain the method of .Rename() in which we need to provide a desired computer name in brackets.
Now check if you computer name get changed or not.
Bingo !!! Yes It is changed.. now reboot you laptop ;) using
restart-Computer
And if you want a GUI box to to open a Pop-UP to insert computer Name try this
[System.Reflection.Assembly]
::LoadWithPartialName('Microsoft.VisualBasic') |
Out-Null
$name
=
[Microsoft.VisualBasic.Interaction]
::InputBox("Enter Desired Computer Name ")
$name
Download the script from Here :
http://dl.dropbox.com/u/17858935/Change_ComputerName.zip
Thanks for reading .
Aman Dhally
Aman Dhally
,
en-US
,
has Images
,
PowerShell
,
Set ComputerName
,
WMI and PowerShell
[Edit tags]
Leave a Comment
Please add 7 and 1 and type the answer here:
Post
Wiki - Revision Comment List(Revision Comment)
Sort by:
Published Date
|
Most Recent
|
Most Useful
Comments
Maheshkumar S Tiwari
5 Sep 2013 8:53 AM
Maheshkumar S Tiwari edited Original. Comment: Added tags
Edit
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by:
Published Date
|
Most Recent
|
Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
Posted by
Maheshkumar S Tiwari
on
5 Sep 2013 8:53 AM
Maheshkumar S Tiwari edited Original. Comment: Added tags
Edit
Page 1 of 1 (1 items)