简体   繁体   English

如何从 JSON 文件中获取应用程序名称列表和卸载字符串并将它们作为参数传递以使用 Powershell 卸载应用程序

[英]How to get the list of application names and uninstall strings from JSON file and pass them as parameters to uninstall an application using powershell

I would like to read JSON file to get the list of application names and their respective uninstall strings and pass them as arguments in power shell to uninstall the apps irrespective of whether the apps are Windows Installer(MSI) or setup.我想读取 JSON 文件以获取应用程序名称列表及其各自的卸载字符串,并将它们作为参数传递到 power shell 中以卸载应用程序,而不管应用程序是 Windows Installer(MSI) 还是安装程序。 Can someone please suggest me how to do this.有人可以建议我如何做到这一点。 Thanks谢谢

Use the ConvertFrom-JSON.使用 ConvertFrom-JSON。 This will create a PSObject out of the JSON这将从 JSON 创建一个 PSObject

$TEST2 = $TEST | ConvertFrom-Json

Thank you for suggesting the answer, that worked.感谢您提出答案,这很有效。 I used the following cmd-line我使用了以下 cmd 行
$J = Get-Content -Raw -Path $scriptDirectory\\Files\\XXX.json | $J = Get-Content -Raw -Path $scriptDirectory\\Files\\XXX.json | ConvertFrom-Json and passed the AppName property as given below to fetch the application names: $AppName = $J |fl -Property AppName. ConvertFrom-Json 并传递如下所示的 AppName 属性以获取应用程序名称:$AppName = $J |fl -Property AppName。

FYI.. my JSON file content looked as follows:仅供参考..我的JSON文件内容如下:

[ { "AppName": "xxxxx", "AppVersion": "aa.bb" }, [ { "AppName": "xxxxx", "AppVersion": "aa.bb" },

 {
   "AppName": "yyy",
   "AppVersion": "aa.bb.cc"
 }

] ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用jQuery从JSON数组获取名称列表? - How to get names list from json array using jquery? 如何使用get JSON将参数传递给php - How to pass parameters to php using get JSON 如何在Android应用程序上使用JSON解析的活动之间传递字符串? - how to pass strings between activities parsed with JSON on android application? 通过powershell脚本获取从odata查询uri读取json文件的应用程序中运行的失败作业的状态 - powershell script to get the status of failed jobs which are running in the application reading the json file from a odata query uri 使用Linq从Json获取字符串列表 - Using Linq to Get List of Strings from Json 如何将Json参数传递给powershell脚本 - How to pass Json parameters to powershell script 如何从json对象获取字符串列表 - How to get list of strings from json object 如何从Json Array获取值以通过意图传递它们 - How to get values from Json Array to pass them through intent 如何使用 powershell 从 json 获取值 - How to Get the values from json using powershell 如何获取推文的某些参数,以使用json.stringify将其保存到文件中? (我使用的方法适用于Stream,但不适用于GET) - How can I get certain parameters of tweets to save them into a file using json.stringify? (Method I use works for Stream but not for GET)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM