instead of copying the subroutine verbatim, import the function itself. It's defined in CourseManagement, so our wwsh script only actually needs two lines.
# tell WeBWorK to import 'initNonNativeTables' from WeBWorK/Utils/CourseManagement.pm
use WeBWorK::Utils::CourseManagement 'initNonNativeTables';
# execute the subroutine as called in CourseAdmin.pm
my $table_update_result = initNonNativeTables($ce, $ce->{dbLayoutName});
# see what's in the return value
warn Dumper($table_update_result);
exit;