Changing local computer descrition with CIM

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Richard Siddaway Richard Siddaway 1 week, 5 days ago.

  • Author
    Posts
  • #75062
    Profile photo of Kevin Greer
    Kevin Greer
    Participant

    The below snip changes a remote computer description. I was wondering if it would be better to use invoke-cimMethod, but I'm not sure how to figure out what methods I can use with the Win32_OperatingSystem to change the description value.

    These are the methods I see with Get-Member
    Clone
    Dispose
    Equals
    GetCimSessionComputerName
    GetCimSessionInstanceId
    GetHashCode
    GetObjectData
    GetType
    ToString

    $OSValues = Get-CimInstance -ClassName win32_operatingsystem -ComputerName $ComputerName
    $OSValues.Description = $ComputerDescription
    Set-CimInstance -InputObject $OSValues
    
  • #75071
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    This is how you use Set-CimInstance to change the description

    PS> Get-CimInstance -ClassName Win32_OperatingSystem | select Description
    
    Description
    -----------
    
    
    
    PS> Get-CimInstance -ClassName Win32_OperatingSystem | Set-CimInstance -Property @{Description = 'Richards Laptop'}
    PS> Get-CimInstance -ClassName Win32_OperatingSystem | select Description
    
    Description
    -----------
    Richards Laptop
    

    There isn't a method that does the job

You must be logged in to reply to this topic.