Forum Discussion
Automatically configure Windows Autopilot device names using a CSV File
Hi Harm
Please see the info from the log file.
I have amended some info so not CORP & Network is shared publicly.
I am running the with domain admin rights.
Sorry for the delay.
**********************
Windows PowerShell transcript start
Start time: 20250210134316
Username: [REDACTED]\[REDACTED]
RunAs User: [REDACTED]\[REDACTED]
Configuration Name:
Machine: [COMPUTER_NAME] (Microsoft Windows NT 10.0.26100.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 11888
PSVersion: 5.1.26100.2161
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.26100.2161
BuildVersion: 10.0.26100.2161
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\log\log.txt
PS C:\Users\[REDACTED]> if (((Get-WmiObject win32_SystemEnclosure).smbiosassettag -ne $env:COMPUTERNAME)) {
Rename-Computer -NewName ((Get-WmiObject win32_SystemEnclosure).smbiosassettag) -Verbose
}
VERBOSE: Performing the operation "Rename-Computer" on target "[COMPUTER_NAME]".
Rename-Computer : Fail to rename computer '[COMPUTER_NAME]' to '[NEW_COMPUTER_NAME]' due to the following exception: Access is
denied.
At line:2 char:9
+ Rename-Computer -NewName ((Get-WmiObject win32_SystemEnclosur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: ([COMPUTER_NAME]:String) [Rename-Computer], InvalidOperationException
+ FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand
Rename-Computer : Fail to rename computer '[COMPUTER_NAME]' to '[NEW_COMPUTER_NAME]' due to the following exception: Access is
denied.
At line:2 char:9
+ Rename-Computer -NewName ((Get-WmiObject win32_SystemEnclosur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: ([COMPUTER_NAME]:String) [Rename-Computer], InvalidOperationException
+ FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand
PS C:\log\[REDACTED]> stop-transcript
**********************
Windows PowerShell transcript end
End time: 20250210134322
**********************
Are your devices Hybrid Joined or not? This should work if you run it as SYSTEM from Intune if the device is Entra Joined. If the device is Hybrid Joined, you mentioned the term "Domain Admin," which makes me think it is... Then you should try an approach like this https://github.com/mtniehaus/RenameComputer ((more info here: https://oofhours.com/2023/10/26/renaming-autopilot-deployed-devices/)
- UpNorthIntuneFeb 12, 2025Iron Contributor
Hi Harm,
I am trying this method today.
Hopefully it does the trick.🤞
I will let you know the outcome asap.
- UpNorthIntuneFeb 10, 2025Iron Contributor
Yes, its Hybrid joined.
Thanks for the link, will take a look and report back asap.