locked
Cannot convert WsusUpdate to the type WsusUpdate required by parameter 'Update' RRS feed

  • Question

  • Can any one tell me what is wrong with this script I have written?

    $win10updates = Get-WsusUpdate -Approval Unapproved -Status Needed | Where-Object -FilterScript {$_.Approved -eq "NotApproved" -and $_.Products -eq "Windows 10"}
    
    ForEach-Object -InputObject $win10updates -Process {Approve-WsusUpdate -TargetGroupName Group -Update $_ -Action Install}

    It gives the error -
    Cannot convert 'Microsoft.UpdateServices.Commands.WsusUpdate' to the type
    'Microsoft.UpdateServices.Commands.WsusUpdate' required by parameter 'Update'. Specified method is not supported.

    Any help would be appreciated.

    Jon
    Tuesday, February 13, 2018 2:52 PM

Answers

  • Hi Jon,

    Based on my research, I suppose we don't have to use ForEach-Object, we can pipe Approve-WsusUpdate directly, please have a try with the following script (Not tested), hope it is helpful to you:
    Get-WsusUpdate -Approval Unapproved -Status Needed |
        Where-Object {$_.Approved -eq 'NotApproved' -and $_.Products -eq 'Windows 10'} |
            Approve-WsusUpdate -TargetGroupName Group -Action Install

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Is there some point in reposting my exact code once again?


    \_(ツ)_/

    • Marked as answer by Jonno_Brown Wednesday, February 14, 2018 2:33 PM
    Wednesday, February 14, 2018 6:45 AM

All replies

  • Proper code formatting would help you find issues.  Please also take tim to learn basic PowerShell instead of guessing.

    Get-WsusUpdate -Approval Unapproved -Status Needed | 
        Where-Object -FilterScript {$_.Products -eq 'Windows 10'} |
        Approve-WsusUpdate -TargetGroupName Group -Action Install
    



    \_(ツ)_/

    Wednesday, February 14, 2018 2:08 AM
  • Hi Jon,

    Based on my research, I suppose we don't have to use ForEach-Object, we can pipe Approve-WsusUpdate directly, please have a try with the following script (Not tested), hope it is helpful to you:
    Get-WsusUpdate -Approval Unapproved -Status Needed |
        Where-Object {$_.Approved -eq 'NotApproved' -and $_.Products -eq 'Windows 10'} |
            Approve-WsusUpdate -TargetGroupName Group -Action Install

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Is there some point in reposting my exact code once again?


    \_(ツ)_/

    • Marked as answer by Jonno_Brown Wednesday, February 14, 2018 2:33 PM
    Wednesday, February 14, 2018 6:45 AM
  • Hi jrv,

    Sorry, I did not refresh my webpage. I'll delete it.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, February 14, 2018 6:47 AM