Installin RabbitMQ server from command line - cmd

How to install RabbitMQ server https://www.rabbitmq.com/install-windows.html from command line in silent mode?
Thank you!

We've done this before by just downloading the zipped version then extracting it and running the relevant commands:
Invoke-WebRequest https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.4/rabbitmq-server-windows-3.5.4.zip -OutFile C:\downloads\rabbitmq.zip
7z x C:\downloads\rabbitmq.zip -oC:\rabbitmq -aoa
# run RabbitMQ
Start-Process -FilePath C:\rabbitmq\rabbitmq_server-3.5.4\sbin\rabbitmq-server.bat
If you want it installed as a service you can use the rabbitmq-service.bat script - https://www.rabbitmq.com/rabbitmq-service.8.html
rabbitmq-service install

Related

PowerShell script on downloading and installing zabbix agent silently

I am trying to write a script that will download a .msi and then install it silently.
This is my 1st time ever trying to use PowerShell would be amazing if someone can assist me.
Thank you very much in advanced
- name: Install Zabbix
win_shell: |
wget "https://cdn.zabbix.com/zabbix/binaries/stable/6.2/6.2.3/zabbix_agent2-6.2.3-windows-amd64-openssl.msi" -UseBasicParsing -OutFile "C:\Users\Administrator\downloads\zabbix_agent2-6.2.3-windows-amd64-openssl.msi"
Start-Process "C:\Users\Administrator\downloads\zabbix_agent2-6.2.3-windows-amd64-openssl.msi /S"

Running a psm1 PowerShell script in Command Prompt (cmd.exe)?

I know nothing of PowerShell, but I wanted to install this: https://www.powershellgallery.com/packages/lolcat/
So, I start PowerShell as administrator, and:
PS C:\WINDOWS\system32> Install-Module -Name lolcat NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet
provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\Me\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import
the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
PS C:\WINDOWS\system32> lolcat
Usage: lolcat [OPTION]... [FILE1[, FILE2[, ...]]]
...
Nice, it works. So first I find where is the newly installed script:
PS C:\WINDOWS\system32> (Get-Module lolcat).Path
C:\Program Files\WindowsPowerShell\Modules\lolcat\1.0.7\lolcat.psm1
Ok, so now I want to try calling this from cmd.exe:
C:\Users>PowerShell.exe -File "C:\Program Files\WindowsPowerShell\Modules\lolcat\1.0.7\lolcat.psm1"
Processing -File 'C:\Program Files\WindowsPowerShell\Modules\lolcat\1.0.7\lolcat.psm1' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Nope, does not work.
Is it possible to call this PowerShell script from cmd.exe - and if so, how?
The error is due to the fact that the -File parameter from the powershell.exe excepts a .ps1 file.
If you want to run C:\Program Files\WindowsPowerShell\Modules\lolcat\1.0.7\lolcat.psm1 from cmd, make a .ps1 script where you can write something like
Import-Module lolcat
# now you have all the functions from the lolcat module loaded into this PowerShell session
# do stuff
And then call this script from cmd.
The difference between .ps1 and .psm1 is explained here.
Eh, turned out to be less complicated then I thought - since it is a "module", just use the module name:
C:\Users>PowerShell.exe lolcat
Usage: lolcat [OPTION]... [FILE1[, FILE2[, ...]]]
...

Correct way to install VirtualBox from electron app on windows

I'm trying to install VirtualBox from an electron app to the host machine.
Currently I do the following:
(virtualbox installer is packaged in the electron app)
await util.sudoExec(`
copy ${app.getAppPath()}\\..\\resources\\installers\\VirtualBox-6.1.8-137981-Win.exe ${temp}\\pkg.exe &
${temp}\\pkg.exe /extract --silent &
msiexec /i ${temp}\\VirtualBox\\VirtualBox-6.1.8-r137981.msi /quiet /norestart ALLUSERS=2 VBOX_INSTALLDESKTOPSHORTCUT=0 VBOX_INSTALLQUICKLAUCHSHORTCUT=0
`)
The above code is working 70%. In some cases I got an error message ie.:
'C:\Users\Username\AppData\Local\Temp\pkg.exe' is not recognized as an internal or external command,
operable program or batch file.
I'm not sure this is the best way to install VB.
You could try to use Chocolatey:
This will install it:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
And this command will install Virtualbox:
choco install virtualbox -y
This would also allow you to easily update the software whenever you need to. It's an option so you don't need to maintain package installers for each version of VB.
There is an answer , I think it could help you
'' is not recognized as an internal or external command, operable program or batch file
see the answer of Gerhard on this question

Chocolatey installs locally but not in a docker build (but it did last week) - Why?

