Cannot add dll to 32-bit PowerShell - powershell

I am trying to add the Exchange 2007 SnapIn for 32-bit Powershell (Microsoft.Exchange.Management.PowerShell.Admin) but I seem to be having some trouble when installing the dll file.
These are the commands I am running in order to register the SnapIns
PS C:\Program Files\Microsoft\Exchange Server\Bin> $snapinPath = 'Microsoft.Exchange.Management.PowerShell.Support.dll'
PS C:\Program Files\Microsoft\Exchange Server\Bin> C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i $snapinPath
The above works without issue. I then go to install the main SnapIn with the following commands:
PS C:\Program Files\Microsoft\Exchange Server\Bin> $snapinPath = 'Microsoft.Exchange.PowerShell.Configuration.dll'
PS C:\Program Files\Microsoft\Exchange Server\Bin> C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i $snapinPath
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5483
Copyright (c) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'Microsoft.Exchange.PowerShell.Configuration, Version=8.
0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. An attempt was made to load a program with an incorrect format..
I'm not sure what I'm missing here. It's a fresh Exchange 2007 install so nothing should be corrupt.

My issue was that I was using the 64-bit version of the Microsoft.Exchange.PowerShell.Configuration.dll.
I required the 32-bit version. As it did not allow me to install the 32-bit version, I extracted the setup files for the 32-bit version of exchange, and copied the setup\serverroles\common folder to C:\Program Files\Microsoft\Exchange Server, and renamed it to Bin32.
The final stage was to copy this registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.PowerShell.Admin
to the following location:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.PowerShell.Admin
and then change any paths within the key to point to the new Bin32 folder.
At this point, it should be possible to load the Microsoft.Exchange.Management.Powershell.Admin snapin into a 32-bit Powershell (Great for IIS apps which depend on 32-bit libraries).

Related

Strawberry Perl MSI installation error - 1603

I tried to install Strawberry perl version 5.32.1.1 using the MSI installer for our 2016 windows 64 bit server.
msiexec.exe /i "C:\StrawberryPerl\strawberry-perl-5.32.1.1-64bit.msi" /L*V C:\StrawberryPerl\Strawberry-Perl.log"
The installer opened the setup wizard, but the installation failed with below error.
MSI (c) (78:00) [18:29:52:718]: Windows Installer installed the product. Product Name: Strawberry Perl (64-bit). Product Version: 5.32.1001. Product Language: 1033. Manufacturer: strawberryperl.com project. Installation success or error status: 1603.
Found that the MSI 1603 error could be due to,
Cause
You may receive this error message if any one of the following conditions is true:
Windows Installer is attempting to install an app that is already installed on your PC.
The folder that you are trying to install the Windows Installer package to is encrypted.
The drive that contains the folder that you are trying to install the Windows Installer package to is accessed as a substitute drive.
The SYSTEM account does not have Full Control permissions on the folder that you are trying to install the Windows Installer package to. You notice the error message because the Windows Installer service uses the SYSTEM account to install software.
In my case, I have installed the Active Perl already on the server. Please advise if this is the root cause of the installation issue.
Value 3 from Log:
MSI (c) (78:00) [18:28:33:113]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (78:00) [18:28:33:113]: PROPERTY CHANGE: Deleting SECONDSEQUENCE property. Its current value is '1'.
Action ended 18:28:33: ExecuteAction. Return value 3.
MSI (c) (78:00) [18:28:33:113]: Doing action: FatalError
Action 18:28:33: FatalError.
Action start 18:28:33: FatalError.
Action 18:28:33: FatalError. Dialog created
Action ended 18:29:51: FatalError. Return value 2.
Action ended 18:29:51: INSTALL. Return value 3.
MSI (c) (78:00) [18:29:51:312]: Destroying RemoteAPI object.
MSI (c) (78:E4) [18:29:51:328]: Custom Action Manager thread ending.
Property(C): UpgradeCode = {DBA41113-4E91-3FFC-B400-573BB4B80705}
Property(C): WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1
Additional Log:
Property(C): WIXUI_INSTALLDIR_VALID = 1
=== Logging stopped: 1/28/2022 18:29:52 ===
MSI (c) (78:00) [18:29:52:718]: Note: 1: 1708
MSI (c) (78:00) [18:29:52:718]: Product: Strawberry Perl (64-bit) -- Installation failed.
MSI (c) (78:00) [18:29:52:718]: Windows Installer installed the product. Product Name: Strawberry Perl (64-bit). Product Version: 5.32.1001. Product Language: 1033. Manufacturer: strawberryperl.com project. Installation success or error status: 1603.
MSI (c) (78:00) [18:29:52:734]: Grabbed execution mutex.
MSI (c) (78:00) [18:29:52:734]: Cleaning up uninstalled install packages, if any exist
MSI (c) (78:00) [18:29:52:750]: MainEngineThread is returning 1603
=== Verbose logging stopped: 1/28/2022 18:29:53 ===
Regards...
Error 1603 just tells you something went wrong during the installation. To discover the root of the issue, you'll want to dig into the log file. I always start by searching the log for value 3.
From there you should be able to find what really is preventing the installation.

