0

次の Powershell スクリプトがあります。

$a = Get-Content C:\users\diana\desktop\names.txt

snmpwalk -v 2c -c root $a .1.3.6.1.2.1.25.3.3.1.2 > c:\users\diana\desktop\cpu.txt
snmpwalk -v 2c -c root $a .1.3.6.1.2.1.25.5.1.1.2 > c:\users\diana\desktop\ramvid.txt
snmpwalk -v 2c -c root $a .1.3.6.1.2.1.25.2.2 > c:\users\diana\desktop\ram.txt

get-content C:\users\diana\desktop\ramvid.txt | %{ [int]$used+=$_.split(' ')[3]; } ;     echo $used > C:\users\diana\desktop\naujas.txt
get-content C:\users\diana\desktop\ram.txt | %{ [int]$total=$_.split(' ')[3]; } ; echo     $total > C:\users\diana\desktop\ramfiltruotas.txt

[decimal]$b=($used*100)/$total
[math]::floor($b) > C:\users\diana\desktop\naujas2.txt


get-content C:\users\diana\desktop\cpu.txt | %{ [int]$array=$_.split(' ')[3]; }
$c=($array | Measure-Object -Average).average
echo $c > C:\users\diana\desktop\naujas3.txt

[void][system.reflection.Assembly]::LoadWithPartialName(“MySQL.Data”)

$myconnection = New-Object MySql.Data.MySqlClient.MySqlConnection
$myconnection.ConnectionString = "database=db;server=localhost;Persist Security Info=false;user id=root;pwd= "
$myconnection.Open()
$command = $myconnection.CreateCommand()
$command.CommandText = "UPDATE db.server SET (cpu='$c',ram='$b') WHERE server_name like '192.168.95.139'";
$myconnection.Close()

コードの上部はうまく機能しますが、MySQL に関しては何も起こりません。単一のエラーも何もありません。テーブルは更新されません。誰かがここで問題がどこにあるのか教えてもらえますか?

4

1 に答える 1