2017-02-07 2 views
1

반복적 인 작업을 위해 자신을 위해 유용한 powershell 모듈을 만들고 있습니다.모듈을 가져올 때 오류가 발생했습니다.

예를 들어 모듈 내에서 하나의 기능을 사용합니다.

내보내기-ModuleMember cmdlet을하는 것은 단지 모듈

내부에서 호출 할 수 있습니다

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 

내가

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

내가 얻을 모듈에게 followoing 오류를로드 할 때마다 ...

나는 powershell을 처음 사용하지만, 앉아있는 곳에서 나는 맹세한다. 모듈 내부. 온라인에서 오류를 찾을 수는 없지만이 문제를 경험할 수있는 유일한 사람은 아닌지 의심 스럽습니다.

+0

'PowerShell_BaseLibrary.ps1' ->'PowerShell_BaseLibrary.psm1' – BenH

+0

@BenH 잘 모르겠다. 내가 가져올 때? – gregnnylf94

+0

'.ps1'은 모듈 파일이 아닙니다. 스크립트의 이름을 바꿉니다. – BenH

답변

1

* .ps1 파일의 이름을 * .psm1로 변경하십시오. Export-ModuleMember으로 전화하면 모듈에서 멤버 만 내보낼 수 있습니다.

관련 문제