SharePoint Installation Error: Windows cannot find e:\prerequisiteinstaller.exe

To install SharePoint we attaching SharePoint setup ISO. It seems due to the same after installation complete, it is looping this error after login to server.

This issue I face in SharePoint 2013 to SharePoint 2019 and the solution will work for all the version mentioned. So just run the below powershell script it will delete the .CMD file from startup and after that command popup won’t appear after login to server.

$path="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
$file= Get-ChildItem $path -Recurse -Force -Filter SharePointServerPreparationToolStartup* | Where-Object {!$_.PSIsContainer}
if($file -ne $null) 
{
	$file | Remove-Item
	Write-Host "File $($file.Name) removed successfully" -ForegroundColor green
}
else
{
   Write-Host "File not found" -ForegroundColor red
}

Get error line number powershell program

If someone wrote a PowerShell program, with multiple lines and without caring the coding standard and you got stuck to find where the error is, so very simplest way which I am thinking is just use below piece of code which saves your time and let you know about a line which is having an issue.

InvocationInfo can provide information about how and where this command was invoked

So just use simple try-catch like below

try {
    #<replace with your code>
}
catch {
    $_ |select -expandproperty invocationinfo
    write-host "$($_.Exception.Message)" -foregroundcolor red  
    break;
}