How to add Windows firewall rules with Powershell

This example adds port rules and an application rule for UltraVnc, after making a backup of firewall’s configuration:

$date = Get-Date -format "yyyyMMdd"
  
$exportfilename = "C:\temp\"+ $date + "WFconfiguration.wfw"
netsh advfirewall export $exportfilename
netsh advfirewall firewall add rule name="VNC1" dir=in action=allow protocol=TCP localport=5900
netsh advfirewall firewall add rule name="VNC2" dir=in action=allow protocol=TCP localport=5800
netsh advfirewall firewall add rule name="UltraVNC" dir=in action=allow program="C:\Program Files (x86)\uvnc bvba\UltraVnc\winvnc.exe"

Reference:http://www.windowsitpro.com/article/windows-server/windows-firewall-netsh-commands-142324

Import mybucket.co bookmarks via API

I’m starting using mybucket.co as my bookmarking solution due it simplicity, intensive and easy use of tagging and easy to use API apart other features. So my first issue is a way to import all my existing bookmarks in my browser to mybucket and I coded this ruby script that parses a html file extracting urls which are uploaded to mybucket auth by api key

require "uri"
require "net/http"

bookmarks_file_name = 'bookmarks.html'
mybucket_api_key = '[api_key for your bucket]'

  class Bookmark 
	def url
	   @url
	end 
	def url=(url)
	    @url = url
	end
	def title
	   @title
	end 
	def title=(title)
	    @title = title
	end
  end

File.open(bookmarks_file_name, 'r') do |f|
bookmarks =[]
  while line = f.gets
	singlebookmark = Bookmark.new
	urlmatch = line.match(/<a href="([^" titlematch="line.match(/([^" )="" ]*)?="">]*)<\/A>/)
    if urlmatch
	    singlebookmark.url = urlmatch[1].to_s
		singlebookmark.title = titlematch[1].to_s
		bookmarks << singlebookmark
    end
  end
  
bookmarks.each do |b|
  params = {'api_key' => mybucket_api_key,
			'href' => b.url,
			'source' => '',
			'type' => '',
}
	x = Net::HTTP.post_form(URI.parse('http://mybucket.co/submit'), params)
	puts x.body
    puts "Added link: #{b.url}"	
  end 
  puts "--Summary:--"
  puts "File - #{bookmarks_file_name}"
  puts "Number of bookmarks - #{bookmarks.count}"
 end