DesktopCentral: Rename Computer
-
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.
-
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 = NULLIt sets the item variable, and nulls out username and password
End if
End ifEnd 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.
-
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.