// 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
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
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?
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>
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.