我有一个 load.PS1,它加载“Microsoft.SqlServer.Smo”,如下所示
[System.Reflection.Assembly]::load('Microsoft.SqlServer.Smo') | Out-Null
当我使用 ISE 加载和运行它时效果很好,但是当我在 powershell shell 中运行它或用作“powershell -command”时出错。\RemoveInvalidSSRSAgentJob.ps1 xxxx”如下
Exception calling "Load" with "1" argument(s): "Could not load file or assembly
'Microsoft.SqlServer.Smo' or one of its dependencies. The system cannot find t
he file specified."
At line:1 char:38
+ & {[System.Reflection.Assembly]::load <<<< ('Microsoft.SqlServer.Smo') | Out-
Null}
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
如何设置它以便它可以在 powershell shell 或命令中工作?
谢谢