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 05, 2024Brass Contributor
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?
Jan 06, 2024
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?
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?