Powershell script to Register Visual Studio Schemas

I always have to Google how to add an XML schema to Visual Studio because I forget the directory (even though it is super easy). Never again will I forget.

function register-vsschemas()
{
	begin
	{
		$schema_folders = gci $env:ProgramFiles -Filter "Microsoft Visual Studio*" | 
							gci -Filter "Xml" | 
							gci -Filter "Schemas"
	}
 
	process
	{
		if(!$_ -or !(Test-Path $_))
		{
			Write-Error "File '$_' not found"
			break;
		}
		if((gi $_).Extension -ine ".xsd")
		{
			Write-Warning "File $_ does not end in an .xsd extension"
		}
 
		foreach($folder in $schema_folders){
			#It is very interesting I had to use .FullName...
			cp $_ $folder.FullName -Verbose
		}
	}
}

Call it as follows:

gi .\lib\NHibernate\*.xsd | register-vsschemas