Hello,
I've just started playing around with the new application model in SCCM 2012 and in the meanwhile I'm reviewing the installation procedures. In ConfigMgr 2012 I would like to use the application model and use Powershell scripting to do additional actions where possible.
I'm having an issue trying to install an application (Lotus Notes) where I have some additional actions to perform. I use a Powershell script to wrap the setup and the additional actions together.
When I run the script from Powershell_ise it completes successful (exitcode 0) but a folder and some icons are not created in %ProgramData%\Microsoft\Windows\Start Menu\Programs. When I run the script from an elevated Powershell_ise the installation is as it should be, including the folder and icons. I use Start-Process to run the msiexec... If I use the -Verb Runas parameter (without the -Wait parameter) the installation also completes successful. Problem here is that I also use the -Wait parameter which seems to cause issues in combination with the -Verb Runas parameter. So I need a way to elevate the script (I think)
In ConfigMgr 2007 you can run a program "as administrator" but in ConfigMgr 2012's applications there does not seem to be an option to do so. Note: In 2007 I sequenced 2 programs, one for the install and one (batch file) for the additional actions so I'm not sure if the script would work this way.
Does anyone know how to run the script using the application model with elevated rights?
Script looks like this:
Begin { $ErrorActionPreference = "STOP" $ScriptDirectory = split-path -parent $MyInvocation.MyCommand.Definition $Application = "`"$ScriptDirectory\Lotus Notes 8.5.3\Lotus Notes 8.5.3.msi`"" $InstallDir = "`"C:\Program Files (x86)\Lotus\Notes`"" $DataDir= "`"C:\Program Files (x86)\Lotus\Notes\Data`"" $Logfile = "`"$env:LOGDIR\CCM\LotusNotes853.log`"" $Arguments = @("/i", $Application, "/q", "DATADIR=$DataDir", "PROGDIR=$InstallDir", "/l*", $Logfile) } Process { $Install = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -wait -PassThru $Exitcode = $Install.ExitCode Try { Copy-Item -Path "\\mydomain\Cfg\Lotus\icons\*.ico" -Destination "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Lotus Applications\" -Force Copy-Item -Path "\\mydomain\Cfg\Lotus\notes.ini" -Destination "C:\Program Files (x86)\Lotus\Notes\" -Force Copy-Item -Path "\\mydomain\Cfg\Lotus\setup.txt" -Destination "C:\Program Files (x86)\Lotus\Notes\data\" -Force Copy-Item -Path "\\mydomain\sys01\Cfg\Lotus\Dic\*.dic" -Destination "C:\Program Files (x86)\Lotus\Notes\data\" -Force } Catch { $Exitcode = "1604" Add-Content $logfile.Substring(1,$logfile.Length-2) $error[0] } } #End Process End { return $Exitcode }
Also I was wondering if SCCM actually picks up the Exitcode the script returns?
Thanks!