我可以帮你进行翻译。以下是翻译的结果,保留了HTML标签。
我有一个.ps1 PowerShell脚本在Windows上执行,但我的所有数据都在Linux服务器上,是否有可能以某种方式在Red Hat服务器上执行PowerShell脚本?
PowerShell脚本如下:
Clear-Host
$path="D:\Deep Backup 26-04-2013\New folder"
$systemname=Read-Host 'Enter System Name'
$files=Get-ChildItem $path -Recurse -Force -Include *_Registrar.zip*,*.reg.zip*
$counter=1
foreach($file in $files)
{
$name=$file.name
[void][system.reflection.Assembly]::LoadFrom("C:\Program Files\MySQL\MySQL Connector Net 6.5.4\Assemblies\v2.0\MySql.Data.dll")
$dbconnect=New-Object MySql.Data.MySqlClient.MySqlConnection
$dbconnect.ConnectionString="server=localhost;userid=root;password=nPr123*;database=test3;"
$dbconnect.Open()
$sql="insert into eid values('"+$name + "','"+$systemname+"')"
$command=new-object MySql.Data.MySqlClient.MySqlCommand($sql,$dbconnect)
$command.ExecuteNonQuery()
}
$sql="insert into eid_unique
select distinct Packet_name, System_name from eid a
where not exists (select 1 from eid_unique b
where a.Packet_name=b.Packet_name);"
$command=new-object MySql.Data.MySqlClient.MySqlCommand($sql,$dbconnect)
$command.ExecuteNonQuery()
$dbconnect.close()