Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

PowerShell – Set Computer Name

Posted on November 9, 2015 By David Kittell
function Set-ComputerName {
	param(	[switch]$help,
		[string]$originalPCName=$(read-host "Please specify the current name of the computer"),
		[string]$computerName=$(read-host "Please specify the new name of the computer"))
			
	$usage = "set-ComputerName -originalPCname CurrentName -computername AnewName"
	if ($help) {Write-Host $usage;break}
	
	$computer = Get-WmiObject Win32_ComputerSystem -OriginalPCname OriginalName -computername $originalPCName
	$computer.Rename($computerName)
	}

Reference: http://poshcode.org/6036

All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code PowerShell

Post navigation

Previous post
Next post

Related Posts

Show Windows Version On Desktop

Posted on November 9, 2013October 26, 2015

WARNING: Backup the computer you try these scripts on before you run these. Windows Registry Editor Version 5.00 [[HKEY_CURRENT_USERControl PanelDesktop] "PaintDesktopVersion"=dword:00000000 Originally Posted on November 9, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program…

Read More

Format Zip Code Properly

Posted on November 11, 2013October 26, 2015

Sometimes a zip code is presented in a database with all nine numbers in the same column that has only five numbers. This query below will assist in formatting the numbers properly. SELECT CASE WHEN len(zip) = 10 AND substring(zip, 6, 1) = ‘-‘ THEN zip WHEN len(zip) = 5…

Read More

PowerShell – Domain Name WhoIS

Posted on November 9, 2015

#.Synopsis # Does a raw WHOIS query and returns the results #.Example # whois poshcode.org # # The simplest whois search #.Example # whois poshcode.com # # This example is one that forwards to a second whois server … #.Example # whois poshcode.com -NoForward # # Returns the partial results…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • Front Page
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes