I have a (pretty much clean) Windows Server 2008 R2 Build with SQL Server 2012 installed. I'm having a problem with PowerShell (Version 3).
I am trying to use the Invoke-Sqlcmd cmdlet. However, when I call get it i get a message saying that 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program.
It works if if I run Import-Module SqlPs -Verbose -Force (bypassing the security policy). However it this lasts only as long as the tab is open. If i open a new tab, try to run another script or re-open Powershell ISE I have to import the module all over again.
Any ideas why this is happening?
From my understanding, module loading is done on a per session basis. So the behavior you're seeing is what is expect.