ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    DesktopCentral: Rename Computer

    IT Discussion
    3
    3
    351
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gjacobseG
      gjacobse
      last edited by gjacobse

      Since we have a mash of computer names in the domain, it was questioned how we can change the computer name - and as we are using Desktop Central - match names.

      A quick search did find that DesktopCentral has a script in the repository to do just such a thing, only it's in VBS which I haven't spent any time in.

      'It is recommended to test the script on a local machine for its purpose and effects. 
      'ManageEngine Desktop Central will not be responsible for any 
      'damage/loss to the data/setup based on the behavior of the script.
      
      
      'Description - Script to change computer name of the local machine.
      'Parameters - New computer name, Username and password
      ' ex: "newcomputername" "domain\username" "password"
      'Remarks - For domain machine username must be in the form domain\username
      'For Workgroup machine only new name needs to be passed.
      'Configuration Type - COMPUTER
      '==============================================================
      
      if WScript.Arguments.Count = 3 Then
      Name = WScript.Arguments.Item(0)
      Username = WScript.Arguments.Item(1)
      Password = WScript.Arguments.Item(2)
      Else if WScript.Arguments.Count = 1 Then
      Name = WScript.Arguments.Item(0)
      Username = NULL
      Password = NULL
      End if
      End if
      
      Set objWMIService = GetObject("Winmgmts:root\cimv2")
      
      ' Call always gets only one Win32_ComputerSystem object.
      For Each objComputer in _
          objWMIService.InstancesOf("Win32_ComputerSystem")
      
              Return = objComputer.rename(Name,Password,Username)
              
      
      Next
      Wscript.Quit Return
      

      Any pointers on how to read this so that I have idea of how to move forward.. My first thought was to use Poweshell, but since Remote Powershell is disabled - have to use what is available to me still.

      DashrenderD 1 Reply Last reply Reply Quote 0
      • DashrenderD
        Dashrender @gjacobse
        last edited by

        if WScript.Arguments.Count = 3 Then

        checks to see if there are three arguments on the execution line

        Name = WScript.Arguments.Item(0)
        Username = WScript.Arguments.Item(1)
        Password = WScript.Arguments.Item(2)

        If there are three, it sets these three variables

        Else if WScript.Arguments.Count = 1 Then

        If there is 1 argument,

        Name = WScript.Arguments.Item(0)
        Username = NULL
        Password = NULL

        It sets the item variable, and nulls out username and password

        End if
        End if

        End of the If/Then statements

        Set objWMIService = GetObject("Winmgmts:root\cimv2")

        ' Call always gets only one Win32_ComputerSystem object.
        For Each objComputer in _
        objWMIService.InstancesOf("Win32_ComputerSystem")

           Return = objComputer.rename(Name,Password,Username)
        

        Runs through the list of objwmiservice (and there is a comment that says there's always only one) and then changes the name and sends it back to the object variable.

        Next

        looks to see if there is another computername in the variable, if not exit

        Wscript.Quit Return

        I think this pushes the value back into WMI and quits the script. - this part I'm not completely sure of.

        1 Reply Last reply Reply Quote 0
        • IRJI
          IRJ
          last edited by

          You still should be able to run powershell via manage engine Desktop Central. https://www.manageengine.com/products/desktop-central/powershell-script-as-a-package.html

          It looks like you can run locally leveraging Desktop Central. You aren't doing powershell remoting.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post