can't get return value for remote (new-object -com "x.y.z")

Welcome Forums General PowerShell Q&A can't get return value for remote (new-object -com "x.y.z")

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
4 years, 3 months ago.

  • Author
    Posts
  • #18543

    Participant
    Points: 0
    Rank: Member

    I'm new at this and have searched for 2 days trying to resolve...sorry if basic...
    no matter how I try to get back, returns NaN or nothing...

    (New-Object -com "Microsoft.Update.AutoUpdate").Settings

    trying to get the NotificationLevel setting back...
    What am I missing?

    FULL ORIGINAL SCRIPT BLOCK:
    $res = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
    $lvl = $res.notificationlevel
    switch ($lvl)
    {
    1 {$msg="Windows Updates set to `"Never Check`""}
    2 {$msg="Windows Updates set to `"Check but let me choose to download/install`""}
    3 {$msg="Windows Updates set to `"Download but let me choose to install`""}
    4 {$msg="Windows Updates Updates set to `"Auto Update`""}
    default {$msg="Windows Updates status couldnt be determined"}
    }
    # Write-Host $msg
    Write-Host "Message.WinUpdates: $msg"
    Write-Host "Statistic.WinUpdates: $lvl"

    appreciate any help

  • #18546

    Keymaster
    Points: 1,673
    Helping HandTeam Member
    Rank: Community Hero

    Have you considered using http://gallery.technet.microsoft.com/scriptcenter/2d191bcd-3308-4edd-9de2-88dff796b0bc, which is a PowerShell module for managing Windows Update, instead?

    Or reviewed http://blogs.technet.com/b/jamesone/archive/2009/01/27/managing-windows-update-with-powershell.aspx, which seems to be doing some of the same stuff you're trying?

  • #18556

    Participant
    Points: 0
    Rank: Member

    I'd seen both in my researching. Basically I am using a monitoring tool to pull this info so ultimately it is using a PSSession to get this.

    The top link I'd seen and determined (briefly reviewing) that it didn't return the notification level setting anywhere.

    The second, I'd seen but when testing the chunk to show the settings, it get "cannot index into a null array" error and am to new to know how to fix this.

    I appreciate your response!

  • #18557

    Keymaster
    Points: 1,673
    Helping HandTeam Member
    Rank: Community Hero

    It sounds like it's something specific to the systems you're working on; the example works on the VM I have here.

  • #18558

    Participant
    Points: 0
    Rank: Member

    good to know. thanks for your time!

The topic ‘can't get return value for remote (new-object -com "x.y.z")’ is closed to new replies.