Created
January 31, 2016 15:47
-
-
Save MattHodge/587a5b2c622a71beba0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Short description | |
.DESCRIPTION | |
Long description | |
.EXAMPLE | |
Example of how to use this cmdlet | |
.EXAMPLE | |
Another example of how to use this cmdlet | |
#> | |
function Get-MPHubot | |
{ | |
[CmdletBinding()] | |
[Alias()] | |
[OutputType([string])] | |
Param | |
( | |
# Param1 help description | |
[Parameter(Mandatory=$true)] | |
$name | |
) | |
# Create a hashtable for the results | |
$result = @{} | |
try | |
{ | |
$template = @' | |
<TD class=sortable><A href="{url*:http://www.microsoft.com/en-us/download/details.aspx?id=23024}" target=_blank>{name:Application Virtualization 4.5 (APP-V)}</A></TD> | |
<TD class=ra>{version:4.5.0.0}</TD> | |
<TD class=ra>{date:10/09/2008}</TD></TR> | |
<TD class=sortable><A href="{url*:http://www.microsoft.com/en-us/download/details.aspx?id=38418}" target=_blank>{name:Application Virtualization Server 5.0 (APP-V)}</A></TD> | |
<TD class=ra>{version:1.0}</TD> | |
<TD class=ra>{date:04/12/2013}</TD></TR> | |
<TD class=sortable><A href="{url*:https://www.microsoft.com/en-in/download/details.aspx?id=45884}" target=_blank>{name:BizTalk Server 2013 R2}</A><BR></TD> | |
<TD class=ra>{version:7.0.2008.0}<BR></TD> | |
<TD class=ra>{date:02/19/2015}<BR></TD></TR> | |
<TD class=sortable><A href="{url*:http://www.microsoft.com/en-us/download/details.aspx?id=11872}" target=_blank>{name:Dynamics AX 2009}</A></TD> | |
<TD class=ra>{version:1.0.0.50}</TD> | |
<TD class=ra>{date:06/16/2009}</TD></TR> | |
<TD class=sortable><A href="{url*:http://www.microsoft.com/en-us/download/details.aspx?id=46832}">{name:Windows Server Storage Spaces 2012 R2}</A></TD> | |
<TD class=ra> | |
<P>{version:1.1.253.0}</P></TD> | |
<TD class=ra> | |
<P>{date:04/27/2015}</P></TD></TR> | |
<TD class=sortable><A href="{url*:http://www.microsoft.com/en-us/download/details.aspx?id=49101}" target=_blank>{name:Windows Azure Pack (WAP) Update 1}</A><BR></TD> | |
<TD class=ra>{version:1.0.0.466} <BR></TD> | |
<TD class=ra>{date:09/16/2015} <BR></TD></TR> | |
'@ | |
#Load data from MP Wiki website | |
$uri = 'http://social.technet.microsoft.com/wiki/contents/articles/16174.microsoft-management-packs.aspx' | |
$site = Invoke-WebRequest -Uri $uri | |
$rows = $site.AllElements | Where-Object { $_.tagName -eq 'TR' } | |
$packs = $rows.innerHTML | ConvertFrom-String -TemplateContent $template -ErrorAction SilentlyContinue | |
$matchingPacks = $packs | Where-Object { $_.name -like "*$($name)*" } | |
$resultstring = @() | |
if ([string]::IsNullOrEmpty($matchingPacks)) | |
{ | |
# Nothing found but still considered successful | |
$result.success = $true | |
$result.output = "MP $($Name) does not exist on MPWIKI." | |
} | |
else | |
{ | |
$result.output = "Management Packs Found: `n" | |
# Loop through any matches | |
ForEach ($mp in $matchingPacks) | |
{ | |
$result.output += "*$($mp.name)* `n> Date: $($mp.date) `n> Version: $($mp.version) `n> URL: $($mp.url)`n" | |
} | |
$result.success = $true | |
} | |
} | |
catch | |
{ | |
# If this script fails we can assume the service did not exist | |
$result.output = "Exception $($_.Exception.Message)" | |
# Set a failed result | |
$result.success = $false | |
} | |
# Return the result and conver it to json | |
return $result | ConvertTo-Json | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment