This script is working on the same machine in Powershell ISE and but is not working while invoking the PS code in Studio
Error :
Invoke Power Shell: Exception calling “Open” with “0” argument(s): “The type initializer for ‘System.Data.SqlClient.TdsParser’ threw an exception.”
Screenshot of function in the Powershell script: