Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .Synopsis
- Install Windows artefacts upon which our applications are dependent
- .Description
- Ensure that all drive references are to C, never to D etc.
- .Example
- Install-WindowsArtefacts -RemoteComputerName "dennis-pc" -BinariesLocation \sandbox\PowerShell\artefacts -LocalTest
- #>
- function Install-WindowsArtefacts
- {
- Param (
- [Parameter(Mandatory=$true, Position=0)]
- [string[]]
- $RemoteComputerName,
- [Parameter(Mandatory=$true, Position=1)]
- [string]
- $BinariesLocation,
- [Parameter(Mandatory=$false, Position=2)]
- [switch]
- $LocalTest
- )
- Begin {
- $localComputer = $env:COMPUTERNAME
- }
- Process {
- $VCR32 = "vcredist_x86.exe"
- $VCR64 = "vcredist_x64.exe"
- $CRR = "CRRuntime_12_0_mlb.msi"
- $DOTNET451 = "NDP451-KB2858728-x86-x64-AllOS-ENU.exe"
- $subFolder = ""
- if ($LocalTest) {
- $subFolder = 'subFolder'
- }
- foreach ($computer in $RemoteComputerName) {
- if (!(Test-Path -Path "\\$computer\C$\$BinariesLocation\$subFolder")) {
- New-Item -ItemType Directory "\\$computer\C$\$BinariesLocation\$subFolder"
- }
- Copy-Item -Path \\$localComputer\C$\$BinariesLocation\$VCR32 -Destination \\$computer\C$\$BinariesLocation\$subFolder\$VCR32 -Force
- Copy-Item -Path \\$localComputer\C$\$BinariesLocation\$VCR64 -Destination \\$computer\C$\$BinariesLocation\$subFolder\$VCR64 -Force
- Copy-Item -Path \\$localComputer\C$\$BinariesLocation\$CRR -Destination \\$computer\C$\$BinariesLocation\$subFolder\$CRR -Force
- Copy-Item -Path \\$localComputer\C$\$BinariesLocation\$DOTNET451 -Destination \\$computer\C$\$BinariesLocation\$subFolder\$DOTNET451 -Force
- $session = New-PSSession -ComputerName $computer
- Invoke-Command -Session $session -ScriptBlock {
- param($BinariesLocation1, $subFolder1, $VCR321, $VCR641, $CRR1,$DOTNET4511 )
- Start-Process -FilePath "C:\$BinariesLocation1\$subFolder1\$VCR321" -ArgumentList "/q /norestart" -wait
- Start-Process -FilePath "C:\$BinariesLocation1\$subFolder1\$VCR641" -ArgumentList "/q /norestart" -wait
- Start-Process -FilePath "C:\$BinariesLocation1\$subFolder1\$CRR1" -ArgumentList "/q /norestart" -wait
- Start-Process -FilePath "C:\$BinariesLocation1\$subFolder1\$DOTNET4511" -ArgumentList "/q /norestart" -wait
- } -ArgumentList ($BinariesLocation, $subFolder, $VCR32, $VCR64, $CRR,$DOTNET451)
- Remove-PSSession $session
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement