我有这样的功能:从功能添加,pssnapin一个模块不能正常工作(范围问题?)
function start-sqlsnap
{
add-pssnapin SqlServerCmdletSnapin100
}
无论用于加载功能的方法,得到-pssnapin将显示该管理单元加载。但是:
- 如果壳粘贴,则各功能(如调用-SQLCMD)被识别
- 如果点从文件来源,所述功能被识别
- 如果放置在一个PSM1文件(内模块文件夹,在它自己的文件夹具有相同的名称作为PSM1文件),并装有进口模块,该管理单元的具体功能并不认可 - 但运行Get-pssnapin将显示模块加载。
错误:
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
我试着用不同的管理单元同样的事情:Microsoft.EnterpriseManagement.OperationsManager.Client并有完全相同的结果。 我在2008 R2上运行PowerShell 2。
这是一个已知的bug或功能?我能不能解决这个问题?
我只是想这和它的工作对我来说是什么你得到'Get-Module'吗?我得到: ModuleType名称ExportedCommands ---------- ---- ---------------- 脚本SQLPS {调用-PolicyEvaluation,调用,SQLCMD } – PeskyGnat 2011-06-03 18:08:09