
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2022 08:19 AM - last edited on ‎04-01-2024 04:10 PM by Mercedes_O
Hello, I am looking for action which would help me rename computers in network. The perfect solution would be rename computer by Custom field(we have "Inventory number"), so we can identify these computers easier and have everything organized. I think this can't be done automatically, so at least pop up should open with input area, and I can submit new computer name.
Thank you in advance,
Dovydas
- Labels:
-
API & Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2022 03:44 AM
{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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 09:07 PM
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/rename-computer?view=powershell-7.2
Example 2 is likely what you'd be looking for. Combine that with ShellRunAs if you're not running as a Domain Admin.
I'm not certain how to prompt for input directly out of Lansweeper, so might have to just use Read-Host in the script.