azure cli extension not found on windows server 2019 self hosted agent

I have installed the latest version of Azure CLI on my windows 2019 self hosted agent. Output when checking for version.
PS C:\Users\blahblah> az --version
azure-cli 2.3.1
command-modules-nspkg 2.0.3
core 2.3.1
nspkg 3.0.4
telemetry 1.0.4
Extensions:
azure-devops 0.18.0
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\builduser\.azure\cliextensions'
Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Then when running the same script in devops azure pipeline release :
2020-04-18T03:50:14.3974844Z ##[debug]which 'az'
2020-04-18T03:50:14.3981389Z ##[debug]found: 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd'
2020-04-18T03:50:14.3981785Z ##[debug]which 'az'
2020-04-18T03:50:14.3985125Z ##[debug]found: 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd'
2020-04-18T03:50:14.3988433Z ##[debug]C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd arg: --version
2020-04-18T03:50:14.3989115Z ##[debug]C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd arg: --version
2020-04-18T03:50:14.3998697Z ##[debug]exec tool: C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
2020-04-18T03:50:14.3998969Z ##[debug]exec tool: C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
2020-04-18T03:50:14.3999139Z ##[debug]arguments:
2020-04-18T03:50:14.3999314Z ##[debug]arguments:
2020-04-18T03:50:14.4000072Z ##[debug] --version
2020-04-18T03:50:14.4000425Z ##[debug] --version
2020-04-18T03:50:14.4017396Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" --version"
2020-04-18T03:50:17.1212688Z azure-cli 2.3.1
2020-04-18T03:50:17.1213010Z
2020-04-18T03:50:17.1213120Z command-modules-nspkg 2.0.3
2020-04-18T03:50:17.1213248Z core 2.3.1
2020-04-18T03:50:17.1213345Z nspkg 3.0.4
2020-04-18T03:50:17.1213451Z telemetry 1.0.4
2020-04-18T03:50:17.1213507Z
2020-04-18T03:50:17.1213631Z Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
2020-04-18T03:50:17.1214799Z Extensions directory 'C:\windows\ServiceProfiles\NetworkService\.azure\cliextensions'
2020-04-18T03:50:17.1214873Z
2020-04-18T03:50:17.1215003Z Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]
2020-04-18T03:50:17.1215081Z
2020-04-18T03:50:17.1215191Z Legal docs and information: aka.ms/AzureCliLegal
2020-04-18T03:50:17.1215271Z
2020-04-18T03:50:17.1215320Z
2020-04-18T03:50:17.1215369Z
2020-04-18T03:50:17.1215468Z Your CLI is up-to-date.
2020-04-18T03:50:17.1215525Z
2020-04-18T03:50:17.1215623Z Please let us know how we are doing: https://aka.ms/clihats
Notice how the release pipeline does not show that I have the azure-devops extension installed. I need this extension to remotely trigger a pipeline release creation. I've tripled and quadrupled check that I am comparing the same server.
My next step would be to add a step to install the Azure CLI extension before calling the az pipelines. However I would rather try to figure out why this is not working. I have make this same call locally and it works fine. However I log in as myself instead of using a service principal/service subscription when testing same call locally.
Has anyone run into this issue and know whats going on here? Any suggestion would be greatly appreciated.
I found that the Extensions directory is inconsistent in your local and release pipeline.
In local:
Extensions directory 'C:\Users\builduser\.azure\cliextensions'
In release pipeline log :
Extensions directory 'C:\windows\ServiceProfiles\NetworkService\.azure\cliextensions'
If you are using a private agent, the Extensions directory should be consistent:
So you need to check the following points:
1.The machine where you installed az cli is the same machine as the agent you use to run the pipeline.
2.According to the directory path, check the installation of azure cli.

