0

我试图使用 powershell 更改远程服务器中的 Windows 更新设置,但是当我运行以下命令时,它给了我一个错误。

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

虽然当我在服务器上本地运行它时它工作正常......

谁能帮帮我。

4

2 回答 2

0

对不起,我找不到真正的答案。我发现这个链接表明远程 PS 会话可以与 SCCM 2012 一起使用,但它们不能与 SCCM 2007 一起使用。

这对您没有帮助,但似乎并非所有 COM 对象都与远程 PS 会话兼容。

于 2012-02-02T13:06:14.063 回答
0

当您通过远程桌面连接并运行命令时它是否有效?这也取决于比特。我不知道 Microsoft.Update.AutoUpdate,所以我只是猜测,但是 - 它可用于 x64 版本的 PowerShell 吗?换句话说,如果您在 x64 版本和 x86 本地运行它,您会看到错误吗?

于 2012-02-02T12:50:44.320 回答