    #set -x; -- removing shell tracing to avoid unnecessary logging in console
    installerlog='/var/log/sut/sut_installer.log';
    if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
	    echo $(date) "Preparing to uninstall SUT" >> $installerlog ;

	    if [ -f /opt/hp/hpsut/bin/hpsut ];
	    then
		    /opt/hp/hpsut/bin/hpsut -deregister >> $installerlog  2>&1;
	    else
	        /opt/sut/bin/sut -installer -deregister >> $installerlog  2>&1;
	    fi;

	    if [ $? -eq 0 ];
	    then
		    echo $(date) "iSUT de-registered successfully" >> $installerlog;
	    else
		    echo $(date) "iSUT de-registeration failed" >> $installerlog;
		    echo "iLO is in High Security Mode. iSUT failed to communicate with iLO.";
		    echo "iSUT deregistration failed.";
		    echo "iSUT namespace RIS data will not be cleared." ;
		    echo "Proceeding with iSUT uninstallation." ;
	    fi;
		# Remove application token during uninstallation
		/opt/sut/bin/sut -detectilo >> $installerlog  2>&1
		ret_val=$?
		
		if [ $ret_val -eq 0 ]; then
			echo "Deleting application account for iSUT from iLO&TPM."
				/opt/sut/bin/sut -delapptoken >> $installerlog  2>&1
			ret_val=$?
			if [ $ret_val -eq 0 ]; then
				echo "Successfully deleted application account"
				echo "Successfully deleted application account" >> $installerlog
			elif [ $ret_val -eq 1 ]; then
				echo "Application account does not exist"
				echo "Application account does not exist" >> $installerlog
			else
				echo "Application account removal failed"
				echo "Application account removal failed" >> $installerlog
			fi;
		elif [ $ret_val -eq 1 ]; then
			echo "iLO 5/6 version detected. Application account deletion skipped" >> $installerlog
		elif [ $ret_val -eq 2 ]; then
			echo "Detecting iLO version failed. Application account could not be removed"
			echo "iLO type detection failed. Application account could not be removed" >> $installerlog
		elif [ $ret_val -eq 4 ]; then
			echo "Unable to access iLO using virtual NIC. Application account could not be removed."
			echo "Unable to access iLO using virtual NIC. Application account could not be removed." >> $installerlog
		else
			echo "Invalid case." >> $installerlog
		fi;
    fi