Does the $dt variable have the servers in it? Are you getting an error? For the $sql, you are not using the $NewObj variable to enter the values from the...
I personally like using the dbatools PowerShell module - https://dbatools.io/. There are several commands, like Export-DBALogin, that can assist with scripting out logins or users and their permissions.
It looks like your function can return nothing. You will want to add code to account for that. For the the Try...Catch statement, you will want to add the parameter...