I am trying to use chocolatey to install packages into a windows container. I actually just wanted to change one of the packages, rebuild and push and now, suddenly, it doesn't work. When I test it on the host (run the same command as the container) it works just fine. It has some kind of an issue with that container installation since last build. I can only suspect the base image changed. But, maybe not
On the host:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
Creating Chocolatey folders if they do not already exist.
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
same host, but this time, in a Dockerfile
PS C:\Users\Administrator\example> cat Dockerfile
# escape=`
ARG SDK_VERSION=4.8
# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:${SDK_VERSION}
# Disable Healthcheck
HEALTHCHECK NONE
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
RUN choco install adoptopenjdk8openj9jre -y
RUN choco install nuget.commandline -y
RUN choco install yarn -y
RUN choco install gitversion.portable -y
RUN choco install sonarscanner-msbuild-net46 -y
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
PS C:\Users\Administrator\example> docker build -t example .
Sending build context to Docker daemon 4.096kB
Step 1/10 : ARG SDK_VERSION=4.8
Step 2/10 : FROM mcr.microsoft.com/dotnet/framework/sdk:${SDK_VERSION}
4.8: Pulling from dotnet/framework/sdk
65014b3c3121: Already exists
b5405b758079: Pull complete
ac56c610af03: Pull complete
d8d61c2ababf: Pull complete
0ed57babb001: Pull complete
c8a0f45b3421: Pull complete
75cb34f91825: Pull complete
1949a0bb0ffb: Pull complete
316fdf3fc0fa: Pull complete
42b0925a3e5c: Pull complete
c5e384761600: Pull complete
f65f633b9854: Pull complete
bd885be04626: Pull complete
179844769b6b: Pull complete
c037183d4738: Pull complete
Digest: sha256:0008d5d893924c10ec01b1619a009c57116f9a943fe43ca772af544c75c9a83a
Status: Downloaded newer image for mcr.microsoft.com/dotnet/framework/sdk:4.8
---> 99ad7e1e8763
Step 3/10 : HEALTHCHECK NONE
---> Running in f679ce4e5789
Removing intermediate container f679ce4e5789
---> a08984a9afe8
Step 4/10 : RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
---> Running in 656ed514a137
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocInstall...
Unable to unzip package using 7zip. Perhaps try setting
$env:chocolateyUseWindowsCompression = 'true' and call install again. Error:
7-Zip signalled an unknown error (code -1073741511)
At line:220 char:15
+ ... default { throw "$errorMessage 7-Zip signalled an unknown error (co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...de -1073741
511):String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try
setting $env:chocolateyUseWindowsCompression = 'true' and call install aga
in. Error: 7-Zip signalled an unknown error (code -1073741511)
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))' returned a non-zero code: 1
PS C:\Users\Administrator\example>
There have been a few issues from TLS changes to changes to the microsoft base images that have caused me some problems with 7zip and choco over the last 3 weeks. I've got my base images working now by adding the following:
RUN $text = '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13 -bor [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Ssl3 -bor [Net.SecurityProtocolType]::Tls'; \
$text | Set-Content 'C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1';
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; \
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
powershell -Command refreshenv; \
cinst -y --allow-empty-checksums 7zip.install make nuget.commandline --no-progress;
However I am still experiencing some issue in other images with the reported error: "7-Zip signalled an unknown error (code -1073741511)", however no doubt they boil down to the same thing. Again, if I exec in to the running container, I am able to manually run choco and install 7zip and even access the "7z" commands. I tried committing the container once I made the changes, but still got this issue.

How to install Tomcat in Docker Windows Server Container?

On my windows server 2016 tp5 virtual machine, I would like to create a simple native windows based docker example without virtualbox.
The example needs tomcat for windows and since this windows server 2016 docker container uses a shared windows kernel, installing tomcat should be straight forward, alas! Using the following powershell docker build command stops with non-zero code: 255
Dockerfile in c:\build:
FROM microsoft/windowsservercore
RUN powershell -Command wget -Uri mirror.klaus-uwe.me/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70-windows-x64.zip -OutFile "$env:TEMP\tomcat-7.0.70.zip"
Admin-powershell:
docker build c:\build
Result:
---> Running in 317a3572890e
The command 'cmd /S /C powershell -Command wget -Uri mirror.klaus-uwe.me/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomca
t-7.0.70-windows-x64.zip -OutFile "$env:TEMP\tomcat-7.0.70.zip"' returned a non-zero code: 255
Although the zip file has been downloaded in my users temp dir.
Can anybody tell me, how a native windows tomcat installation should look like, as I am not really deep in this stuff.
As mentioned here:
The error code "255" usually means that it is not able to find the file you are asking it to execute
So try and test with the full path and name of the binary(ies) involved in your RUN command line (like powershell)
But test also a simpler case:
RUN dir c:\Users\
This has been recently reported as failing with the same exit code 255, which would mean the latest docker on Windows Server 2016 Technical Preview 5 has a bug.

Resources