Thanks a mill,
The issue has been resolved,
The variable should have been:
$FSMORoles=netdom query FSMO > E:\Software\ReplicationScripts\FSMORoles.txt
Instead of:
$FSMORoles=netdom query FSMORoles > E:\Software\ReplicationScripts\FSMORoles.txt.
As you pointed out, the $FSMORoles variable had a few more inconsistencies which I have also corrected.
Thank you.