Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- Script to install required apps to a recently deployed VM template
- .DESCRIPTION
- This script installs required applications to a newly deployed server.
- It's executed from the VM deployment scripts in vCenter.
- .NOTES
- #>
- #--------------------------------
- # Variables
- #--------------------------------
- $InstallersDir = "\\VMAUTOserver\Installers"
- $WorkingDir = "C:\VMTemplateDeploymentTemp"
- #--------------------------------
- # Create temp working directory
- #--------------------------------
- Write-Host "Creating $WorkingDir"
- New-Item -ItemType directory -Path "$WorkingDir"
- #--------------------------------
- # Copy installers
- #--------------------------------
- Write-Host "Copying Red Cloak Installer to working directory."
- Copy-Item "$InstallersDir\redcloak.msi" -Destination "$WorkingDir"
- Write-Host "Copying Cisco Amp Installer to working directory."
- Copy-Item "$InstallersDir\amp_Server.exe" -Destination "$WorkingDir"
- #--------------------------------
- # Install Apps
- #--------------------------------
- ### Install Red Cloak
- Write-Host "Installing Red Cloak"
- Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$WorkingDir\redcloak.msi`" /qn /passive" -Wait
- ### Install Cisco AMP with Server Policy
- Write-Host "Installing Cisco Amp"
- Start-Process -FilePath "$WorkingDir\amp_Server.exe" -ArgumentList '/S'
- ### Wait for the Cisco amp service to be created and running
- $AmpService = "CiscoAmp*"
- If ((Get-Service $AmpService).Status -ne 'Running') {
- do {
- Write-Host 'Waiting for Cisco Amp service to be created and get to a Running state.'
- Start-Sleep 5
- } until ((Get-Service $AmpService).Status -eq 'Running')
- }
- Write-Host "Cisco Amp service has STARTED"
- Start-Sleep -seconds 5
- #--------------------------------
- # Clean it all up
- #--------------------------------
- Write-Host "Cleaning up and deleting installers from C:"
- #Remove-Item -Path "$WorkingDir\amp_Server.exe"
- #Remove-Item -Path "$WorkingDir\redcloak.msi"
- Remove-Item -LiteralPath "$WorkingDir\" -Recurse -Force
- #--------------------------------
- # Windows Updates
- #--------------------------------
- ### Check if PSWindowsUpdate module exists. Install if not.
- if (Get-Module -ListAvailable -Name PSWindowsUpdate) {
- Write-Host "PSWindowsUpdate module exists."
- } else {
- Write-Host "PSWindowsUpdate module does not exist. Installing now."
- Install-Module -Name PSWindowsUpdate -Force
- }
- Write-Host "Windows Updates - Installing all..."
- Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot
- # Clean up the WinSxS component store and optimize the image with DISM
- Write-Host "Cleaning up the WinSxS component store and optimizing the image with DISM"
- Dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
- #--------------------------------
- # Reboot Server
- #--------------------------------
- Write-Host "Rebooting $env:computername"
- shutdown.exe /r /t 60
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement