Resolve-Error is not recognized as the name of a cmdlet

Hello All,
Good Day!

I have create an app and wrapped it using PSADT. The wrapped application installs all fine when deployed from SCCM. When I use the same source in Intune for OOBE the installation fails. When I try to run the Deploy-Applications.ps1 manually during OOBE, i get to see an error stated below:
Resolve-Error : The term Resolve-Error is not recognized as the name of cmdlet, Script file. or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The error is seen at line:
Catch{
[String]$mainerrormessage = “$(Resolve-Error)”
}

I haven’t changed anything from the template, and have just included command to install the executable.

Kindly assist on the issue as I am stuck with no clue whats wrong!!

Many thanks in advance.

Regards,
Avi

Resolve-Error is a PSADT function but it doesn’t get declared until AppDeployToolkitMain.ps1 is loaded but Deploy-Applications.ps1 takes about 100 lines before it gets there.

I’ve reported this as a bug but it won’t be included until PSADT 4.0.

If you change the Catch statement at the end of Deploy-Applications.ps1 with this, you will have a log file created in %temp%.

	##*===============================================
	##* END SCRIPT BODY
	##*===============================================

	## Call the Exit-Script function to perform final cleanup operations
	Exit-Script -ExitCode $mainExitCode
}
Catch {
	[int32]$mainExitCode = 60001
    if ($([BOOL](Get-Command Resolve-Error -errorAction SilentlyContinue)) ) {
        [string]$mainErrorMessage = "$(Resolve-Error)"
        Write-Log $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
		Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
		Exit-Script -ExitCode $MainExitCode
    } Else { #Resolve-Error and Exit-Script don't exist yet
		[String]$mainErrorMessage = @{'Message:' = "$($_.Exception.Message)";'ScriptStackTrace:'="$($_.ScriptStackTrace)";'InnerException:'="$($_.Exception.InnerException)"} `
        | Format-Table -AutoSize -Wrap -HideTableHeaders | Out-String
		[String]$AlternateLogPath = "$Env:TEMP\$(($MyInvocation.MyCommand.name) -replace '.ps1','.log' )"
		Set-Content -Path $AlternateLogPath -Value "ExitCode = [$mainExitCode] `r`n [$mainErrorMessage]" -ErrorAction SilentlyContinue
		Write-error "ExitCode = [$mainExitCode] `r`n [$mainErrorMessage] `r`n [$AlternateLogPath]"
        Start-Sleep -Seconds 10
		$host.SetShouldExit($mainExitCode)
    	exit
    }
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.