Hello everybody,
the script was make for a Windows server 2012 and is use to export a lease from a DHCP in a MySQL database
i would know when is a possibility to convert this script to use him of a server 2008 R2 ?
{[void][System.Reflection.Assembly]::LoadWithPartialName("MySql.Data")
$connectionString = "server=localhost;uid=user;pwd=user;database=arpwatch;Allow User Variables=true;Pooling=false;"
$connection = New-Object MySql.Data.MySqlClient.MySqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()
Get-DhcpServerv4Lease -ScopeId 192.168.0.0 -ComputerName winserver |
Select-Object -Property ClientId, IPAddress |
Export-Csv -NoTypeInformation -Path C:\Users\Administrateur\mysql.csv
$sql = @'
LOAD DATA LOCAL INFILE 'C:\\Users\\Administrateur\\mysql.csv'
INTO TABLE dhcp
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
'@
$command = New-Object MySql.Data.MySqlClient.MySqlCommand($sql, $connection)
$rowsAffected = $command.ExecuteNonQuery();
$connection.Close()}
Thanks for your helping