Forum Discussion
Jaime_IT
Dec 21, 2023Brass Contributor
Device Bulk Rename Struggle
We've struggled with this for quite some time now. What we need to do is, discover all Intune devices with one of the following elements true: 10.1.x.x IP address 10.111.x.x IP address Then re...
Jaime_IT
Jan 04, 2024Brass Contributor
Interesting. Not the Microsoft recommended process, yet it seems completely plausible.
I'll investigate this suggestion and get back to you. Thanks!
Jan 04, 2024
Let us know! This is what I used to rename the computer based on Asset Tag (replaced value with XXX to avoid mentioning customer name)
if ($env:COMPUTERNAME -notmatch 'XXX') {
if (((Get-WmiObject win32_SystemEnclosure).smbiosassettag -ne $env:COMPUTERNAME)) {
Rename-Computer -NewName ((Get-WmiObject win32_SystemEnclosure).smbiosassettag)
}
}
- Jaime_ITJan 06, 2024Brass ContributorSo 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?- Jan 23, 2024Any update?
- Jaime_ITMar 04, 2024Brass 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.
- Jan 06, 2024Seems 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?