I have the following script where the user is asked for the file server IP address, the IP is entered and the gpreport.xml file modified as needed.
$file_server = Read-Host "Enter the file server IP address" $rootFolder = 'C:\TEMP\GPO\source\5' Get-ChildItem -LiteralPath $rootFolder -Directory | Where-Object { $_.Name -as [System.Guid] } | ForEach-Object { $directory = $_.FullName (Get-Content "$directory\gpreport.xml") | ForEach-Object { $_ -replace "99.999.999.999", $file_server } | Set-Content "$directory\gpreport.xml" # ... etc }
This works well, but I would like to automate it using a reference CVS file. I have 3 columns in my file - FQDN, Server Name and Server IP. I need PowerShell to identify current logged on users domain name ($env:userdnsdomain) and match the result to the CSV file below. Once matched, take the server IP column and insert it into gpreport.xml . This way the user insnt being asked for the Ip address of the $file_server and it's being done automatically.
Thank you.