cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
cap_nitesh
Level 3

InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Provider. Powershell script not working for encrypt config files

Hello,

We have .net 4.5 project and we are creating installer for installshield 2022 version .

we have created one custom action which run after install finalization .in that custom action we calling a powershell script . The purpose of this script is set application pool 4.5 with specific user and from that user we need to encrypt sensitive info for particular section.

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

$username = Get-Property -Name SERVICEUSER
$plainPassword = Get-Property -Name SERVICEPASS
$password = ConvertTo-SecureString $plainPassword -AsPlainText -Force

$cred = New-Object System.Management.Automation.PSCredential($username, $password)

Import-Module WebAdministration
Set-ItemProperty iis:\apppools\"Asp.net v4.5" -name processModel -value @{userName=$username;password=$plainPassword;identitytype=3}

# Registry entry for ProtectionPolicy access
if (Test-Path "HKLM:\Software\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb") {
Write-Output "ProtectionPolicy registry entry already exists. Updating value..."
New-ItemProperty -Path "HKLM:\Software\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb" -Name "ProtectionPolicy" -Value 1 -PropertyType DWORD -Force | Out-Null
} else {
Write-Output "ProtectionPolicy registry entry does not exist. Creating new entry..."
New-Item -Path "HKLM:\Software\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb" -Force | Out-Null
New-ItemProperty -Path "HKLM:\Software\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb" -Name "ProtectionPolicy" -Value 1 -PropertyType DWORD -Force | Out-Null
}
$pwshPath = "C:\Program Files\PowerShell\7\pwsh.exe"
# Encryption process
Write-Host "Start encryption"
Start-Process -FilePath $pwshPath -Credential $cred -ArgumentList "-ExecutionPolicy Bypass -Command Set-Location 'C:\Program Files\Terumo BCT\Vista Information System Server\BLIT' && Rename-Item 'DonorBloodLossHistoryImportUtility.exe.config' -NewName 'web.config' -Force && Set-Location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319' && .\aspnet_regiis.exe -pef 'secureAppSettings' 'C:\Program Files\Terumo BCT\Vista Information System Server\BLIT' -prov 'customprovider' && Set-Location 'C:\Program Files\Terumo BCT\Vista Information System Server\BLIT' && Rename-Item 'web.config' -NewName 'DonorBloodLossHistoryImportUtility.exe.config' -Force "
Start-Process -FilePath $pwshPath -Credential $cred -ArgumentList "-ExecutionPolicy Bypass -Command Set-Location 'C:\Program Files\Terumo BCT\Vista Information System Server\Services\DataAccess' && Rename-Item 'BCT.Vista.DataAccess.Service.exe.config' -NewName 'web.config' && Set-Location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319' && .\aspnet_regiis.exe -pef 'connectionStrings' 'C:\Program Files\Terumo BCT\Vista Information System Server\Services\DataAccess' -prov 'customprovider' && Set-Location 'C:\Program Files\Terumo BCT\Vista Information System Server\Services\DataAccess' && Rename-Item 'web.config' -NewName 'BCT.Vista.DataAccess.Service.exe.config'"
Start-Process -FilePath $pwshPath -Credential $cred -ArgumentList "-ExecutionPolicy Bypass -Command Set-Location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319' && .\aspnet_regiis.exe -pef 'appSettings' 'C:\Program Files\Terumo BCT\Vista Information System Server\TerumoBCT.Vista.Web\CompatibilityWebService' -prov 'customprovider' "
Start-Process -FilePath $pwshPath -Credential $cred -ArgumentList "-ExecutionPolicy Bypass -Command Set-Location 'C:\Program Files\Terumo BCT\Vista Information System Server\Services\Application' && Rename-Item 'BCT.Vista.VistaService.exe.config' -NewName 'web.config' && Set-Location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319' && .\aspnet_regiis.exe -pef 'secureAppSettings' 'C:\Program Files\Terumo BCT\Vista Information System Server\Services\Application' -prov 'customprovider' && Set-Location -Path 'C:\Program Files\Terumo BCT\Vista Information System Server\Services\Application' && Rename-Item -Path 'web.config' -NewName 'BCT.Vista.VistaService.exe.config'"

After Run script we are getting error like 

InstallShield: Using highest version runtime...
InstallShield: Loading assembly ClrPsHelper from resource 4097
InstallShield: Calling method with parameters [(System.UInt32)16266, (System.String)C:\Users\RDTFSService\AppData\Local\Temp\6390e38e-b6ce-4521-9bbb-ffc501cdd759\SetIIsEncryption.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.IIS.PowerShell.Framework
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Framework
InstallShield: Loading Assembly Microsoft.IIS.PowerShell.Framework
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Framework
InstallShield: Loading Assembly Microsoft.IIS.PowerShell.Framework
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Framework
InstallShield: Loading Assembly Microsoft.IIS.PowerShell.Framework
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Framework
InstallShield: Loading Assembly Microsoft.IIS.PowerShell.Framework
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Framework
InstallShield: Loading Assembly Microsoft.IIS.PowerShell.Framework
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Framework
InstallShield: Loading Assembly Microsoft.IIS.PowerShell.Provider
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Provider
InstallShield: Loading Assembly Microsoft.IIS.PowerShell.Provider
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.PowerShell.Provider
InstallShield: Loading Assembly Microsoft.IIS.Powershell.Provider.resources
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.Powershell.Provider.resources, Version=10.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35
InstallShield: Loading Assembly Microsoft.IIS.Powershell.Provider.resources
InstallShield: Couldn't resolve assembly by name Microsoft.IIS.Powershell.Provider.resources, Version=10.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
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
MSI (s) (14:C8) [00:01:56:202]: Doing action: ISXmlFinalize
Action ended 0:01:56: EncryptionConfig. Return value 1.
MSI (s) (14:EC) [00:01:56:205]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI15DF.tmp, Entrypoint: ISXmlFinalize

 

 

 

    

 

 

 

 

 

Labels (1)
0 Kudos
(0) Replies