Windows Vista Forums

Change MachineName via PowerShell
  1. #1


    Shane Wealti Guest

    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

  2. #2


    Vadims Podans [MVP] Guest

    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"...

    > 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

  3. #3


    Shay Levy [MVP] Guest

    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>

    >> 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

  4. #4


    Vadims Podans [MVP] Guest

    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"...

    > 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>

    >>> 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

  5. #5


    Shane Wealti Guest

    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:

    > 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>

    > >> 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

  6. #6


    Vadims Podans [MVP] Guest

    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"...

    > 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:
    >

    >> 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>

    >> >> 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

  7. #7


    Shay Levy [MVP] Guest

    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>

    >> 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>

    >>>> 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

Change MachineName via PowerShell problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
PowerShell 2.0 CTP3: How to change ThreadOptions Christian PowerShell 1 19 Feb 2009
MetadataResolver.Resolve issues , localhost and machinename problem r Indigo 0 24 Apr 2008
MetadataResolver gets uri with 'localhost' and not 'machinename' r Indigo 0 24 Apr 2008
using localhost v/s Environment.MachineName DEE Indigo 5 15 Apr 2008
Change IE Settings with Powershell Bernd Wagner PowerShell 2 15 Jan 2008