Hi
I’m rather PS rookie but I’ve managed to setup O365 installtion using PSADT and all looks great.
There is one last thing which I would love to add but just can’t sort it and would appreciate any help.
How and where in Deploy-Application.ps1 I could add a line which says something like:
If (“installaton was sucesfull”) {do A} else {do B}? Is it possible at all?
I was thinking I could check $LASTEXITCODE and based on this do A or B.
Thanks but this doesn’t answer my question.
I have tried to insert in Deploy-Application.ps1 this line just for testing:
if ($LASTEXITCODE -eq 0 ) { New-Item C:\Users\Public\Documents\O365\done.txt } else { New-Item C:\Users\Public\Documents\O365\not.txt }
but it does nothing. I have added for testing in Post-Installation section but also I have tried other places and nothing. Hence my question, is that a correct way and if yes where I should add it?
I’ve been fooled by Office’s Setup.exe.
The licensing would fail at the start but setup.exe would still return 0 and not an EXE was installed.
I resorted to Test-path "<path>\excel.exe" and that was 3 years ago.
Thanks but with o365 and Click2Run licensing is not an issue as that happens after user run Word and logs in to O365 acc.
What I really would like to know is how I could get exit code from installation and based on that I want to do IF.
I have notticed that if I will do:
straight after this line if I will use $LASTEXITCODE I get 0 or 1, depnds if installation was sucesfull or not. So seems to be OK.
but If strait after this I will add just for testing:
$results = Execute-Process -Path "setup.exe" -Parameters "/configure configuration.xml" -ContinueOnError $true -ExitOnProcessFailure $false -PassThru
#CAVEAT: PSADT introduced -ExitOnProcessFailure arround 3.8.3.
#By default ($ExitOnProcessFailure = $true) will call Exit-Script and anything after this line is ignored
#If you want the goodies that -PassThru gives you, you need -ExitOnProcessFailure $false
#I collect the log files here but most people don't care. Code removed
#Did it work?
If (3010,1641,0 -contains $($results.ExitCode) ) {
Write-Log "Exitcode [$($results.ExitCode)] means success!"
} Else {
$mainExitCode = $results.ExitCode
[string]$Message = "${$results.STDErr |Out-String} ${$results.STDOut |Out-String}" #Out-String cleans up the output to make sure Write-log can handle it
Write-Log "Exitcode [$($results.ExitCode)] means Setup.exe failed. [$Message]" -Severity 3
Start-Sleep -Seconds 5 #delay to let you read error in the console (if shown)
Exit-Script -ExitCode $mainExitCode
}
Sorry if im out of topic, i will create a new post if you want.
I read somewhere that you could use exit/error code to catch a pending reboot lets say before i start a new required install. Can i do that and what error code can i use?