Powershell silent / unattended install of Delphi Tokyo 10.2 - for CI use in win docker container

I'm attempting to create a powershell command that silently installs Delphi Tokyo 10.2 - to be used as an automated compiler in a Windows Docker container. I've not been able to find any recent documentation on how to implement an unattended/silent installation using the proper installer commands / switches.
I was able to determine that the Tokyo and Rio installers use Inno Setup - and should be given Inno Setup installer commands/switches.
From the Tokyo installer about page:
https://photos.app.goo.gl/88jY7PF2mPAipwEA9
This is the command I've messed with thus far:
.\radstudio10_2_3_esd__93231.exe /sp- /verysilent /suppressmsgboxes /norestart/ /log="c:\somelocation\install.log"
However I am not able to get the install process to go past the first page or EULA checkbox. The failed silent install log shows:
Log opened. (Time zone: UTC-05:00)
Setup version: Inno Setup version 5.5.6 (u)
Original Setup EXE: C:\somelocation\radstudio10_2_3_esd__93231.exe
Setup command line: /SL5="$18051C,138809719,642048,C:\somelocation\radstudio10_2_3_esd__93231.exe" /sp- /verysilent /suppressmsgboxes /norestart/ /log=c:\somelocation\install.log
Windows version: 10.0.18363 (NT platform: Yes)
64-bit Windows: Yes
Processor architecture: x64
User privileges: Administrative
64-bit install mode: No
Created temporary directory: C:\Users\username\AppData\Local\Temp\is-1QQ8P.tmp
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-1QQ8P.tmp\innocallback.dll
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-1QQ8P.tmp\UnlockFirewall.dll
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-1QQ8P.tmp\mOasisRuntime.dll
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-1QQ8P.tmp\topbanner96.bmp
Failed to proceed to next wizard page; aborting.
Got EAbort exception.
Deinitializing Setup.
Log closed.
Here's a portion of the logs from a non-silent install of the same installer package:
Log opened. (Time zone: UTC-05:00)
Setup version: Inno Setup version 5.5.6 (u)
Original Setup EXE: C:\somelocation\radstudio10_2_3_esd__93231.exe
Setup command line: /SL5="$405F0,138809719,642048,C:\somelocation\radstudio10_2_3_esd__93231.exe" /log=c:\somelocation\install.log /saveinf=c:\somelocation\install.inf
Windows version: 10.0.18363 (NT platform: Yes)
64-bit Windows: Yes
Processor architecture: x64
User privileges: Administrative
264-bit install mode: No
Created temporary directory: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\innocallback.dll
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\UnlockFirewall.dll
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\mOasisRuntime.dll
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\topbanner96.bmp
Message box (OK):
Inno Setup version 5.5.6 (u)
Copyright © 1997-2015 Jordan Russell
Portions Copyright © 2000-2015 Martijn Laan
All rights reserved.
Inno Setup home page:
http://www.innosetup.com/
RemObjects Pascal Script home page:
http://www.remobjects.com/ps
User chose OK.
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\ProductCodes.ini
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\ProductCodes.ini
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\ProductCodes.ini
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\ProductCodes.ini
Extracting temporary file: C:\Users\username\AppData\Local\Temp\is-K4M7F.tmp\ProductCodes.ini
Starting the installation process.
Creating directory: C:\Program Files (x86)\Embarcadero
Creating directory: C:\Program Files (x86)\Embarcadero\Studio
Creating directory: C:\Program Files (x86)\Embarcadero\Studio\19.0
Directory for uninstall files: C:\Program Files (x86)\Embarcadero\Studio\19.0\
...
...
...
So in the above successful non-silent install - notice the line in the logs that says Message box (OK) this occurs after I accept the EULA. So at present i'm not sure how to pass an installer switch to suffice the EULA page silently.
Has anyone had success with creating a silent / unattended install of Delphi Tokyo or Rio? Or has found documentation that helped them achieve something similar?
Any help is much appreciated!
Kind Regards,
For Delphi 2007 and Delphi XE2 we were able to do a silent installation with setup.exe /s, see https://delphisorcery.blogspot.com/2011/07/unattended-delphi-installation-how.html for reference.
But this did not work for Delphi 10.2 Tokyo anymore. So our IT department called Embarcadero directly for more information on how to do a silent installation. But unfortunately they told us, the installation process can not be done silently!

