Forum Discussion
Jaime_IT
Jan 05, 2024Brass Contributor
Re: Device Bulk Rename Struggle
So the issue I run into with this suggestion is that Intune does not natively support device renaming based on specific criteria like IPv4 addresses. I've checked Intune 3x, and unless I'm missing something here or you have another suggestion, I'm back to working on a script. Though I think that I can create a more basic script and deploy it to all devices. Something like this:
$ipAddress = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -like '10.1.*' }).IPAddress
if ($ipAddress -ne $null) {
$serialNumber = (Get-WmiObject Win32_BIOS).SerialNumber
$newComputerName = "A-$serialNumber"
Rename-Computer -NewName $newComputerName -Force -Restart
} else {
Write-Host "IPv4 address does not match the criteria. No action taken."
}
Thoughts?
$ipAddress = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -like '10.1.*' }).IPAddress
if ($ipAddress -ne $null) {
$serialNumber = (Get-WmiObject Win32_BIOS).SerialNumber
$newComputerName = "A-$serialNumber"
Rename-Computer -NewName $newComputerName -Force -Restart
} else {
Write-Host "IPv4 address does not match the criteria. No action taken."
}
Thoughts?
7 Replies
- Any update?
- Jaime_ITBrass Contributor
Still a struggle, nothing has really worked. We got a script from a Microsoft engineer, it renamed less than 100 devices, and he's not sure why yet. Pretty lost here and continuing one by one as time permits.
- But are you using a script on the client side which renames the computername or are you trying do to it with Graph?
- Seems ok, but perhaps adding a check if the ComputerName is already correct before changing it again and again 😅 And perhaps checking on dns suffix to avoid computers being renamed incorrectly when at home or when in a network that has the same ip range.
And rebooting the computer... Not nice if your users are in the middle of something, computer name will be renamed after reboot or shutdown by the user or when installing updates that require a reboot.
Also, are you doing this using remediation or from the Scripts lane? Or with a Win32 app, detection method?