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
 

PC inventory information gatherer v1

I use this script (Powershell) in order to gather information about a PC to be registered in my maintain system inspired on the New Delhi PowerShell User Group and helped by consulting reference on SS64:

$Date = Get-Date -format "yyyyMMdd"
$ComputerName = (Get-Item env:\Computername).Value

$FolderName = $Date + $ComputerName

new-item -path . -name $FolderName -type directory

$ExportFile = ".\" + $FolderName +  "\installedsoft.txt"
Get-WmiObject -ComputerName  $ComputerName -Class Win32_Product | select Name | Out-File $ExportFile

$ExportFile = ".\" + $FolderName + "\licences.html"

.\ProduKey.exe /shtml $ExportFile

$ExportFile = ".\" + $FolderName + "\cpuz"
.\cpuz\cpuz_x32.exe -html= $ExportFile

$ExportFile = ".\" + $FolderName + "\logicalDisk.txt"
Get-WmiObject win32_logicalDisk -ComputerName $ComputerName | select DeviceID,VolumeName,@{Expression={$_.Size /1Gb -as [int]};Label="Total Size(GB)"},@{Expression={$_.Freespace / 1Gb -as [int]};Label="Free Size (GB)"} | Out-File $ExportFile

$ExportFile = ".\" + $FolderName + "\systemInfo.txt"
systeminfo.exe | Out-File $ExportFile

$ExportFile = ".\" + $FolderName + "\mac.txt"
getmac | Out-File $ExportFile

 

It depends on CPUZ and ProduKey executables on the same folder.

Forzar el display language a todos los usuarios

Instalando windows con una copia en inglés y luego instalando el paquete de idioma español, por defecto al crear usuarios aparece como lenguaje el inglés, incluso especificando en las opciones regionales y de idioma, tanto los mensajes e interfaces de Windows como los menús de Internet Explorer aparecen en inglés. Para solventarlo, usando políticas de grupo se especifica que el idioma de interfaz sea el español:
gpedit.msc
Ir a Configuración del equipo>Plantillas administrativas> Panel de control>Configuración regional y de idiomas > Limta los idiomas de la interfaz de usuario que Windows usa para todos los usuarios que hayan iniciado sesión.

Activar la directiva y eligiendo en las opciones Limitar usuarios al siguiente idioma: Español

Importando el archivo de datos y autocompletado de contactos en Outlook 2010

Outlook, en su versión 2010 ha cambiado la localización de almacenamiento de sus archivos de datos (PST), siendo ahora localizados en Documents\Outlook Files. Otro cambio es que no basta copiar el archivo Outlook.nk2 a la ruta %appdata%\Microsoft\Outlook para recuperar La lista de Autocompletar de contactos al escribir en el campo «Para:» sino que para que se haga efectiva la importación, luego de la copia del archivo hay que ejecutar Outlook con el modificador /importnk2:

outlook.exe /importnk2

Referencias:

  1. http://support.microsoft.com/kb/980542
  2. http://office.microsoft.com/en-us/outlook-help/where-does-microsoft-outlook-2010-save-my-information-and-configurations-HP010354943.aspx