Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have implemented exactly what you are looking for at my current project. We need to automate deployment and instillation of n number of apps across multiple environments and datacenters. These scripts are slightly modified from the original version for simplicity sake since my complete code is reaching 1000 lines but the core functionality is intact. I hope this does what you are asking for.</p> <p>This PS function pulls all the apps from the registry (what add/remove programs reads from) and then search's for the supplied app name and display version. In my code (PSM1) I run this function before I install to whether or not it is their and then afterword’s to verify that it got installed…. All this can be wrapped in one master function to manager flow control.</p> <pre><code>function Confirm-AppInstall{ param($AppName,$AppVersion) $Apps = Get-ItemProperty Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*|?{$_.DisplayName -ne $Null}|?{$_.DisplayName -ne ""} $Apps += Get-ItemProperty Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*|?{$_.DisplayName -ne $Null}|?{$_.DisplayName -ne ""} $Installed = $Apps|?{$_.DisplayName -eq ""}|?{$_.DisplayVersion -eq ""}|select -First 1 if($Installed -ne $null){return $true}else{return $false} } </code></pre> <p>This PS function will load a txt file that has the install commands prepopulated (one command per line). and run each line indivaduly and wait for the install to complete before moving on to the next.</p> <pre><code>function Install-Application{ param($InstallList = "C:\Install_Apps_CMDS.txt") $list = gc -Path $InstallList foreach ($Command in $list){ Write-Output ("[{0}]{1}" -f (Get-Date -Format G),$call) #Make install process wait for exit before continuing. $p = [diagnostics.process]::Start("powershell.exe","-NoProfile -NoLogo -Command $Command") $p.WaitForExit() Start-Sleep -Seconds 2 #Searches for the installer exe or msi that was directly opened by powershell and gets the process id. $ProcessID = (gwmi -Query ("select ProcessId from Win32_Process WHERE ParentProcessID = {0} AND Name = '{1}'" -f $p.Id,$ParentProcessFile)|select ProcessId).ProcessId #waits for the exe or msi to finish installing while ( (Get-Process -Id $ProcessID -ea 0) -ne $null){ Start-Sleep -Seconds 2 $ElapsedTime = [int](New-TimeSpan -Start $P.StartTime -End (Get-Date)|select TotalSeconds).TotalSeconds #install times out after 1000 seconds so it dosent just sit their forever this can be changed if(2000 -lt $ElapsedTime){ Write-Output ('[{0}] The application "{1}" timed out during instilation and was forcfully exited after {2} seconds.' -f (Get-Date -Format G),$App.Name,(([int]$App.InstallTimeOut) * 60)) break } } #clean up any old or hung install proccess that should not be running at this point. Stop-Process -Name $ParentProcessName -ea 0 -Force Stop-Process -Name msiexec -ea 0 -Force } } </code></pre> <p>The TXT file should be formatted as such... you will need to do you research on how to each app needs to be installed. a good resource is appdeploy.com</p> <pre><code>C:\Install.exe /q C:\install.msi /qn TRANSFORMS='C:\transform.mst' C:\install2.msi /qn /norestart C:\install3.exe /quiet </code></pre> <p>Let me know if there are any errors I had to modify my existing code to remove the proprietary values and make this a little more simplistic. I am pulling my values from a custom XML answer sheet. But this code should work as I have supplied it.</p> <p>If you would like for me to discuss more about my implementation let me know and i can make a more detailed explanation and also add more of the supporting functions that I have implemented.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload