Alternative for Invoke-SqlCmd

Invoke-SqlCmd ist a great cmdlet for PowerShell for querying SQL databases. But sometimes you don’t want to install the extra requirement SQL Server Management Objects on the server.

Invoke-SqlCmd -ServerInstance $Server -Database $Database -Query "SELECT * FROM Staff"

There’s an simple alternative. Use the .NET classes in the System.Data.SqlClient namespace which are available on every computer which has the .NET framework installed.

function SqlQuery($server, $database, $query)
{
 $connection = New-Object System.Data.SqlClient.SqlConnection
 $connection.ConnectionString = "Server=$server;Database=$database;Integrated Security=True;"
 $connection.Open()
 $command = $connection.CreateCommand()
 $command.CommandText = $query
 $result = $command.ExecuteReader()
 $table = new-object “System.Data.DataTable”
 $table.Load($result)
 $connection.Close()
 return $table
}

SqlQuery $Server $Database "SELECT * FROM Staff"

Modify the window URL without reloading the page

Today I found an easy solution for the problem that if you’re changing the URL of the current window with JavaScript in the traditonal way, unfortenately the whole page will be reloaded.

window.location = "http://peter-doering.com/mynewurl"

You may want to update the URL after you’ve updated parts of the page with an Ajax call. This would enable the users to share the current page as link or to add an bookmark.

HTML5 introduced a new API for manipulating the browsers history. You can use the pushState()-method to change the current page url without page reload.

history.pushState(null, null, "http://peter-doering.com/mynewurl")
history.pushState(null, null, "http://peter-doering.com?id=1234")

Using Visual Studio Code behind a proxy

Microsoft has built a new lightweight IDE Visual Studio Code. Actually VS Code has nothing in common with their traditional full-featured IDE Visual Studio. It’s more like an enhanced Code Editor like the Atom Editor or vim. VS Code is developed with pure JavaScript and it’s based an Electron (UI-Framework) and Node.js.

If you’re using VS Code from within a companies network und you probably may want to install plugins from the Internet, you have to set the proxy settings first. Because VS Code is built for cross-plattform-ability it isn’t aware of the Windows IE proxy settings.

Please open File -> Preferences -> Settings

Add these two lines to the settings.json:

// Place your settings in this file to overwrite the default settings
{
    "http.proxy": "https://proxy.contoso.com",
    "http.proxyStrictSSL": false
}