Add the following action to asset pages:
{actionpath}Change_Computer_Name.vbs {computer}
Then create a file called "Change_Computer_Name.vbs" and place this in it:
(replace YOUR-SERVER-NAME-HERE with your actual lansweeper server)
strCurrentPCName = WScript.Arguments(0)
If strCurrentPCName = "" Then
Wscript.Quit
End If
strNewName = Inputbox("New Computer Name:","Enter the new name for this computer","")
If IsEmpty(strNewName) or IsNull(strNewName) Then
Wscript.Quit
Else
Dim cmd,shell,executor,ps1result,strResult
cmd = "powershell.exe -ExecutionPolicy Bypass -noprofile -command \\YOUR-SERVER-NAME-HERE\lansweeper$\Change_Computer_Name.ps1 '" & strCurrentPCName & "' '" & strNewName & "'"
Set shell = CreateObject("WScript.Shell")
Set executor = shell.Exec(cmd)
executor.StdIn.Close
ps1result = executor.StdOut.ReadAll
strResult = Trim(ps1result)
If IsEmpty(strResult) or IsNull(strResult) Then
Else
Msgbox "Update requested. The changes will take effect after you restart the computer."
End If
End If
Then also create a file called "Change_Computer_Name.ps1" and place this in it:
$strCurrentPCName = $args[0]
$strNewPCName = $args[1]
$Credentials = Get-Credential -Message "Enter your Windows admin credentials"
Rename-Computer -ComputerName $strCurrentPCName -NewName $strNewPCName -DomainCredential $Credentials -Force
Then place "Change_Computer_Name.vbs" and "Change_Computer_Name.ps1" in your Lansweeper actions folder.