Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Скриптовые языки администрирования Windows (http://forum.oszone.net/forumdisplay.php?f=102)
-   -   Powershell. Key Management Service Report (http://forum.oszone.net/showthread.php?t=277538)

KATOCHIMOTO 11-02-2014 17:17 2307343

Powershell. Key Management Service Report
 
Имеется вот такой скрипт (есть в интернете):

Цитата:

Get-WmiObject -class Win32_NTLogEvent -computerName $RemoteComputerName -filter "Logfile='Key Management Service' And EventCode=12290" | foreach-object {

$_ | Add-Member noteproperty "Return Code" $_.InsertionStrings[1]
$_ | Add-Member noteproperty "Minimum Count To Activate" $_.InsertionStrings[2]
$_ | Add-Member noteproperty Machine $_.InsertionStrings[3]
$_ | Add-Member noteproperty "Client Machine ID" $_.InsertionStrings[4]
$_ | Add-Member noteproperty "Client Time" $_.InsertionStrings[5]
$_ | Add-Member noteproperty "VM Info" $_.InsertionStrings[6]
$_ | Add-Member noteproperty "Licensing Status" $_.InsertionStrings[7]
$_ | Add-Member noteproperty "Time to Expiration, min" $_.InsertionStrings[8]
$_ | Add-Member noteproperty "Activation ID" $_.InsertionStrings[9]

write-output $_ | select-object RecordNumber, Machine, "Return Code", "Minimum Count To Activate", "Client Machine ID", "Client Time", "VM Info", "Licensing Status", "Time to Expiration, min", "Activation ID"
}
выводит инфу вот так
Цитата:

RecordNumber : 16002
Machine : C-DC1.contoso.com
Return Code : 0x0
Minimum Count To Activate : 5
Client Machine ID : *******-***-***-***-*******
Client Time : 2014/02/10 15:52
VM Info : 1
Licensing Status : 1
Time to Expiration, min : 249120
Activation ID : ******-****-*****-****-******
Значения он берет из журнала событий. Как сделать что бы выдаваемое значения в VM Info вместо 1, было- Virtual machine, а если 0 то Phisical Machine ? и License Status в зависимости от 0 до 4 выдало не цифру а Licensed status:
0 -Unlicensed
1 - Licensed
2 - Out-Of-Box Grace Period
3 - Out-Of-Tolerance Grace Period
4 -Non-Genuine Grace Period

Kazun 11-02-2014 17:31 2307347

Код:

$pc = @{1="Virtual machine";0="Phisical Machine"}

PS > $pc[1]
Virtual machine
PS > $a | Foreach {$pc[$_."VM Info"]}
Virtual machine

Код:

$lic = @{0="Unlicensed";1="Licensed";3="Out-Of-Tolerance Grace Period";4="Non-Genuine Grace Period"}

KATOCHIMOTO 12-02-2014 10:19 2307697

а как бы его в код вставить ?
Я не совсем хорошо разбираюсь.

Kazun 12-02-2014 15:20 2307874

Код:

$pc = @{1="Virtual machine";0="Phisical Machine"}
$lic = @{0="Unlicensed";1="Licensed";3="Out-Of-Tolerance Grace Period";4="Non-Genuine Grace Period"}

Get-WmiObject -class Win32_NTLogEvent ...... | Foreach {
        ..........
        $_ | Add-Member noteproperty "VM Info" $pc[[int]$_.InsertionStrings[6]]
        $_ | Add-Member noteproperty "Licensing Status" $lic[[int]$_.InsertionStrings[7]]
        .......
}



Время: 20:32.

Время: 20:32.
© OSzone.net 2001-