#
# Dit script haalt de laatste acht headlines van Tweakers.net op
# en geeft ze met een samenvatting weer in de browser
#
function Show-HTML ($html) {
$ie=New-Object -ComObject InternetExplorer.Application
$ie.menubar=0
$ie.toolbar=0
$ie.statusbar=0
$ie.navigate("about:blank")
$ie.document.body.innerHtml = $html
$ie.visible="true"
}
$rssUrl = "http://tweakers.net/feeds/nieuws.xml/direct"
$feed= [xml](new-object System.Net.WebClient).DownloadString($rssUrl)
$resultaat = $feed.rss.channel.item | select title,description -first 8 | ConvertTo-Html -title "Laatste headlines van Tweakers.net"
Show-HTML($resultaat)
# Author: Marcel Ortiz
# Modified by: Sung Kim
# Deze functie berekent de MD5-hash van een opgegeven bestand
#
function Get-MD5 {
param([System.IO.FileInfo] $file)
begin {
function DisplayUsage {
$private:UsageString = 'USAGE: Get-MD5 [System.IO.FileInfo]`n'
$private:UsageString += 'Examples:`n'
$private:UsageString += '1) Get the MD5 bytes for the specified argument`n'
$private:UsageString += '`tGet-MD5 (Get-Item file_name)`n'
$private:UsageString += '2) Get MD5 bytes for pipeline input`n'
$private:UsageString += '`tls | Get-MD5`n'
$private:UsageString += '3) How to check(a quick way) if two files have same MD5 hash values`n'
$private:UsageString += '`tif (Compare-Object (get-md5 (gi fileName1)) (get-md5 (gi fileName2))) `n'
$private:UsageString += '`t{ "different" } else { "same" }'
Write-Host -ForegroundColor "White" $private:UsageString
}
function ComputeHash([System.IO.FileInfo]$fileInfo) {
$PRIVATE:stream = $null;
# A type Shortcut for MD5CryptoServiceProvider type
# Reference: http://blogs.msdn.com/powershell/archive/2006/07/12/663540.aspx
$PRIVATE:cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider];
$PRIVATE:hashAlgorithm = new-object $PRIVATE:cryptoServiceProvider
$PRIVATE:stream = $fileInfo.OpenRead();
$PRIVATE:hashByteArray = $PRIVATE:hashAlgorithm.ComputeHash($PRIVATE:stream);
$PRIVATE:stream.Close();
# We have to be sure that we close the file stream
# if any exceptions are thrown.
trap {
if ($PRIVATE:stream -ne $null) {
$PRIVATE:stream.Close();
}
break;
}
return $PRIVATE:hashByteArray;
}
}
process {
if ($_ -is [IO.FileInfo]) {
ComputeHash($_)
}
}
end {
# Check if "-?", "-h" or "-help" argument has been passed
if ($args[0] -match '-(\?|(h|(help)))') {
DisplayUsage
return;
}
if ($file) {
ComputeHash($file)
}
trap {
DisplayUsage;
break;
}
}
}