Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Scripting Games 2008 Sudden Death Challenge 5

My Solution for sudden dead event 5  of the 2008 scripting games :

$l = [collections.arraylist][char[]]"ABCDEFGHIJKLMNOPQRSTUVWXY"

$Properties = @()

gwmi -list |% {([wmiclass]$_.name).properties} |

  where {$_.origin -like "win32_*"} |

    select name,origin  |

      foreach {

        if ($l.Contains($_.name[0])) {$Properties += $_;$l.remove($_.name[0])}

      }

$properties | sort name   

A funny one I tought of later :

(gwmi -list |% {([wmiclass]$_.name).properties} |

  where {$_.origin -like "win32_*"} |

    select name,origin | sort -unique {$_.name[0]})[0..24]

Enjoy,

Greetings /\/\o\/\/

Published Tuesday, February 26, 2008 1:32 PM by MoW

Comments

# Scripting Games: Sudden Death Challenge - Event 5 « PowerShell ?? ???????????? ??????????????

# Scripting Games: Sudden Death Challenge - Event 5

Решая эту задачку я совсем забыл про [wmiclass] и использовал вместо него system.management.managementClass…   SD5.ps1 # Объявляем хэш-таблицу. $h = @{} # Получаем список WMI объектов. Get-WmiObject -List | # отбираем только начинающиеся

Friday, March 21, 2008 2:58 AM by PowerShell и другие скрипты
Anonymous comments are disabled