PowerShell script to update value in the JSON file.

Ashwa 166 Reputation points

Please help in creating a PowerShell script to update the value in the JSON file. Want to get it done using paramaters not as hardcoded.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,766 questions
No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 18,846 Reputation points Microsoft Vendor


    What is the $object? Can you post the error message? Why not just update the value as you did above


    Best Regards,
    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 36,481 Reputation points

    On this line:

    $object.GlossEntry. = $object.roles.psobject.Properties.Value

    You need to correct this $object is undefined and there's a trailing period after $object.GlossEntry

    Plus, it looks like you've omitted parts of your script.

    Also, the JSON text you posted cannot be processed by the ConvertFrom-JSON cmdlet.