Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell change hostname in a workstation or member server joined to the domain.

$
0
0

Hi, I use the powershell to change a machine name, I use $name as variable to input a name and the follow cmd-let: $computerName.Rename($name) but it only work in a unjoined domain machine.

my script is the following:

$computerName = Get-WmiObject Win32_ComputerSystem
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$name = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Desired Computer Name ")
$computername.rename("$name")

but I need to change the hostname of any computer joined in my domain, may be it's another command, I don't know and I can't find information seeking the web.

I don't need a remote procedure, only a local to facilitate to my servicedesk to change hostnames in different machines.

If somebody knows something I'll be pleasure to know it.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>