Hi,
I am executing a script which gathers Windows server names in the domain, then I use the LOAD DATA LOCAL INFILE to import it into MYSQL. Everything is imported, but the first line has a couple of strange characters in the first row only. The MYSQL table collation is set to utf8_general_ci.
First I get the server names from AD:
$computerdetails = Get-ADComputer -server $dc -Filter {OperatingSystem -Like “Windows Server” } -Property * |`
Select-Object Name, @{N=“DNSHostName”;E={$.DNSHostName.Split(“.”)[1] + “.” + $.DNSHostName.Split(“.”)[2] + “.” + $_.DNSHostName.Split(“.”)[3]}}, OperatingSystem, PasswordLastSet
Then I set the array to the results and create the csv file:
$result += $computerdetails
$result | ConvertTo-Csv | Select -Skip 2 | out-file $winfilename -Encoding UTF8 -force
The results in the table look like this, for an example:
Name DNSHostName OperatingSystem PasswordLastSet
“SERVER1” domainname Windows Whenever
SERVER2 domainname Windows Whenever
So the first row, first column has a couple of funny characters, and the server name is in quotes. All other information is fine.
I have opened this in Notepad++ and checked for characters, of which I see only CRLF at the end of the rows.
Does anyone have any ideas on what might be wrong?
Thanks!