Skip to main content

Posts

Showing posts from July, 2012

Powershell Fun (Key - Value Pairs)

Using Powershell to Import Key-Value Pairs from a file


Given a file named ConfigurationKeyValuePairs.conf with Key Value pairs that looks like: Key^Value
WebsiteHostName^localhost
QueryServiceHostName^localhost
ApplicationServiceHostName^localhost
ReportServerHostName^localhost
ReportServerPort^8080
IncludeExceptionDetailInFaults^true
ICacheServicePort^8050
Compilation.Debug^true   

You can extract these into a powershell variable with the following command:Get-Content .\ConfigurationKeyValuePairs.conf | %{$configurationSettings= @{}} { if ($_ -match "(.*)\^(.*)") { $configurationSettings[$matches[1]]=$matches[2]; }}

The keys can now be referred to using$configurationSettings.Key



References:  http://blogs.msdn.com/b/mwilbur/archive/2007/02/23/powershell-1-liner-key-values-pairs-from-text-file-to-hashtable.aspx

Windows Server 2008 Command-Line Tools Summary

CommandDescriptionArpDisplay and modify the IP to physical address translation tables used by
the Address Resolution Protocol (ARP).AssocDisplay and modify file extension associations.AttribDisplay and change file attributes.BreakConfigure extended Ctrl-C checking.BcdeditConfigure properties in name database to control boot loading. CaclsDisplay or modify access control lists of files.CallCall a script or script label as a procedure.CD/ChdirDisplay the name of or changes the current directory.ChcpDisplay or set the active code page number.ChkdskCheck a disk for errors and display a report.ChkntfsDisplay the status of volumes. Set or exclude volumes from automatic system
checking during system boot.ChoiceCreate a selection list from which users can select a choice in batch
scripts.ClsClear the console window.CmdStart a new instance of the Windows command shell.Color

Scraping HTML Table data into a Google Docs Spreadsheet

Tried something interesting today.

I needed to scrape the Root Zone Database data from the Internet Assigned Numbers Authority (IANA) website at [http://www.iana.org/domains/root/db] .So I imported the data to a google docs spreadsheet and then exported it to a csv as follows:
Create a new Google Docs spreadsheetIn the first row, import the data using the ImportHtml() function with the following syntax [=ImportHtml("http://www.iana.org/domains/root/db","table",0) ] This should now populate the rest of the table with the data from the web page.I can now download the spreadsheet as a csv ( File ⇒ Download as ⇒ Comma Separated Values )