Thank you for trying the script. I have uploaded a new version that just skips securities that do not have an ISIN.
Regarding @Balmy6009 error, the secid 0P0000684V is of type Stock and will not be classified, but it should not return an error at the end. The first message of secid not in PortFolioSal is just informative and indicates that the script did not find the security in the standard web of MorningStar’s funds and ETFs and will try its x-ray service. The error at the end might be related to strange structure of the xray page used for retrieving the information when querying a stock instead of a fund/ETF. I made some changes to improve the robustness of the script in that sense. Try the new version and see what errors you get.