"Start-Transcript : This host does not support transcription." -- Error. How can we resolve this?
Note: My issue is resolved, as I kept Remove-Item in starting of my code and then it works.
Appreciate if you can demonstrate why it is not working at the end of the code.
You are asking for a "Magic Crystal Ball" answer. You want to know why transcripts don't work, but you have provided no details about your environment. Forum users have no idea if you are running Win7, Win10, or Linux. Or what version of Powershell you have installed.
You want me to explain to you why moving statements in the script causes it to work. But you haven't shared the source code for me to examine. I have have no idea why YOUR CODE is doing what it is doing. If transcripts are not available, then add in your own debugging and logging statements so that you can examine what execution path the script is taking. Be sure to include try/catch error handling in case your script runs into unexpected errors.
Start-Transcript is available (at least) in Powershell 5.1. You could install that version, but I have no idea what impact that would have on other scripts.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view=powershell-5.1