Powershell installing msi - powershell

I am using docker with powershell. I want to download and install webdeploy .msi
I am using the following code:
RUN Invoke-WebRequest http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_x86_en-US.msi -OutFile webdeploy.msi; \
Start-Process msiexec -Wait -ArgumentList /q, /i, -PassThru, webdeploy.msi ; \
Remove-Item -Force webdeploy.msi
When I run:
docker build -t test.
Everything goes fine.
When I then check the folder "Program Files (x86)" inside the container I dont see any folder "IIS".
I also tried:
RUN Invoke-WebRequest http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_x86_en-US.msi -OutFile webdeploy.msi; \
Start-Process msiexec -Wait -ArgumentList /q, /i, webdeploy.msi ; \
Remove-Item -Force webdeploy.msi
Some help would be appreciated.

Related

powershell for quicken update

trying to patch quicken with this script i think im missing a silent install command any suggestions would be great
$Path = $env:TEMP; $Installer = "Greenshot-INSTALLER-1.2.10.6-RELEASE.exe"; Invoke-WebRequest "https://assistant.quicken.com/patch/QW27.1.47.11MPatch.EXE" -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path$Installer
when I run the script it fails (exceeding the timeout for completion I'm deploying it from PDQ inventory with admin credentials)

Download and Install CCleaner using PowerShell

I tried this below command line to download and install CCleaner using PowerShell. But I got errors, it was a guess try, and I would appreciate if you could modify to a working command.
powershell.exe -Command "$Path = $env:TEMP; $Installer = 'ccsetup578.exe'; Invoke-WebRequest 'https://www.ccleaner.com/ccleaner/download/standard' -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args '/silent /install' -Verb RunAs -Wait; Remove-Item $Path$Installer"
"https://www.ccleaner.com/ccleaner/download/standard" - .html, not .exe
need
Invoke-WebRequest -Uri "https://download.ccleaner.com/ccsetup578.exe" -OutFile "$env:Temp\ccsetup578.exe"
P.S. Ccleaner - placebo
Use C:\Windows\System32\cleanmgr.exe /LOWDisk

Install Docker and Docker Compose on the Docker image

I am working on Containerized CI/CD. I have a web API project developed in .NET Framework 4.6.2. This application enabled docker support.
Expected Working Scenario:
I have to configure CI which needs to build the application as a docker image and push to ECR repository.
I have to deploy the same to ECS as well. As a final, I have to run my SQL (RDS) also as a docker and deploy as part of this.
Currently, I need to build and push the docker image to ECR.
Current Progress:
In order to build my application, I have created a custom docker as the build server. Please find my current docker file used to build the docker image;
# escape=`
FROM microsoft/dotnet-framework:4.7.2-runtime
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
#Install NuGet CLI
ENV NUGET_VERSION 4.4.1
RUN New-Item -Type Directory $Env:ProgramFiles\NuGet; `
Invoke-WebRequest -UseBasicParsing https://dist.nuget.org/win-x86-commandline/v$Env:NUGET_VERSION/nuget.exe -OutFile $Env:ProgramFiles\NuGet\nuget.exe
#Install AWS CLI
RUN Invoke-WebRequest -UseBasicParsing https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi -OutFile AWSCLI64PY3.msi; `
Start-Process "msiexec.exe" -ArgumentList '/i', 'AWSCLI64PY3.msi', '/qn', '/norestart' -Wait -NoNewWindow; `
Remove-Item -Force AWSCLI64PY3.msi; `
# Install VS Test Agent
Invoke-WebRequest -UseBasicParsing https://download.visualstudio.microsoft.com/download/pr/12210068/8a386d27295953ee79281fd1f1832e2d/vs_TestAgent.exe -OutFile vs_TestAgent.exe; `
Start-Process vs_TestAgent.exe -ArgumentList '--quiet', '--norestart', '--nocache' -NoNewWindow -Wait; `
Remove-Item -Force vs_TestAgent.exe; `
# Install VS Build Tools
Invoke-WebRequest -UseBasicParsing https://download.visualstudio.microsoft.com/download/pr/12210059/e64d79b40219aea618ce2fe10ebd5f0d/vs_BuildTools.exe -OutFile vs_BuildTools.exe; `
# Installer won't detect DOTNET_SKIP_FIRST_TIME_EXPERIENCE if ENV is used, must use setx /M
setx /M DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1; `
Start-Process vs_BuildTools.exe -ArgumentList '--add', 'Microsoft.VisualStudio.Workload.MSBuildTools', '--add', 'Microsoft.VisualStudio.Workload.NetCoreBuildTools', '--add', 'Microsoft.VisualStudio.Workload.WebBuildTools;includeRecommended', '--quiet', '--norestart', '--nocache' -NoNewWindow -Wait; `
Remove-Item -Force vs_buildtools.exe; `
Remove-Item -Force -Recurse \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\"; `
Remove-Item -Force -Recurse ${Env:TEMP}\*; `
Remove-Item -Force -Recurse \"${Env:ProgramData}\Package Cache\"
# Set PATH in one layer to keep image size down.
RUN setx /M PATH $(${Env:PATH} `
+ \";${Env:ProgramFiles}\NuGet\" `
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\CommonExtensions\Microsoft\TestWindow\" `
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\")
# Install Targeting Packs
RUN #('4.0', '4.5.2', '4.6.2', '4.7.2') `
| %{ `
Invoke-WebRequest -UseBasicParsing https://dotnetbinaries.blob.core.windows.net/referenceassemblies/v${_}.zip -OutFile referenceassemblies.zip; `
Expand-Archive -Force referenceassemblies.zip -DestinationPath \"${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\"; `
Remove-Item -Force referenceassemblies.zip; `
}
Here I have installed my prerequisites as below;
NuGet
AWS CLI
List item
VS Test Agent
VS Build Tools
Issue / Question:
As the application enabled docker-compose, I can use MSBuild command to build the docker image as specified below;
msbuild "%~dp0SampleDevOps.sln" /p:TargetFrameworkVersion=v4.6.2 /p:Configuration=Release /p:PackageAsSingleFile=false /p:OutDir=%~dp0\artifacts\ docker-compose.dcproj
This commands worked successfully in my local machine (Windows 10). But when I run code build, I got error like below;
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(195,5):
error : MSB0001: Internal MSBuild Error: SampleDevOps.sln unexpectedly
not a rooted path
[C:\codebuild\tmp\output\src096397699\src\github.com\xxxx\test1\docker-compose.dcproj]
Here my thought was I need to install docker and docker-compose also in my build server.
Is my understanding, right? Am I going the correct direction?
If yes, please help me to do that from the docker file I poster earlier.
I also confused that, there is not have built-in docker which already contains this AWS CLI and dockers?

using logfile when installing .exe with powershell

When I want to install an .msi file with powershell and want to use logging I use the following code:
RUN Invoke-WebRequest http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi -OutFile webdeploy.msi; \
Start-Process msiexec -Wait -ArgumentList '/i webdeploy.msi /l*v C:\msilog.txt /q' ; \
Remove-Item -Force webdeploy.msi
I searched on google how to do this for an .exe file but cannot find a solution.
So my question how do I add a log file for the following function in powerhsell:
RUN Invoke-WebRequest -UseBasicParsing
https://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-
475AB85EEF6E/vcredist_x86.exe -OutFile vcredist_x86.exe; \
powershell.exe -Command Start-Process vcredist_x86.exe -ArgumentList '/quiet'
| Wait-Process
RUN Invoke-WebRequest -UseBasicParsing
https://download.microsoft.com/download/9/1/4/914851c6-9141-443b-bdb4-
8bad3a57bea9/vcredist_x64.exe -OutFile vcredist_x86.exe; \
powershell.exe -Command Start-Process vcredist_x86.exe -ArgumentList '/quiet'
| Wait-Process

Powershell script to install Azure Service Fabric SDK, runtime and tools silently

I'm trying to write a script to download an install Azure Service Fabric SDK, runtime and tools into a few servers.
My issue is that the installer provided here is a Web Installer, and does not support silent mode.
I found a guy that solved this issue here. His code:
# Install Service Fabric Runtime
Invoke-WebRequest "http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabric.6.0.232.9494.exe" -OutFile "C:\ServiceFabricRuntime.exe" -UseBasicParsing; \
Start-Process "C:\ServiceFabricRuntime.exe" -ArgumentList '/AcceptEULA', '/QUIET' -NoNewWindow -Wait; \
rm "C:\ServiceFabricRuntime.exe"
# Install Service Fabric SDK
Invoke-WebRequest "http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabricSDK.2.8.232.msi" -OutFile "C:\ServiceFabricSDK.msi" -UseBasicParsing; \
Start-Process "msiexec" -ArgumentList '/i', 'C:\ServiceFabricSDK.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait; \
rm "C:\ServiceFabricSDK.msi"
As you can see, he's using direct links to the .msi installers (as well as other guys are doing in other threads like these two answers.).
So my questions is, how do i get a direct link to the msi with the latest version of these installers?
And the follow up question would be, is there a universal link that will automatically download the latest version of these tools?
Thanks in advance.
I know this is not exactly what you asked for but you can use Web Platform Installer Command Line to install WebPI products silently. The idea is to download WebPICMD and run installation of Service Fabric SDK from the cmd line. The powershell script can look like this:
Invoke-WebRequest "https://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi" -OutFile "C:\WebPlatformInstaller.msi" -UseBasicParsing;
Start-Process "msiexec" -ArgumentList '/i', 'C:\WebPlatformInstaller.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait;
rm "C:\WebPlatformInstaller.msi"
WebPICMD.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEULA
Product MicrosoftAzure-ServiceFabric-CoreSDK will install latest version of Service Fabric SDK and Service Fabric Runtime silently.
If you want to install something different from the WebPI run :
WebPICMD.exe /List /ListOption:All
This command will list all of the available products, just grab the id of the product and run install command.
More about WebPICMD here.
To add on the answer above, if WebPlatformCMD gives you Windows' UAC consent window issues, you can use PSEXEC tools to run the installer as system account, avoiding that problem.
Example code:
Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkId=287166" -OutFile "$env:temp\WebPlatformInstaller_amd64_en-US.msi" -UseBasicParsing
Start-Process "msiexec" -ArgumentList "/i $env:temp\WebPlatformInstaller_amd64_en-US.msi /passive /quiet /norestart /qn" -NoNewWindow -Wait
$psToolsPath = "$env:temp\pstools"
New-Item $psToolsPath -ItemType directory -force -erroraction silentlycontinue
Invoke-WebRequest -Uri https://download.sysinternals.com/files/PSTools.zip -OutFile $psToolsPath\PSTools.zip
Expand-Archive "$psToolsPath\PSTools.zip" $psToolsPath -force
cd $psToolsPath
Start-Process psexec64 -ArgumentList "-s /accepteula WebPICMD.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEULA"
Small note on SteppingRazor's answer above.
You can ease out the ArgumentList Parameter value like this:
Start-Process "msiexec" -ArgumentList "/i C:\WebPlatformInstaller.msi /passive /quiet /norestart /qn -NoNewWindow -Wait
Instead of
Start-Process "msiexec" -ArgumentList '/i', 'C:\WebPlatformInstaller.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait;
Then using variables in the string is also easier.