相关疑难解决方法(0)

如何在PowerShell中加载程序集?

以下PowerShell代码

#Get a server object which corresponds to the default instance
$srv = New-Object -TypeName Microsoft.SqlServer.Management.SMO.Server
... rest of the script ...
Run Code Online (Sandbox Code Playgroud)

给出以下错误消息:

New-Object : Cannot find type [Microsoft.SqlServer.Management.SMO.Server]: make sure 
the assembly containing this type is loaded.
At C:\Users\sortelyn\ ... \tools\sql_express_backup\backup.ps1:6  char:8
+ $srv = New-Object -TypeName Microsoft.SqlServer.Management.SMO.Server
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Run Code Online (Sandbox Code Playgroud)

互联网上的每个答案都写道我必须加载程序集 - 确保我可以从错误信息中读取:-) - 问题是:

如何加载程序集并使脚本工作?

powershell powershell-3.0

145
推荐指数
6
解决办法
24万
查看次数

标签 统计

powershell ×1

powershell-3.0 ×1