如何从PowerShell调用方法?

时间:2013-09-26 12:05:04

标签: windows powershell methods

我正在尝试通过运行以下命令来获取Microsoft所说的信息:

IWindowsUpdateAgentInfo::GetInfo

问题是,我不知道如何在powershell中运行此命令。尝试以这种方式运行时,我收到以下错误消息:

[Microsoft.Update.IWindowsUpdateAgentInfo]::GetIno

Unable to find type [Microsoft.Update.IWindowsUpdateAgentInfo]: make sure that the assembly containing this type is 
loaded.
At line:1 char:1
+ [Microsoft.Update.IWindowsUpdateAgentInfo]::GetInfo
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Update.IWindowsUpdateAgentInfo:TypeName) [], RuntimeExcep 
   tion
    + FullyQualifiedErrorId : TypeNotFound

我在这里做错了什么?

1 个答案:

答案 0 :(得分:2)

是一个comobject,试试这个:

[version](New-Object -ComObject Microsoft.Update.AgentInfo).            
GetInfo('ProductVersionString')