Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Change MachineName via PowerShell

Reply
 
Old 05-04-2009   #1 (permalink)
Shane Wealti


 
 

Change MachineName via PowerShell

I'm new to Windows PowerShell so I apologize if I missed something obvious. I
would like to write a script that will change the MachineName and then reboot
the PC. I think I can figure out the reboot part but I searched many places
and I can't figure out how to change the MachineName. I'm trying to set up a
generic VM that will be used to test different configurations of software and
part of the testing requires different machine names so I would like to write
a script that sets up the VM with the test environment which includes a
specific machine name and then reboots the PC/VM.


My System SpecsSystem Spec
Old 05-04-2009   #2 (permalink)
Vadims Podans [MVP]


 
 

Re: Change MachineName via PowerShell

For PowerShell 1.0 you can use:
1) netdom.exe utility
2) Rename method in Win32_ComputerSystem WMI class
For PowerShell V2 you can use Rename-Computer cmdlet.
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"Shane Wealti" <ShaneWealti@xxxxxx> rakstīja ziņojumā
"news:84C94186-C2AD-430A-9E6D-0B4EF0780D2D@xxxxxx"...
Quote:

> I'm new to Windows PowerShell so I apologize if I missed something
> obvious. I
> would like to write a script that will change the MachineName and then
> reboot
> the PC. I think I can figure out the reboot part but I searched many
> places
> and I can't figure out how to change the MachineName. I'm trying to set
> up a
> generic VM that will be used to test different configurations of software
> and
> part of the testing requires different machine names so I would like to
> write
> a script that sets up the VM with the test environment which includes a
> specific machine name and then reboots the PC/VM.
>
My System SpecsSystem Spec
Old 05-04-2009   #3 (permalink)
Shay Levy [MVP]


 
 

Re: Change MachineName via PowerShell

Rename-Computer doesn't exist anymore on CTP3, I wonder why.


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



V> For PowerShell 1.0 you can use:
V> 1) netdom.exe utility
V> 2) Rename method in Win32_ComputerSystem WMI class
V> For PowerShell V2 you can use Rename-Computer cmdlet.
V> "Shane Wealti" <ShaneWealti@xxxxxx> rakst?ja
V> zi?ojum? "news:84C94186-C2AD-430A-9E6D-0B4EF0780D2D@xxxxxx"...
V>
Quote:
Quote:

>> I'm new to Windows PowerShell so I apologize if I missed something
>> obvious. I
>> would like to write a script that will change the MachineName and
>> then
>> reboot
>> the PC. I think I can figure out the reboot part but I searched many
>> places
>> and I can't figure out how to change the MachineName. I'm trying to
>> set
>> up a
>> generic VM that will be used to test different configurations of
>> software
>> and
>> part of the testing requires different machine names so I would like
>> to
>> write
>> a script that sets up the VM with the test environment which includes
>> a
>> specific machine name and then reboots the PC/VM.

My System SpecsSystem Spec
Old 05-04-2009   #4 (permalink)
Vadims Podans [MVP]


 
 

Re: Change MachineName via PowerShell

mmm..at this time Rename-Computer appear in latest official CTP3 release
(from connect).
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"Shay Levy [MVP]" <no@xxxxxx> rakstīja ziņojumā
"news:95d808937dd298cb9b27bc06aab0@xxxxxx"...
Quote:

> Rename-Computer doesn't exist anymore on CTP3, I wonder why.
>
>
> ---
> Shay Levy
> Windows PowerShell MVP
> http://blogs.microsoft.co.il/blogs/ScriptFanatic
> PowerShell Toolbar: http://tinyurl.com/PSToolbar
>
>
>
> V> For PowerShell 1.0 you can use:
> V> 1) netdom.exe utility
> V> 2) Rename method in Win32_ComputerSystem WMI class
> V> For PowerShell V2 you can use Rename-Computer cmdlet.
> V> "Shane Wealti" <ShaneWealti@xxxxxx> rakst?ja
> V> zi?ojum? "news:84C94186-C2AD-430A-9E6D-0B4EF0780D2D@xxxxxx"...
> V>
Quote:
Quote:

