Greetings,
So I'm in a bit of a pickle trying to update the registry with PowerShell. I need to go into a key, list it's sub keys, and update a value in all of the subkeys on local machine. Reason this is being done with PowerShell, is it has to be pushed out to 80 machines...so nobody wants to do it manually 80 times
The script (scrounged off the internet) I've been beating on all afternoon is below, it will open the key and list the values I'm after … But I cannot get it to update them. Note: the updated value is/will be based on the current value. So I'm looking for a get/replace/set type of operation on the HostName entry's value which is an IP address.
$registry = Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports" -Recurse
foreach ($a in $registry) {
($a | Get-ItemProperty).Psobject.Properties |
#Exclude powershell-properties in the object
Where-Object { $_.Name
-like 'HostName' } | Select-Object Name, Value
}
So instead of displaying the HostName entry's value, I need it to change the third octet of the IP address to a 4 so that 192.168.1.152 becomes 192.168.4.152
Anybody smarter than I am got a bit of mercy handy for a tired old fool?
TIA
-Stoic Joker