When writing Powershell functions to return single values (a string, for example) please ensure you pipe any calls to ‘Execute’ or ‘Close’ to ‘Out-Null’ (please see above). This will stop the function from returning a System.Object[] (since Powershell functions return the whole output from the function, and not just the value after the ‘return’ statement)!