>>> I'm new to Windows PowerShell so I apologize if I missed something
>>> obvious. I
>>> would like to write a script that will change the MachineName and
>>> then
>>> reboot
>>> the PC. I think I can figure out the reboot part but I searched many
>>> places
>>> and I can't figure out how to change the MachineName. I'm trying to
>>> set
>>> up a
>>> generic VM that will be used to test different configurations of
>>> software
>>> and
>>> part of the testing requires different machine names so I would like
>>> to
>>> write
>>> a script that sets up the VM with the test environment which includes
>>> a
>>> specific machine name and then reboots the PC/VM.
>
>
My System SpecsSystem Spec
Old 05-04-2009   #5 (permalink)
Shane Wealti


 
 

Re: Change MachineName via PowerShell

I'm running CTP3 and it does exist by I can't get it to work. For example,
I'm running it on a local PC named CAR01 and I want to change it to CAR05.

I run (from the Integrated Scripting Environmnet):

Rename-Computer -newcomputername CAR05 -PassThru -verbose

And it gives me the error:

This command cannot be executed on target computer('localhost') due to the
following error: The RPC server is unavailable.

I checked and the RPC service is running on the PC that I'm running the
command on. I can ping localhost. Also I tried with the firewall on and off
and it made no difference. It seems like there might be some kind of issue
with the credentials or powershell having permission to do a "remote"
procedure call even though it's running on the local computer.


"Shay Levy [MVP]" wrote:
Quote:

> Rename-Computer doesn't exist anymore on CTP3, I wonder why.
>
>
> ---
> Shay Levy
> Windows PowerShell MVP
> http://blogs.microsoft.co.il/blogs/ScriptFanatic
> PowerShell Toolbar: http://tinyurl.com/PSToolbar
>
>
>
> V> For PowerShell 1.0 you can use:
> V> 1) netdom.exe utility
> V> 2) Rename method in Win32_ComputerSystem WMI class
> V> For PowerShell V2 you can use Rename-Computer cmdlet.
> V> "Shane Wealti" <ShaneWealti@xxxxxx> rakst?ja
> V> zi?ojum? "news:84C94186-C2AD-430A-9E6D-0B4EF0780D2D@xxxxxx"...
> V>
Quote:
Quote:

> >> I'm new to Windows PowerShell so I apologize if I missed something
> >> obvious. I
> >> would like to write a script that will change the MachineName and
> >> then
> >> reboot
> >> the PC. I think I can figure out the reboot part but I searched many
> >> places
> >> and I can't figure out how to change the MachineName. I'm trying to
> >> set
> >> up a
> >> generic VM that will be used to test different configurations of
> >> software
> >> and
> >> part of the testing requires different machine names so I would like
> >> to
> >> write
> >> a script that sets up the VM with the test environment which includes
> >> a
> >> specific machine name and then reboots the PC/VM.
>
>
>
My System SpecsSystem Spec
Old 05-04-2009   #6 (permalink)
Vadims Podans [MVP]


 
 

Re: Change MachineName via PowerShell

try netdom or WMI.
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"Shane Wealti" <ShaneWealti@xxxxxx> rakstīja ziņojumā
"news:E4E66121-86F1-45C6-9C97-CFAF2DD2DB85@xxxxxx"...
Quote:

> I'm running CTP3 and it does exist by I can't get it to work. For example,
> I'm running it on a local PC named CAR01 and I want to change it to CAR05.
>
> I run (from the Integrated Scripting Environmnet):
>
> Rename-Computer -newcomputername CAR05 -PassThru -verbose
>
> And it gives me the error:
>
> This command cannot be executed on target computer('localhost') due to the
> following error: The RPC server is unavailable.
>
> I checked and the RPC service is running on the PC that I'm running the
> command on. I can ping localhost. Also I tried with the firewall on and
> off
> and it made no difference. It seems like there might be some kind of issue
> with the credentials or powershell having permission to do a "remote"
> procedure call even though it's running on the local computer.
>
>
> "Shay Levy [MVP]" wrote:
>
Quote:

>> Rename-Computer doesn't exist anymore on CTP3, I wonder why.
>>
>>
>> ---
>> Shay Levy
>> Windows PowerShell MVP
>> http://blogs.microsoft.co.il/blogs/ScriptFanatic
>> PowerShell Toolbar: http://tinyurl.com/PSToolbar
>>
>>
>>
>> V> For PowerShell 1.0 you can use:
>> V> 1) netdom.exe utility
>> V> 2) Rename method in Win32_ComputerSystem WMI class
>> V> For PowerShell V2 you can use Rename-Computer cmdlet.
>> V> "Shane Wealti" <ShaneWealti@xxxxxx> rakst?ja
>> V> zi?ojum? "news:84C94186-C2AD-430A-9E6D-0B4EF0780D2D@xxxxxx"...
>> V>
Quote:

>> >> I'm new to Windows PowerShell so I apologize if I missed something
>> >> obvious. I
>> >> would like to write a script that will change the MachineName and
>> >> then
>> >> reboot
>> >> the PC. I think I can figure out the reboot part but I searched many
>> >> places
>> >> and I can't figure out how to change the MachineName. I'm trying to
>> >> set
>> >> up a
>> >> generic VM that will be used to test different configurations of
>> >> software
>> >> and
>> >> part of the testing requires different machine names so I would like
>> >> to
>> >> write
>> >> a script that sets up the VM with the test environment which includes
>> >> a
>> >> specific machine name and then reboots the PC/VM.
>>
>>
>>
My System SpecsSystem Spec
Old 05-04-2009   #7 (permalink)
Shay Levy [MVP]


 
 

Re: Change MachineName via PowerShell

Thanks for checking, it should be missing on post CTP3 builds.

---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



V> mmm..at this time Rename-Computer appear in latest official CTP3
V> release (from connect).
V>
V> "Shay Levy [MVP]" <no@xxxxxx> rakst?ja zi?ojum?
V> "news:95d808937dd298cb9b27bc06aab0@xxxxxx"...
V>
Quote:
Quote:

>> Rename-Computer doesn't exist anymore on CTP3, I wonder why.
>>
>> ---
>> Shay Levy
>> Windows PowerShell MVP
>> http://blogs.microsoft.co.il/blogs/ScriptFanatic
>> PowerShell Toolbar: http://tinyurl.com/PSToolbar
>> V> For PowerShell 1.0 you can use:
>> V> 1) netdom.exe utility
>> V> 2) Rename method in Win32_ComputerSystem WMI class
>> V> For PowerShell V2 you can use Rename-Computer cmdlet.
>> V> "Shane Wealti" <ShaneWealti@xxxxxx> rakst?ja
>> V> zi?ojum?
>> "news:84C94186-C2AD-430A-9E6D-0B4EF0780D2D@xxxxxx"...
>> V>
Quote:

>>>> I'm new to Windows PowerShell so I apologize if I missed something
>>>> obvious. I
>>>> would like to write a script that will change the MachineName and
>>>> then
>>>> reboot
>>>> the PC. I think I can figure out the reboot part but I searched
>>>> many
>>>> places
>>>> and I can't figure out how to change the MachineName. I'm trying
>>>> to
>>>> set
>>>> up a
>>>> generic VM that will be used to test different configurations of
>>>> software
>>>> and
>>>> part of the testing requires different machine names so I would
>>>> like
>>>> to
>>>> write
>>>> a script that sets up the VM with the test environment which
>>>> includes
>>>> a
>>>> specific machine name and then reboots the PC/VM.

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Change IE Settings with Powershell PowerShell
Using PowerShell to change service descriptions PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46