SQL PowerShell Profile

I’m very much new to using PowerShell in my day-to-day DBA tasks. One thing it took me a while to work out was that i had to import the sqlps module each time I started PowerShell. Then I realized that I could create a new PowerShell profile so that this could be imported automatically every time I started a session.

1) Test to see if you have a profile first

Test-Path $profile

2) if the result is false then we need to create a profile:

New-item -type file -force $profile.

3) now let’s open the profile in notepad:

Notepad $profile

4) Enter our default settings for when we open PowerShell:

import-module sqlps -DisableNameChecking

Voila! Now when you start PowerShell the SQLPS module will already be imported and you should see SQLServer as a location via PSDrive too: