Closed mozq1to closed 4 years ago
To be honest, I have no clue. The variable expansion should be happening within PowerShell before the request is ever sent to Infoblox. So assuming your $hostname
variable is identical to the hard coded name in the first query, there should be no difference.
Is the hostname variable only the short name rather than the FQDN? Are there any non-ascii characters in the hostname that might be messing with things?
You can try running both commands with the -Verbose
flag to see the actual URL sent to Infoblox. That might highlight the difference.
The CSV file I use in my foreach loop had some servernames written with upper case letters. When I switched to lower case it solved my probelm. Thanks for your response :)
I cant remove objects and i dont really understand the warning, what does it mean? I can manually remove the objects from IB gui. VERBOSE: Removing ore01sd01.internt.domain.se WARNING: "ore01sd01.internt.domain.se" not found in the set of existing profiles.
This is the script im using:
$servers = Import-Csv 'C:\Lokala Filer\LegacyServers.csv' -Header Name
foreach ($server in $servers) {
$hostname = $server.Name.ToLower() + '.internt.domain.se'
$HOSTrec = Get-IBObject 'record:host' -Filters "name=$hostname"
$HOSTrec | Remove-IBConfig -Verbose
}
It looks like you're using the wrong function to delete an object. You've got Remove-IBConfig
when it should be Remove-IBObject
.
Hello! Im trying to list all records that belongs to a list of servers. So im doing this in a foreach loop and the hostname is used with a variable. These two commands gives me results:
This command gives me nothing:
But if write the hostname instead of the variable it gives me a result. How come?