不能';t按名称Microsoft.PowerShell.Commands.Management.resources解析程序集

不能';t按名称Microsoft.PowerShell.Commands.Management.resources解析程序集,powershell,installshield,Powershell,Installshield,我正试图通过Installshield自定义操作中使用的PowerShell更新一个.ini文件: Add-Type -assembly "Microsoft.PowerShell.Commands.Management.resources" $installdir=get-property -name 'INSTALLDIR'; $targetdir=$installdir+'KovairDevOpsAgentInstaller\WinServiceInstaller\c

我正试图通过Installshield自定义操作中使用的PowerShell更新一个
.ini
文件:

Add-Type -assembly "Microsoft.PowerShell.Commands.Management.resources"

$installdir=get-property -name 'INSTALLDIR';
$targetdir=$installdir+'KovairDevOpsAgentInstaller\WinServiceInstaller\configuration.ini'
$username=get-property -name 'IS_APP_ID';
$password=get-property -name 'IS_APP_PASSWORD';
$baseurl=get-property -name 'IS_APP_BASEURL';

$AppLine =Get-Content -Path $targetdir| Where-Object { $_ -match 'Baseurl=' }
$AppVersion = $AppLine.Replace($AppLine.Split('=')[1],$baseurl)


$AppLine1 =Get-Content -Path $targetdir| Where-Object { $_ -match 'Username=' }
$AppVersion1 = $AppLine1.Replace($AppLine1.Split('=')[1],$username) 


$AppLine2 =Get-Content -Path $targetdir| Where-Object { $_ -match 'Password=' }
$AppVersion2 = $AppLine2.Replace($AppLine2.Split('=')[1],$password) 
$AppVersioncom=$AppVersion2.Replace("==","")


$AppLine3 =Get-Content -Path $targetdir| Where-Object { $_ -match 'IsDefaultHost=' }
$AppVersion3 = $AppLine3.Replace($AppLine3.Split('=')[1],"N")

$AppLine4 =Get-Content -Path $targetdir| Where-Object { $_ -match 'TickTimeinSecond=' }
$AppVersion4 = $AppLine4.Replace($AppLine4.Split('=')[1],3)

$AppLine5 =Get-Content -Path $targetdir| Where-Object { $_ -match 'AppStreamingThreshold=' }
$AppVersion5 = $AppLine5.Replace($AppLine5.Split('=')[1],5)

Set-content -Path $targetdir -Value ""

Add-Content -Path $targetdir -Value "$AppVersion" 
Add-Content -Path $targetdir -Value "$AppVersion1" 
Add-Content -Path $targetdir -Value "$AppVersioncom"
Add-Content -Path $targetdir -Value "$AppVersion3"
Add-Content $targetdir -Value "$AppVersion4"
Add-Content -Path $targetdir -Value "$AppVersion5"
运行安装程序时遇到以下错误:

Action start 12:31:51: UpdateKeys.
MSI (c) (D4:90) [12:31:51:534]: Invoking remote custom action. DLL: C:\Users\afreeng\AppData\Local\Temp\MSI933E.tmp, Entrypoint: m3
InstallShield: Attempting to load through CLR 4 APIs...
InstallShield: Getting meta host...
InstallShield: Enumerating available runtimes...
InstallShield: Highest available runtime: v4.0.30319
InstallShield: Trying to use highest runtime...
InstallShield: Using highest version runtime...
InstallShield: Loading assembly ClrPsHelper from resource 4097
InstallShield: Calling method with parameters [(System.UInt32)183, (System.String)C:\Users\afreeng\AppData\Local\Temp\57bed54d-7ffc-4572-a5be-e69fa422a269\updatekeys.ps1]
InstallShield: Loading Assembly Microsoft.PowerShell.Commands.Management.resources
InstallShield: Couldn't resolve assembly by name Microsoft.PowerShell.Commands.Management.resources
InstallShield: Loading Assembly Microsoft.PowerShell.Commands.Management.resources
InstallShield: Couldn't resolve assembly by name Microsoft.PowerShell.Commands.Management.resources, Version=3.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35
InstallShield: Loading Assembly Microsoft.PowerShell.Commands.Management.resources
InstallShield: Couldn't resolve assembly by name Microsoft.PowerShell.Commands.Management.resources, Version=3.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35
Action ended 12:32:01: UpdateKeys. Return value 1.
我使用的是PowerShell版本5.1.17763.1490