[英]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.