Error when importing a module

gregnnylf94

I am creating a useful powershell module for myself, for repetitive tasks.

As an example I will use one function within the module.

function GetUserInfo
{
    $user_name = $env:UserName
    $user_domain = $env:UserDomain
    $user_computer = $env:COMPUTERNAME
    $user_ip = [System.Net.Dns]::GetHostAddresses($user_computer);
    $user_ip = $user_ip[1].IPAddressToString

    return $user_info = "$user_domain/$user_ip/$user_computer/$user_name"
}
export-modulemember -function GetUserInfo

Every time I try to load the module

Import-Module \\erpscriptprod\Library\PowerShell\PowerShell_BaseLibrary.ps1

I get the followoing error...

The Export-ModuleMember cmdlet can only be called from inside a module

I am new to powershell, but from where I'm sitting, I swear I am calling it inside the module. I can't seem to find the error online, but I doubt I'm the only person to experience this.

Moerwald

Rename your *.ps1 file to *.psm1. You can only export members from a module, when you call Export-ModuleMember.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Module not found error when importing

From Dev

Parse error on input ‘module’ when importing a module

From Dev

Python Module Not Found Error when importing package

From Dev

Error when importing python module from folders

From Dev

Attribute error when importing VLC module in python

From Dev

Error occuring when importing module "threading"

From Dev

Cannot find module error when importing a module with exported enums

From Dev

Module not found error when importing Pyspark Delta Lake module

From Dev

How to fix SimpleQueue error when importing the Laspy module in Python?

From Python

Python gives error when importing simple C extension module

From Dev

Ionic Uncaught Error: Cannot find module "." when importing a service provider

From Dev

"Cannot find module" error when importing mp3

From Dev

Error when importing module from a different folder in the same parent directory

From Dev

Error when importing the returned value of a function in a different module using Python

From Dev

Getting 'no such module' error when importing a Swift Package Manager dependency

From Dev

Error "Cannot find module" when importing a remote JSON file in TypeScript

From Dev

Error when importing "date-fns" into a Svelte Module

From Dev

Error after importing module Volley

From Dev

Travis CI error importing module

From Dev

error importing module and loading files

From Dev

Module installed but error importing cartopy

From Dev

Error when importing PyMC

From Dev

Error when importing matplotlib

From Dev

Python Import Error (ModuleNotFoundError) when importing a function from a module that imports a class from another module

From Java

importing a module when the module name is in a variable

From Dev

ModuleNotFoundError when importing a module that is importing itself another module

From Dev

I get a 'No module named 'alpha_vantage'' error when i try importing alpha_vantage on Spyder

From Dev

'Cannot find module fingerprintjs2' error when importing the library in Angular project

From

When importing tensorflow, I get the following error: No module named 'numpy.core._multiarray_umath'

Related Related

  1. 1

    Module not found error when importing

  2. 2

    Parse error on input ‘module’ when importing a module

  3. 3

    Python Module Not Found Error when importing package

  4. 4

    Error when importing python module from folders

  5. 5

    Attribute error when importing VLC module in python

  6. 6

    Error occuring when importing module "threading"

  7. 7

    Cannot find module error when importing a module with exported enums

  8. 8

    Module not found error when importing Pyspark Delta Lake module

  9. 9

    How to fix SimpleQueue error when importing the Laspy module in Python?

  10. 10

    Python gives error when importing simple C extension module

  11. 11

    Ionic Uncaught Error: Cannot find module "." when importing a service provider

  12. 12

    "Cannot find module" error when importing mp3

  13. 13

    Error when importing module from a different folder in the same parent directory

  14. 14

    Error when importing the returned value of a function in a different module using Python

  15. 15

    Getting 'no such module' error when importing a Swift Package Manager dependency

  16. 16

    Error "Cannot find module" when importing a remote JSON file in TypeScript

  17. 17

    Error when importing "date-fns" into a Svelte Module

  18. 18

    Error after importing module Volley

  19. 19

    Travis CI error importing module

  20. 20

    error importing module and loading files

  21. 21

    Module installed but error importing cartopy

  22. 22

    Error when importing PyMC

  23. 23

    Error when importing matplotlib

  24. 24

    Python Import Error (ModuleNotFoundError) when importing a function from a module that imports a class from another module

  25. 25

    importing a module when the module name is in a variable

  26. 26

    ModuleNotFoundError when importing a module that is importing itself another module

  27. 27

    I get a 'No module named 'alpha_vantage'' error when i try importing alpha_vantage on Spyder

  28. 28

    'Cannot find module fingerprintjs2' error when importing the library in Angular project

  29. 29

    When importing tensorflow, I get the following error: No module named 'numpy.core._multiarray_umath'

HotTag

Archive