Home > Powershell > Powershell – (Get-virtual).info – RSS Capture with Powershell through a proxy

Powershell – (Get-virtual).info – RSS Capture with Powershell through a proxy

a little geekery . . .

As the blog is called ‘Get-Virtual’  . .I figure we may as well have a cmdlet / function to allow us to actually get the content of get-virtual . . . so I quickly put together an RSS reader to capture the RSS feed for the blog and export it to a GridView

The function is not entirely useless, as it will demonstrate 6 new things
1 – Using Powershell to get info from the web
2 – Accessing the web from Powershell through a proxy
3 – Authenticating through the proxy using Powershell
4 – Reading an RSS feed using Powershell
5 – Exporting a Powershell object to a GridView
6 – Reading / Parsing XML using Powershell

Exporting the info captured into a GridView makes it easy to filter the data and view what the latest posts etc are.

I have hashed a little ‘replace’ code out in the script as several of the older Get-virtual.info posts had special characters that get misinterpreted . . so you could remove the hashes to clean this up if you really wanted.

here is the code:

function get-virtual 
	([string]$proxyserver = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"  | %{$_.ProxyServer}),
	{	$proxy = new-object System.Net.WebProxy $proxyserver
		If ($auth)
			{if (!$proxycred) 
			{$proxycred = Get-Credential}
			$proxy.credentials = $proxycred.GetNetworkCredential()
		$WebClient = New-Object System.Net.WebClient
		$webclient.proxy = $proxy
		$WebClient = Get-WebClient
        $blog =  1$Webclient.DownloadString("http://feeds.feedburner.com/PsCget-virtualinfo")
		$obj = @() # New-Object psobject
		for ($i=1; $i -le $blog.rss.channel.item.count; $i = $i + 1)
		$rep = "" | select "Title", "Link", "Creator", "Date"
		$rep."Title" = ($blog.rss.channel.item[$i].title)#.toString().replace("`â`€`“","-").replace("`â`€`˜","`"").replace("`â`€`™","`"")
		$rep."Link" = ($blog.rss.channel.item[$i].Link)#.toString().replace("`%e2`%80`%98","`'").replace("`%e2`%80`%99","`'").replace("","")
		$rep."Creator" = $blog.rss.channel.item[$i].Creator
		$rep."Date" = $blog.rss.channel.item[$i].PubDate
		$Obj += $Rep
		$obj | Out-GridView -Title "Get-Virtual.info Fat(ish) client"
		return $obj


and here is the result:

  1. No comments yet.
  1. January 28th, 2015 at 04:45 | #1
You must be logged in to post a comment.