How do I install the Nuget provider for PowerShell on a offline machine?

I am trying to install NuGet on an offline work machine running Windows Server 2016. Files can be uploaded to this machine via NAS. All online machines have restricted admin rights while the offline machine has full admin rights. I have found installation guides for offline machines, but they all assume that the online machine has admin rights.
How do I install the Nuget provider for PowerShell on a unconnected machine so I can install a nuget package from the PS command line? [Stack Exchange]
How to get PowerShellGet working with no Internet access [Intrepid Integration]
Bootstrap the NuGet provider and NuGet.exe [Microsoft]
These references recommend that NuGet is installed on an online machine (requires admin rights) then the installed dll is copied to the offline machine. Here's what I've tried so far:
Tried to download NuGet on the offline machine to see where it downloads the files. It searches: https://onegetcdn.azureedge.net/providers/providers.masterList.feed.swidtag
Followed the links in the URL and downloaded PackageManagement.NuGetProvider-2.8.5.208.dll
On a personal computer (with admin rights) I downloaded NuGet the normal way and got the dll PackageManagement.NuGetProvider.dll installed in C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\
I checked the hash of both dll's and they matched.
On the offline computer I created a C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208 folder and placed the dll from step 2 into this folder.
I launched PowerShell as an admin and saw that NuGet 2.8.5.208 was installed but has no DynamicOptions. Any attempt to install nupkg packages failed. Here's what the output of Get-PackageProvider looks like:
PS C:\Windows\system32> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
nuget 2.8.5.208
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
Notice that there are no DynamicOptions for NuGet. It clearly didn't install properly. I repeated this process for version 2.8.5.208 and 2.8.5.205 (both failed). I suspect there's an issue with the metadata of the dll I copied to the offline machine.
How can I get NuGet to install properly on my offline machine without admin rights on the online machines?
Download-Copy-Paste solution
Run on your offline or online Windows machine
Install-PackageProvider -Name NuGet
If you receive the following error
Install-PackageProvider : Administrator rights are required to install packages in 'C:\Program Files\PackageManagement\ProviderAssemblies'.
Log on to the computer with an account that has Administrator rights, and then try again,
or install in 'C:\Users\\AppData\Local\PackageManagement\ProviderAssemblies' by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).
At line:1 char:1
+ Install-PackageProvider -Name NuGet
then run it with -Scope CurrentUser
Install-PackageProvider -Name NuGet -Scope CurrentUser
We need an URL from received error
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.
Currently this will be https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409
So, go to an online machine and open this URL in a browser.
You'll receive the following XML
<?xml version="1.0" encoding="utf-8"?>
<SoftwareIdentity xmlns="http://standards.iso.org/iso/19770/-2/2015/schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:discovery="http://packagemanagement.org/discovery" patch="false" media="(OS:windows)" name="OneGet.Providers" tagVersion="1" uniqueId="OneGet.Providers.1" version="1.15.194.0" versionScheme="multipartnumeric">
<!--
This swidtag is a Discovery Feed that has pointers to the SWIDTAGs for
the providers that the bootstrapper can download.
-->
<Link href="https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag" type="application/swid-tag+xml" rel="package" discovery:name="nuget" discovery:latest="true" discovery:version="2.8.5.208" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/psl-1.0.0.210.package.swidtag" type="application/swid-tag+xml" rel="package" discovery:name="psl" discovery:latest="true" discovery:version="1.0.0.210" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/ChocolateyPrototype-2.8.5.130.package.swidtag" type="application/swid-tag+xml" rel="package" discovery:name="chocolatey" discovery:latest="true" discovery:version="2.8.5.130" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/nugetv2.feed.swidtag" type="application/swid-tag+xml" rel="feed" discovery:name="nuget" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/psl.feed.swidtag" type="application/swid-tag+xml" rel="feed" discovery:name="nuget" media="(OS:windows)" />
<Link href="https://onegetcdn.azureedge.net/providers/chocolateyprototype.feed.swidtag" type="application/swid-tag+xml" rel="feed" discovery:name="chocolatey" media="(OS:windows)" />
</SoftwareIdentity>
Copy the URL of the following form https://onegetcdn.azureedge.net/providers/nuget-X.X.X.XXX.package.swidtag
Currently it is https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag
Open this URL in a browser and you'll receive the following XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SoftwareIdentity xmlns="http://standards.iso.org/iso/19770/-2/2015/schema.xsd" xmlns:discovery="http://packagemanagement.org/discovery" xmlns:sha512="http://www.w3.org/2001/04/xmlenc#sha512" name="nuget" versionScheme="multipartnumeric" media="(windows)" tagVersion="1" version="2.8.5.208" uniqueId="nuget.2.8.5.208">
<Meta providerName="nuget" providerVersion="2.8.5.208" summary="NuGet provider for the OneGet meta-package manager" />
<Link href="https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll" type="application/octet-stream" rel="installationmedia" discovery:targetFilename="Microsoft.PackageManagement.NuGetProvider.dll" discovery:type="assembly" media="(OS:windows)" />
</SoftwareIdentity>
You need an URL from the only href attribute.
This URL allows you to download the current .dll file of the current NuGet Provider for PowerShell.
Currently it is https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll
After downloading, navigate to this .dll file and unlock it (or use Unblock-File cmdlet)
Copy this file to C:\Program Files\PackageManagement\ProviderAssemblies on your offline machine.
Additional info
Cant you just install it?
https://www.nuget.org/downloads
Download the Windows x86 Commandline installer to a thumb drive or shared folder, and install it the old fashioned way, or via a script?

Powershell : Failed To Load Microsoft.SqlServer.Management.Utility.dll

I don't ve Sql Server installed in my machine but I need the SQLPS module . So I installed below three msi .
Microsoft® System CLR Types for Microsoft® SQL Server® 2012 (SQLSysClrTypes.msi)
Microsoft® SQL Server® 2012 Shared Management Objects (SharedManagementObjects.msi)
Microsoft® Windows PowerShell Extensions for Microsoft® SQL Server® 2012 (PowerShellTools.ms
Then I tried importing SQLPS module but I got error
Importing SQLPS module.
The assembly 'Microsoft.SqlServer.Management.Utility' was not loaded because no assembly with that name was found.
I verified and I found this assemby is present under C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies but not under GAC .
So requesting you to please suggest me what I shd do ? I am not getting any clue . Should I copy the assembly to GAC ?
Try installing the native client as well?
Microsoft® SQL Server® 2012 Native Client (sqlncli.msi)