Windows 8 x64
PowerShell (from $PSVersionTable):
PSVersion 3.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.2.9200.17065
PSCompatibleVersions {1.0, 2.0, 3.0}
PSRemotingProtocolVersion 2.2
==================================================
Good day. Read a lot of posts on this forum and on other sites but didn't find solution for my problem: PS Studio don't show me any function from my module.
Module was created by PS Studio. It contains from 3d part libraries and functions inside .psm1. So I have next files structure:
├ PSLibraryPack
│ └─NLog
│─PSLibraryPack.psd1
│─PSLibraryPack.psm1
So in folder NLog I have .dll file that will not assembly by importing module, only with function from module. Also i create profile.ps1 and put it to C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1. Inside:
Code: Select all
<# Start code for import PSLibraryPack #>
Import-Module PSLibraryPack -Force -DisableNameChecking
<# End code for import PSLibraryPack #>
Here code from .psm1:
Code: Select all
function Set-ReturnObject {
$obj = New-Object System.Management.Automation.PSObject
Add-Member -InputObject $obj -MemberType NoteProperty -Name success -Value $false
Add-Member -InputObject $obj -MemberType NoteProperty -Name errorInfo -Value $null
Add-Member -InputObject $obj -MemberType NoteProperty -Name result -Value $null
return $obj
}
function NLog.Get-Library {
$returnObject = Set-ReturnObject
try {
[System.Void][System.Reflection.Assembly]::LoadFile($Script:PSScriptRoot + "\NLog\NLog.dll")
$returnObject.success = $true
} catch {
$returnObject.errorInfo = $Error[0]
}
return $returnObject
}
function NLog.Set-Logger {
[CmdletBinding()]
param
(
[Parameter(Mandatory = $false,
Position = 0)]
[System.String]$loggerName,
[Parameter(Mandatory = $false,
Position = 1)]
[System.String]$logsDir
)
$returnObject = Set-ReturnObject
try {
$nlogConfig = New-Object NLog.Config.XmlLoggingConfiguration($Script:PSScriptRoot + "\NLog\NLog.xml")
[NLog.LogManager]::Configuration = $nlogConfig
if ($logsDir) {
$target = [NLog.LogManager]::Configuration.FindTargetByName("logfile")
$target.FileName = $logsDir + "\`${shortdate}.log"
[NLog.LogManager]::ReconfigExistingLoggers() | Out-Null
}
if ($loggerName) {
$logger = [NLog.LogManager]::GetLogger($loggerName)
} else {
$logger = [NLog.LogManager]::GetLogger("nlog")
}
$returnObject.success = $true
$returnObject.result = $logger
} catch {
$returnObject.errorInfo = $Error[0]
}
return $returnObject
}
Export-ModuleMember NLog.Get-Library
Export-ModuleMember NLog.Set-Logger
Code: Select all
<#
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.117
Created on: 21.03.2016 21:23:09
Created by: Alexander Tarassenko
Organization: Roga i kopyta
Filename: PSLibraryPack.psd1
-------------------------------------------------------------------------
Module Manifest
-------------------------------------------------------------------------
Module Name: PSLibraryPack
===========================================================================
#>
@{
# Script module or binary module file associated with this manifest
ModuleToProcess = 'PSLibraryPack.psm1'
# Version number of this module.
ModuleVersion = '1.0.1.0'
# ID used to uniquely identify this module
GUID = '4b44e42b-1060-4108-8166-c28bdb5e0d91'
# Author of this module
Author = 'Alexander Tarassenko'
# Company or vendor of this module
CompanyName = 'Roga i kopyta'
# Copyright statement for this module
Copyright = '(c) 2016. All rights reserved.'
# Description of the functionality provided by this module
Description = 'PowerShell Library Pack Module'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '3.0'
# Name of the Windows PowerShell host required by this module
PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
PowerShellHostVersion = ''
# Minimum version of the .NET Framework required by this module
DotNetFrameworkVersion = '4.0'
# Minimum version of the common language runtime (CLR) required by this module
CLRVersion = '4.0'
# Processor architecture (None, X86, Amd64, IA64) required by this module
ProcessorArchitecture = 'None'
# Modules that must be imported into the global environment prior to importing
# this module
RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to
# importing this module
ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @()
# Modules to import as nested modules of the module specified in
# ModuleToProcess
NestedModules = @()
# Functions to export from this module
FunctionsToExport = '*'
# Cmdlets to export from this module
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module
AliasesToExport = '*'
# List of all modules packaged with this module
ModuleList = @()
# List of all files packaged with this module
FileList = @()
# Private data to pass to the module specified in ModuleToProcess
PrivateData = @{
#Support for PowerShellGet galleries.
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
}
So why in PowerShell I can see cmdlet but not in PSStudio? I tried to use CacheBuilder but it's not helped: files that must contains cmdlets for module are empty: What I'm doying wrong? Please help )