Rename computer fixlet for windows 10 machine already on the domain

https://www.bigfix.me/fixlet/details/1393

Hi All, above link is for the fixlet to rename computer name on xp and 7 but it does not work on Windows 10 machines already on the domain.

I need help configuring it to rename computer which is already on the domain. Please help.

I tried to run above fixlet and also tried to put the command in powershell with jgstew’s powershell template example shown below.

Fixlet from jgstew: https://bigfix.me/fixlet/details/3860

// Disable wow64 redirection on x64 OSes
action uses wow64 redirection {not x64 of operating system}

delete __createfile

//    CREATEFILE
createfile until END_OF_FILE

# REPLACE THE FOLLOWING WITH THE SCRIPT YOU WANT TO RUN ON THE ENDPOINT
rename-computer -computername $env:computername –newname CHIDRB07

END_OF_FILE

delete powershell.ps1
move __createfile powershell.ps1

waithidden { pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry) } -ExecutionPolicy Bypass -File powershell.ps1

Fixlet runs and Fails with below action details:

Completed //ask admin for name of new computer 
Completed action parameter query "newComputerName" with description "Please enter the new Computer Name (Ex: Daniel-PC):" and with default value "" 
Completed //use WMI to change the name 
Completed waithidden wmic ComputerSystem where "name='%ComputerName%' call rename {parameter "newComputerName" as string} 
Failed continue if {exit code of action = 0} 
 //flag action as requiring a restart 
 action requires restart 

@JasonWalker @jgstew @AlexaVonTess

When I create a fixlet for this, I put in a domain service account since the local system account wouldn’t have permissions within AD to change the name:

// Disable wow64 redirection on x64 OSes
action uses wow64 redirection {not x64 of operating system}

action parameter query "ServerName" with description "Please enter the New Server Name" with default value "New Server Name"

delete __createfile

//    CREATEFILE
createfile until END_OF_FILE

$bfuser = '{parameter "secret" of action}'
$bfpass = '{parameter "secret2" of action}'
$password = $bfpass | ConvertTo-SecureString -AsPlainText -Force

$Credential = New-Object System.Management.Automation.PsCredential -ArgumentList $bfuser, $Password

Rename-Computer -NewName "{parameter "ServerName"}" -DomainCredential $Credential -Force
END_OF_FILE

delete powershell.ps1
move __createfile powershell.ps1

waithidden { pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry) } -ExecutionPolicy Bypass -File powershell.ps1

@cjwolford

Sir! Thank you so much for sharing your Fixlet with me.

I replace secret and secret 2 with my domain id and password but it failed.
Can you please tell me what changes I need to make in this to make it work for me?

Do I need to put the domain name in the username field?

Sorry I’m new to all of this.

Thank you.

those are called secret parameters in BigFix.

They’re basically coded in the description to hide them in the console. Here’s a link that discusses it.

The basic steps would be to export the fixlet you’ve created, and then edit it in VS Code or Notepad++ or whatever you use.

In the Description field you’d add the username and password:
<Description><![CDATA[Rename Server joined to Active Directory (Secure) <script> document.body.ontakeaction = function() { TakeSecureFixletAction( Relevance('id of current fixlet'), Relevance('id of current bes site'), "Action1", {}, {secret: 'domainaccount' , secret2: 'domainpassword' } ); return false; } </script> ]]></Description>

Thank you so much! I really appreciate your help.

After adding description, it was a success. And I learned a few new things today too.

You have a great day my friend.

Hi ,

I saw your powershell script to rename the domain added computer . is there any other way to change the name please share me because in my environment powershell was blocked.

Regards,
Sekar D

Have you tried WMIC?

WMIC computersystem where caption=‘current_pc_name’ rename new_pc_name

You could inbed this in an actionscript and leverage relevance substitution.

It would be something like

waithidden WMIC.exe computersystem where caption ='{computer name} rename new_pc_name

2 Likes

Hi Jared,

Thanks for your reply, I tried this already but domain PCs renaming not happened.