Set Computer Description on WMI

This topic contains 4 replies, has 3 voices, and was last updated by Profile photo of Jamie Davenport Jamie Davenport 2 years, 1 month ago.

  • Author
    Posts
  • #19543
    Profile photo of Jamie Davenport
    Jamie Davenport
    Participant

    Background
    I was working on a powershell script that would change the computer description in Active Directory and locally on the computer so that they would both match. I was able to get the AD part easily but the wmi seems to be a challenge. I have tried the following.

    What I have Tried
    $x = Get-CimInstance Win32_OperatingSystem – Property Description
    Set-Ciminstance -InputOjbect $x -Property @{Description="New Description"} -PassThru

    Error
    A parameter cannon be found that matches parameter name 'InputObject'

    I have searched different places but haven't found anything for this specific attribute where someone has gotten it to change. I verified that this value can be set. Any help that can be provided is appreciated.

  • #19545
    Profile photo of Raymond Slieff
    Raymond Slieff
    Participant

    Instead of -InputObject I think you need to use -CimInstance
    The following worked for me

    $x = Get-CimInstance Win32_OperatingSystem -Property Description
    $x.Description = "My Machine"
    Set-CimInstance -CimInstance $x -PassThru

    edit: removed pre tags since they seemed to not format correctly.

    • #19548
      Profile photo of Jamie Davenport
      Jamie Davenport
      Participant

      @Raymond This worked! Thanks!

      Instead of -InputObject I think you need to use -CimInstance
      The following worked for me

      $x = Get-CimInstance Win32_OperatingSystem -Property Description
      $x.Description = "My Machine"
      Set-CimInstance -CimInstance $x -PassThru

      edit: removed pre tags since they seemed to not format correctly.

  • #19546
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    You can't modify the description property – its read only

    £> $class = Get-CimClass -ClassName Win32_ComputerSystem
    £> $class.CimClassProperties["Description"]

    Name : Description
    Value :
    CimType : String
    Flags : Property, ReadOnly, NullValue
    Qualifiers : {read}
    ReferenceClassName :

    • #19547
      Profile photo of Jamie Davenport
      Jamie Davenport
      Participant

      @Richard: You did Win32_ComputerSystem I am trying to modify description at Win32_OperatingSystem

You must be logged in to reply to this topic.