
How To Import SQLPS While Keeping The Current PowerShell Provider
One of the very few annoyances of using the SQL PowerShell Provider becomes apparent when you import its module. Your current location, probably a working folder somewhere in your file system, will get overridden by the default location of the new provider.
To avoid this behaviour, you can include a function like the one below in your scripts. This will hold on to your current location, import the module and then reset your location to what it was before.
function Import-SQLPS
{
$Current = Get-Location
Import-Module SQLPS -DisableNameChecking
Set-Location $Current
}