【发布时间】:2020-10-16 02:17:51
【问题描述】:
我被困在我的 PowerShell 脚本中的某个点,我需要将名为 restServiceURL 和 microServiceURL 的属性的部分值从 http 更新为 https。 (截图如下)
我有以下脚本,但不知何故我无法弄清楚需要添加什么才能从“http:”中替换属性值的特定部分(在本例中为 http) >//VWMAIMPKG16SN/IMatchREST/”到“https://VWMAIMPKG16SN/IMatchREST/”
我知道 set-content 命令应该能够做到这一点,但是如何在不改变值的其他部分的情况下做到这一点是我卡在的地方。
对此的任何建议都会有所帮助。
# Code to get Installation Directory path
$CommonNode=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\AquagardePI\STeP\Platform\Common
$InstallationDir=$CommonNode.InstallationDir
#Path of Json File
$ConfigPath = $InstallationDir + "Web Client\www\\NextGen\assets\config.json"
#Get Content of the File
$file = Get-Content $ConfigPath -raw | ConvertFrom-Json
#Get the value of Property
$file = $file.restServiceURL
【问题讨论】:
标签: json powershell powershell-4.0 powershell-5.0