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.
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.
Comments