2012-02-02 17 views
0

我試圖使用powershell更改遠程服務器中的Windows更新設置,但是當我運行下面的命令時,它給了我一個錯誤。無法在RemotePS會話中使用Windows Update COM對象

PS C:\Windows\system32> Enter-PSSession opalisbinary 

[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings 
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.NotificationLevel=2 
Property 'NotificationLevel' cannot be found on this object; make sure it exists and is settable. 
At line:1 char:14 
+ $AUSettings. <<<< NotificationLevel=2 
    + CategoryInfo   : InvalidOperation: (NotificationLevel:String) [], RuntimeException 
    + FullyQualifiedErrorId : PropertyNotFound 



[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.IncludeRecommendedUpdates=$true 


Property 'IncludeRecommendedUpdates' cannot be found on this object; make sure it exists and is settable. 
At line:1 char:14 
+ $AUSettings. <<<< IncludeRecommendedUpdates=$true 
    + CategoryInfo   : InvalidOperation: (IncludeRecommendedUpdates:String) [], RuntimeException 
    + FullyQualifiedErrorId : PropertyNotFound 

[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.Save() 


You cannot call a method on a null-valued expression. 
At line:1 char:18 
+ $AUSettings.Save <<<<() 
    + CategoryInfo   : InvalidOperation: (Save:String) [], RuntimeException 
    + FullyQualifiedErrorId : InvokeMethodOnNull 

雖然當我在服務器上本地運行它,它工作正常...

任何人都可以請幫助我。

回答

0

當您通過遠程桌面連接並運行命令時它工作嗎?它也取決於點數。我不知道Microsoft.Update.AutoUpdate,所以我只是猜測,但 - 是否可用於x64版本的PowerShell?換句話說,如果您在x64版本和x86中本地運行它,您是否看到錯誤?

+0

不,我沒有看到任何錯誤,當我通過RDP訪問服務器時運行命令 – PowerShell 2012-02-02 13:57:41

+0

好吧,通過RDP,x86或x64運行哪個版本的PowerShell? – stej 2012-02-02 18:45:28

0

對不起,我找不到真正的答案。我發現的是this link,其中指出遠程PS會話可以與SCCM 2012一起使用,但它們不能與SCCM 2007一起使用。

這不會幫助您,但似乎並非所有COM對象都與遠程PS會話兼容。