Hello,
I have a powershell script (below) which works fine when I ask it to look up IP addresses.. The only criteria I have changes is for it to match the hostname field in the CSV opposed to the IPAddress.
The $Source contains hostnames like:
10000L
10001L
10002L
etc
Now the CSV Has the hostnames as 10002L.domain.co.uk
It only seems to match anything which has a blank hostname. I have pulled the hostname list directly from AD so I know there are no typing errors when matching and the DHCP information again directly from DHCP.
If I ask it to just write out the $_.HostName it gives me a list so I know its pulling information from the CSV file.
Does anyone know why its not matching?
$Source = Get-Content "C:\Temp_Storage\ip.txt" Import-Csv 'C:\Temp_Storage\DHCP_Reservations.csv' | where{$Source -Match $_.HostName} | Select-Object IPAddress, HostName | Export-Csv "C:\Temp_Storage\Matches.csv" -NoTypeInformation
Thanks