如何在SqlClr 中调用 PowerShell ?


PowerShell交流中心如何在SqlClr 中调用 PowerShell ?
0
yenange asked 8 年 ago

相关代码在:

http://blog.csdn.net/yenange/article/details/51271283

 

异常信息:

消息 6522,级别 16,状态 1,过程 Proc_DBA_PowerShell,第 0 行在执行用户定义例程或聚合“Proc_DBA_PowerShell”期间出现 .NET Framework 错误: System.ArgumentException: 路径的形式不合法。System.ArgumentException: 在 System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) 在 System.IO.Path.GetFullPath(String path) 在 System.Diagnostics.FileVersionInfo.GetFullPathWithAssert(String fileName) 在 System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName) 在 System.Management.Automation.PSVersionInfo.GetPSVersionTable() 在 System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace() 在 SqlClrDBA.PowerShell.Proccess.RunScript(String scriptText) 在 SqlClrDBA.SqlCLR.Proc_DBA_PowerShell(String script, String password)。

1 Answers
1
Best Answer
Mooser Lee 管理员 answered 8 年 ago

不好意思,我没有用过SqlClr,但是我在MSDN的tech论坛上搜到一个几乎和你一样的一个问题。大概说SQLCLR并不支持所有的.NET dll,而且PowerShell相关的dll就更不可能了。所以你的这样的思路应当是有问题的,具体关于SQLCLR支持的dll可以参考:https://msdn.microsoft.com/zh-cn/library/ms403279.aspx,显然 它不包括 PowerShell的核心程序集System.Management.Automation.dll

yenange replied 8 年 ago

非常感谢, 可能你这个答案是正确的了……