I have this function:
function start-sqlsnap { add-pssnapin SqlServerCmdletSnapin100 }
Regardless of the method used to load the function, get-pssnapin will show the snapin load. But:
- When pasted into a shell, functions (e.g. invoke-sqlcmd) are recognized
- If the point is obtained from a file, the functions are recognized.
- If placed in the psm1 file (inside the moduleβs folder, in its own folder with the same name as the psm1 file) and loaded using the import module, special snapin functions are not recognized, but running get-pssnapin will show the module is loaded.
Error:
The term 'invoke-sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check t he spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:14 + invoke-sqlcmd <<<< + CategoryInfo : ObjectNotFound: (invoke-sqlcmd:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
I tried the same thing with another snapin: Microsoft.EnterpriseManagement.OperationsManager.Client and had the same result. Im working with PowerShell 2 on 2008 R2.
Is this a known bug or feature? Can I solve it somehow?
source share