Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4082450
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:11:21+00:00 2026-05-20T18:11:21+00:00

Given the following modules: adonetlib.psml param($ModelModule) $dbmodel=import-module $ModelModule -AsCustomObject function new-ADOnetconnection{ return $dbmodel.newconnection() }

  • 0

Given the following modules:

adonetlib.psml

param($ModelModule)

$dbmodel=import-module $ModelModule -AsCustomObject 

function new-ADOnetconnection{
   return $dbmodel.newconnection()
}

mysqlmodel.psm1

function newconnection{
   write-host "MySQL connection"
}

sqlservermodel.psm1

function newconnection{
   write-host "SQLServer connection"
}

I’d like to be able to do this:

$mysql= import-module adonetlib -argumentlist mysqlmodel -ascustomobject
$sqlserver= import-module adonetlib -argumentlist sqlservermodel -ascustomobject

and have the following be true (sorry about the syntax):

$mysql."new-adonetconnection"() -> returns "MySql connection"
$sqlsever."new-adonetconnection"() -> returns "SQLServer connection"

Apparently, though, the adonetlib module is only loaded once (even though we imported it with different arguments). Both statements return “MySQL connection”.

Also,

get-module -all 

shows that the mysqlmodel module is loaded, but sqlservermodel isn’t.

Any ideas about how I can get this to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:11:22+00:00Added an answer on May 20, 2026 at 6:11 pm

    The functionality you’re looking for may be present already in the Powershell Community Extensions:

    PS C:\Users\davidp> Get-command -Module pscx | ? { $_ -like "*-ado*" } | select name
    
    Name
    ----
    Get-ADObject
    Get-AdoConnection
    Get-AdoDataProvider
    Invoke-AdoCommand
    

    But in case you’re implementing just for fun:

    You might be better off using submodules to implement the polymorphic behavior it looks like you’re trying to achieve. The top-level module would export a single New-ADOnetConnection cmdlet, with a parameter to select which DB you want to use for that connection; then it would dynamically choose which submodule to use to carry out the command.

    If you’d like to avoid having to specify the DB on every call, you could create your own preference variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following module, module Foo def bar :baz end end def send_to_foo(method) #
I am unable to compile a linux kernel module, Given the following source: /*
Given the following XML 'template': <Request module=CRM call=list_service_features id={ID}> <block name=auth> <a name=username format=text>{USERNAME}</a>
I am new to Play and GWT and following the documentation given here .
I've written the following function to check whether a given singleton class implements a
Given the following: class User; attr_accessor :roles; end module RegisteredUser def default_context Submission end
Given a string with a module name, how do you import everything in the
Given following Ruby statements: (Read input and store each word in array removing spaces
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given the following XML: <current> <login_name>jd</login_name> </current> <people> <person> <first>John</first> <last>Doe</last> <login_name>jd</login_name> </preson> <person>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.