what does this line do ? variable.get()

Welcome Forums General PowerShell Q&A what does this line do ? variable.get()

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

 
Participant
1 month, 3 weeks ago.

  • Author
    Posts
  • #116631

    Participant
    Points: 57
    Rank: Member

    Hi,
    I came across a powershell script with below lines, but I don't understanding what is the role of get() ?
    CollectionSettings = Get-WmiObject -Namespace $NameSpace -Query "Select * From SMS_CollectionSettings Where CollectionID = '$CollectionID'"
    $CollectionSettings.Get()

    Thanks,
    Kishor

  • #116673

    Participant
    Points: 290
    Helping Hand
    Rank: Contributor

    Not sure. I apparently don't have that WMI class available on my machine, so I can't check myself. However, if you pipe the object to Get-Member, you'll see a bit more information.

    $CollectionSettings | Get-Member

    In essence, ".Get()" is a method on the object. Unfortunately, its bland name doesn't really give us much to go on, and all I can surmise is that it's used to retrieve some data from the class.

  • #116697

    Participant
    Points: 190
    Helping Hand
    Rank: Participant

    You need to check MSDN on what that method is for.
    I often find that it's easist to just check in e.g. ISE which Class it belongs to and then just google/bing it.

    https://msdn.microsoft.com/en-us/library/cc143292.aspx

    Basically it allows you to asynchronously grab the data, so you can continue doing other stuff while it collects the data.
    But you would need to create the observerobject etc. etc. to use it.

    So from the context of the two lines in your example it won't do anything.

You must be logged in to reply to this topic.