I used a similar script to yours. Please try to access the 23R1 version.
Please Login to Report Topic
Please Login to Share Feed