You have a couple problems here.
1. Your script is written in groovy, but the language you had selected was PowerShell.
2. Your DS was setup as a script but your collection script is setup to output like a batch script. Batch script is actually better in this case since your collection query is capable of collecting all the data for all the instances in one go. Unfortunately, you can't change this after the DS is created. I created a new DS with those corrections. Save this snippet as an XML file and import it into your portal (Settings>>DataSources>>Add>>From File). Then compare the differences. If you like this one, fix the name and you'll be good to go.
<?xml version="1.0" encoding="UTF-8" ?>
<feed version="1.0" hasPendingRequests="false" >
<company></company>
<status>200</status>
<errmsg>OK</errmsg>
<interval>0</interval>
<entry type="predatasource">
<version>1601394083</version>
<name>_SSL_Certificates_All_Weenig</name>
<displayedas>_SSL_Certificates_All_Weenig</displayedas>
<description></description>
<collector>batchscript</collector>
<hasMultiInstances>true</hasMultiInstances>
<schedule>180</schedule>
<appliesTo>join(system.groups,",") =~ "IT Ops Systems Management Group"</appliesTo>
<wildcardauto>true</wildcardauto>
<wildcardpersist>false</wildcardpersist>
<wildcardlinuxscript>ad_script</wildcardlinuxscript>
<wildcardlinuxcmdline>type="embeded" </wildcardlinuxcmdline>
<wildcardwinscript>ad_script</wildcardwinscript>
<wildcardwincmdline>type="embeded" </wildcardwincmdline>
<wildcardgroovyscript>import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
import com.santaba.agent.groovyapi.http.*;
import com.santaba.agent.groovyapi.jmx.*;
import org.xbill.DNS.*;
import groovy.sql.Sql // needed for SQL connection and query
import groovy.time.*
hostname = hostProps.get("system.hostname");
user = ''
pass = ''
SQLUrl = "jdbc:sqlserver://" + hostname + ";databaseName=master;integratedSecurity=true" //
sql = Sql.newInstance(SQLUrl, user, pass, 'com.microsoft.sqlserver.jdbc.SQLServerDriver')
sql.eachRow( 'SELECT name, expiry_date from sys.certificates'){
certname = it.name.toString().replaceAll("#","")
println(certname + "##" + certname)
}
sql.close() // Close connection</wildcardgroovyscript>
<wildcardschedule>0</wildcardschedule>
<wildcarddisable>false</wildcarddisable>
<wildcarddeleteinactive>true</wildcarddeleteinactive>
<agdmethod>none</agdmethod>
<agdparams></agdparams>
<group>_Certificates</group>
<tags></tags>
<technology></technology>
<adlist><![CDATA[{"agdmethod":"none","method":"ad_script","agdparams":"","id":0,"filters":[],"params":{"type":"embeded","groovyscript":"import com.santaba.agent.groovyapi.expect.Expect;\r\nimport com.santaba.agent.groovyapi.snmp.Snmp;\r\nimport com.santaba.agent.groovyapi.http.*;\r\nimport com.santaba.agent.groovyapi.jmx.*;\r\nimport org.xbill.DNS.*;\r\nimport groovy.sql.Sql // needed for SQL connection and query\r\nimport groovy.time.*\r\n\r\nhostname = hostProps.get(\"system.hostname\");\r\nuser = ''\r\npass = ''\r\n\r\nSQLUrl = \"jdbc:sqlserver://\" + hostname + \";databaseName=master;integratedSecurity=true\" //\r\nsql = Sql.newInstance(SQLUrl, user, pass, 'com.microsoft.sqlserver.jdbc.SQLServerDriver')\r\n\r\nsql.eachRow( 'SELECT name, expiry_date from sys.certificates'){\r\n\tcertname = it.name.toString().replaceAll(\"#\",\"\")\r\n println(certname + \"##\" + certname)\r\n}\r\nsql.close() // Close connection"}}]]></adlist>
<schemaVersion>2</schemaVersion>
<dataSourceType>1</dataSourceType>
<attributes>
<attribute>
<name>scripttype</name>
<value>embed</value>
<comment></comment>
</attribute>
<attribute>
<name>scriptgroovy</name>
<value>import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
import com.santaba.agent.groovyapi.http.*;
import com.santaba.agent.groovyapi.jmx.*;
import org.xbill.DNS.*;
import groovy.sql.Sql // needed for SQL connection and query
import groovy.time.*
hostname = hostProps.get("system.hostname");
user = ''
pass = ''
SQLUrl = "jdbc:sqlserver://" + hostname + ";databaseName=master;integratedSecurity=true" //
sql = Sql.newInstance(SQLUrl, user, pass, 'com.microsoft.sqlserver.jdbc.SQLServerDriver')
sql.eachRow( 'SELECT name, expiry_date from sys.certificates'){
certname = it.name.toString().replaceAll("#","")
daystoexpire = TimeCategory.minus(new Date(),Date.parse("yyy-MM-dd HH:mm:ss.S",it.expiry_date.toString()))
println(certname + ".daystoexpire: " + daystoexpire.getDays())
}
sql.close() // Close connection</value>
<comment></comment>
</attribute>
<attribute>
<name>windowsscript</name>
<value></value>
<comment></comment>
</attribute>
<attribute>
<name>linuxscript</name>
<value></value>
<comment></comment>
</attribute>
<attribute>
<name>windowscmdline</name>
<value></value>
<comment></comment>
</attribute>
<attribute>
<name>linuxcmdline</name>
<value></value>
<comment></comment>
</attribute>
</attributes>
<datapoints>
<datapoint>
<name>DaystoExpire</name>
<dataType>7</dataType>
<type>2</type>
<postprocessormethod>namevalue</postprocessormethod>
<postprocessorparam>##WILDVALUE##.daystoexpire</postprocessorparam>
<usevalue>output</usevalue>
<alertexpr></alertexpr>
<alertmissing>1</alertmissing>
<alertsubject></alertsubject>
<alertbody></alertbody>
<enableanomalyalertsuppression></enableanomalyalertsuppression>
<adadvsettingenabled>false</adadvsettingenabled>
<warnadadvsetting></warnadadvsetting>
<erroradadvsetting></erroradadvsetting>
<criticaladadvsetting></criticaladadvsetting>
<description></description>
<maxvalue></maxvalue>
<minvalue></minvalue>
<userparam1></userparam1>
<userparam2></userparam2>
<userparam3></userparam3>
<iscomposite>false</iscomposite>
<rpn></rpn>
<alertTransitionIval>0</alertTransitionIval>
<alertClearTransitionIval>0</alertClearTransitionIval>
</datapoint>
</datapoints>
<graphs>
</graphs>
<overviewgraphs>
</overviewgraphs>
<scripts>
</scripts>
</entry>
</feed>