0

以下のように VBSCRIPT で配列を使用していました... PowerShell でどのように行うべきかわかりません... 助けてもらえますか...?

CODE --> VBSCRIPT
dim arrErrors(12)
arrErrors(0) = "APP0"
arrErrors(1) = " APP1"
arrErrors(2) = " APP2"
arrErrors(3) = " APP3”
arrErrors(4) = "APP4"
arrErrors(5) = "APP5"
arrErrors(6) = "APP6"
arrErrors(7) = "APP7"
arrErrors(8) = "APP8"
arrErrors(9) = "APP9"
arrErrors(10) = "APP10"
arrErrors(11) = "APP11"
arrErrors(12) = "APP12"
for i = 0 to ubound(arrErrors)
    strError = arrErrors(i)
    if (left(lcase(strErrorLine), len(strError)) = lcase(strError)) then
    objErrorLog.WriteLine strErrorLine & vbTab & strComputer & vbTab & "Found Error number" & vbTab & i
    exit for
    end If 
4

1 に答える 1

2

ハッシュ テーブルを作成します。エラーの名前と値を入力します。エラー文字列を解析し、ハッシュ テーブルに含まれているかどうかを調べます。そのようです、

$htErr = @{ "app0" = 0; "app1" = 1; "app2" = 2 } # Populate hash table
$error = ... # get the error string from somewhere.
if($htErr[$error]) { 
    "Found error, code " + $htErr[$error] # Get code based on error string
} 
于 2012-11-26T08:06:48.343 に答える