I had to change option 150 (Cisco VoIP) for multiple scopes across multiple servers as we are moving our Call Manager to a new location this weekend, and couldn’t be bothered doing it manually post move.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$DHCPServers="server1","server2","server3" $OldIP = "10.xxx.xxx.xxx" $NewIP = "192.xxx.xxx.xxx" foreach ($DHCPServer in $DHCPServers) { Get-DhcpServerv4Scope -ComputerName $DHCPServer | where Name -match "Voice|VoIP|VOICE" | %{ $ScopeID = $_.ScopeId $ScopeOption = Get-DhcpServerv4OptionValue -ComputerName $DHCPServer -ScopeId $_.ScopeId -Option 150 $OldValue = $ScopeOption.Value $NewValue = $OldValue -replace $oldIP,$NewIP Set-DhcpServerv4OptionValue -ComputerName $DHCPServer -ScopeId $_.ScopeId -Option 150 -Value $NewValue } } |
All my voice scopes have the word Voice or VoIP in them so I match on them. A lot of the code is verbose coz I like to be a bit verbose, but you could probably crunch it all down to a single line or two. :)