WMI:“无效命名空间”当尝试检索“SqlServerAlias”时范围
以下代码抛出 ManagementException:“无效的命名空间”。有什么想法吗?
private ManagementClass GetManagementObject()
{
const String client = @"localhost";
const String sqlServerAliasScope = @"SqlServerAlias";
const String aliasScopePart = @"\root\Microsoft\SqlServer\ComputerManagement10";
ManagementScope scope = new ManagementScope(@"\\" + client + aliasScopePart);
ManagementClass clientAlias =
new ManagementClass(scope, new ManagementPath(sqlServerAliasScope), null);
clientAlias.Get(); // *** THROWS HERE ***
return clientAlias;
}
这个 PS 脚本也失败了,如果上面失败的话应该会失败:
Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class SqlServerAlias
我是否缺少任何安装服务器的东西?
Following code is throwing ManagementException: "Invalid Namespace". Any idea?
private ManagementClass GetManagementObject()
{
const String client = @"localhost";
const String sqlServerAliasScope = @"SqlServerAlias";
const String aliasScopePart = @"\root\Microsoft\SqlServer\ComputerManagement10";
ManagementScope scope = new ManagementScope(@"\\" + client + aliasScopePart);
ManagementClass clientAlias =
new ManagementClass(scope, new ManagementPath(sqlServerAliasScope), null);
clientAlias.Get(); // *** THROWS HERE ***
return clientAlias;
}
This PS script also fails, which should if above fails after all:
Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class SqlServerAlias
Am I missing anything to install the server maybe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在查询远程服务器吗?
我可以成功运行此命令(没有无效的命名空间错误),但不会返回任何结果,尽管我没有配置任何别名。
are you querying the remote server?
I can run this successfully ( without invalid namespace error) but does not return any results, although i do not have any alias configured.
这对我有用:
返回:
This works for me:
Returns: