Have you tried Setting your inactive users to a variable, and using that to loop? I’ve not used Search-ADAccount so I don’t know what kind of object it spits out, but at the very least, you should be able to get some unique information from each user you get back to use with Set-ADUser: Set-ADUser (ActiveDirectory) | Microsoft Learn. However, the AD Module is extremely well built so I would expect it to output a Microsoft.ActiveDirectory.Management.ADAccount object. If that’s the case, you likely can just feed it directly into Set-ADUser via the PowerShell pipeline directly into Set-ADUser like this:
Set-ADUser will allow you to update the Office phone. I am pretty sure it will accept $null and null that field out. You don’t have to set it equal to a variable, but I personally do, so I can go look at what accounts are scope prior to actually making a change. On that topic a couple words of caution:
Test. Test. Test. This is pretty low stakes probably, but test! If you have a whole test environment, that’s a great way to do it against a lot of accounts. However, If you have a test account, try it on that first. I’ve seen people get bit by an ask and they think it does one thing and it does another. Again ,this seems pretty low stakes but it’s a good practice to do it anyway!
Definitely look through the output of Search-ADAccount to make sure it’s what you expect.
Try this on one or a small subset of users first to ensure it works as expected. Again this is just a another level of testing. You can access a single object by using the index . $InactiveUsers[0] would access the first ‘object’ that is returned.