Powershell Binary Module not found but installed - powershell

I've created a Binary Powershell Module called ODBCManager. After installing from a feed, I am able to use it's functions successfully, but Get-Module does not find it by name (Get-Module -Name ODBCManager returns null). Get-Module -ListAvailable will show it after a 2 minute query, so it's definitely installed. Also -Verbose on installation says success.
C:\Users\xxxxx> Get-Module -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Binary 0.1.0.1 ODBCManager {Add-OracleODBC, Get-ODBCDrivers, New-OracleODBC}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script 3.4.0 Pester {Describe, Context, It, Should...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove-PSReadlineKeyHandler, Get-PSReadlineOption...}
Manifest 20.0 SqlServer {Add-SqlColumnEncryptionKeyValue, Complete-SqlColumnMasterKeyRotation, Get-SqlColumnEncryptionKey, Get-SqlColumnMasterKey...}
Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 ActiveDirectory {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-ADDomainControllerPasswordReplicationPolicy, Add-ADFineGrainedPasswordPolicySu... Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnosticLog, Set-AppBackgroundTaskResourcePolicy, Unregister-AppBackgroundTask...} Manifest 2.0.0.0 AppLocker {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPolicy, Set-AppLockerPolicy...}
Manifest 1.0.0.0 AppvClient {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add-AppvPublishingServer, Disable-Appv...}
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage...}
Script 1.0.0.0 AssignedAccess {Clear-AssignedAccess, Get-AssignedAccess, Set-AssignedAccess}
Manifest 1.0 BestPractices {Get-BpaModel, Get-BpaResult, Invoke-BpaModel, Set-BpaResult}
......................
Directory: C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0 SQLASCMDLETS {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}
Manifest 1.0 SQLPS {Backup-SqlDatabase, Add-SqlAvailabilityDatabase, Add-SqlAvailabilityGroupListenerStaticIp, Disable-SqlAlwaysOn...}
Directory: C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 2.0 SQLASCMDLETS {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}
Manifest 1.0 SQLPS {Add-SqlColumnEncryptionKeyValue, Complete-SqlColumnMasterKeyRotation, Get-SqlColumnEncryptionKey, Get-SqlColumnMasterKey...}
C:\Users\xxxxxx> Install-Module -Name ODBCManager -Scope AllUsers -Force -ErrorAction Stop -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '2' more times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '1' more times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '0' more times
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Total package yield:'0' for the specified package 'ODBCManager'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'http://srv-proget/nuget/QASolutions-PS/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'http://srv-proget/nuget/QASolutions-PS/FindPackagesById()?id='ODBCManager'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'ODBCManager'.
VERBOSE: Performing the operation "Install-Module" on target "Version '0.1.0.1' of module 'ODBCManager'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'ODBCManager' with version '0.1.0.1' from the repository 'http://srv-proget/nuget/QASolutions-PS/'.
VERBOSE: Searching repository 'http://srv-proget/nuget/QASolutions-PS/FindPackagesById()?id='ODBCManager'' for ''.
VERBOSE: InstallPackage' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxxx\AppData\Local\Temp\191916'
VERBOSE: DownloadPackage' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxx\AppData\Local\Temp\191916\ODBCManager\ODBCManager.nupkg',
uri='http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'
VERBOSE: Downloading 'http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'.
VERBOSE: Completed downloading 'http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'.
VERBOSE: Completed downloading 'ODBCManager'.
VERBOSE: Hash for package 'ODBCManager' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxx\AppData\Local\Temp\191916'
VERBOSE: Catalog file 'ODBCManager.cat' is not found in the contents of the module 'ODBCManager' being installed.
VERBOSE: For publisher validation, current module 'ODBCManager' with version '0.1.0.1' with publisher name ''. Is this module signed by Microsoft: 'False'.
VERBOSE: For publisher validation, using the previously-installed module 'ODBCManager' with version '0.1.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\ODBCManager\0.1.0.1' with publisher name ''. Is this module signed by Microsoft: 'False'.
VERBOSE: Module 'ODBCManager' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\ODBCManager\0.1.0.1'.
I have it hosted in ProGet under a Powershell Modules Feed
On Publish, folder name and DLL name are the same
Manifest has been created
Functions export and execute as expected
Manifest:
#{
RootModule = 'ODBCManager.dll'
ModuleVersion = '0.1.0.1' # filled in by cake-build process
CmdletsToExport = '*'
GUID = 'xxx-xxx-xxx-xx-xx'
DotNetFrameworkVersion = '4.0'
Author = 'xxx'
Description = 'PowerShell Binary Module for manipulating ODBCs.'
CompanyName = 'xxx'
Copyright = '(c) 2017 xxx. All rights reserved.'
PrivateData = #{
PSData = #{
ProjectUri = 'xxxxxxxxxx'
LicenseUri = ''
ReleaseNotes = 'First Release'
}
}
}
Have I forgot something? Because I've tried everything.
EDIT: After help from #BenH I was able to research further and found you can call Get-Module -ListAvailable -Name ODBCManager to quickly show your module installed, but not imported. -- For future reference!

Install-Module and Import-Module are different. Get-Module returns all of the Modules that are imported and Get-Module -ListAvailable returns all of the modules that are installed.
Thus your module is "Installed" but not "Imported".
With later versions of PowerShell, modules are dynamically imported if their functions/cmdlets are defined in the exported functions/cmdlets of the .psd1. But until they are imported, Get-Module will not list them.
Try this:
Import-Module ODBCManager
Get-Module ODBCManager

Related

Windows 10 SSH server installation does not create required services

I am trying to install Open-SSH on my Windows 10 pc in order to connect to it from my linux machine with ssh. I am following this tutorial, but as soon as I have to run something like Start-Service ssh-agent, it says that the service doesn't exist. Another thing that doesn't work is Install-Module -Force OpenSSHUtils, and it says that the signature of the file 'OpenSSHUtils.psd1' is not valid. I have tried many other tutorials, uninstalling everything before each one, and none of them are working. Is there any way to install these things manually? Am I missing an important step of the installation?
You do know you can install SSH directly in Windows 10 by using Add Feature option, correct? No need to download an external module/tool unless the builtin one does not provide all you are after.
Installation of OpenSSH For Windows Server 2019 and Windows 10
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Using the GUI
How to Enable and Use Windows 10’s New Built-in SSH Commands
Yet, if you do decide to use external stuff, then, Always test destructive (CUD = Create, Update, delete) code before true implementation.
Find-Module -Name 'OpenSSHUtils' -Verbose
<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
Version Name Repository Description
------- ---- ---------- -----------
1.0.0.1 OpenSSHUtils PSGallery Configure OpenSSH for Windows related security settings like file owner and permissions.
#>
Find-Module -Name 'OpenSSHUtils' -Verbose |
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules" -Verbose -WhatIf
<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Save Package" on target "'OpenSSHUtils' to location 'C:\Users\Daniel\Documents\WindowsPowerShell\Modules'".
#>
Install-Module -Name 'OpenSSHUtils' -Verbose -WhatIf
<#
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Install-Module" on target "Version '1.0.0.1' of module 'OpenSSHUtils'".
#>

Warnings When Attempting to Install Sysinternals With Powershell

I am trying to install the sysinternals package with powershell, but is instead greeted with tons of warnings. It should be noted that I am following a set of instructions and don't know a lot about this subject yet. Here are the warnings when attempting to run the install-package command:
Install-Package sysinternals
WARNING: NuGet: System.InvalidOperationException: Unable to find version '1.3.5.1' of package 'chocolatey-core.extension'.
WARNING: NuGet: at NuGet.PackageRepositoryHelper.ResolvePackage(IPackageRepository sourceRepository, IPackageRepository
localRepository, IPackageConstraintProvider constraintProvider, String packageId, SemanticVersion version, Boolean
allowPrereleaseVersions)
WARNING: NuGet: at NuGet.PackageManager.InstallPackage(String packageId, SemanticVersion version, Boolean ignoreDependencies,
Boolean allowPrereleaseVersions)
WARNING: NuGet: at NuGet.Commands.InstallCommand.InstallPackage(IFileSystem fileSystem, String packageId, SemanticVersion version)
WARNING: NuGet: at NuGet.Program.Main(String[] args)
WARNING: NuGet: System.InvalidOperationException: Unable to find version '2019.12.19' of package 'sysinternals'.
As for what I've done before this, I've only installed the Chocolatey package provider and updated windows, but maybe I did something wrong? Here are the steps leading up to this:
Set-ExecutionPolicy RemoteSigned
Install-PackageProvider Chocolatey
Install-Module -Name PSWindowsUpdate
Get-WUInstall -Verbose
Get-WUInstall -Install
Any help is much appreciated.
Though you can use Chocolatey and NuGet, PowerShell's package manager is PowerShellGet (well, that uses NuGet by design). So, Choco is not really needed, yet, many still install and use it for the other sources.
If you use PowerShellGet directly, you'll see the same errors.
Find-Module -Name 'SysInternals' -AllVersions |
Format-Table -AutoSize
<#
# Results
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'SysInternals'. Try Get-PSRepository to see all available registered module
repositories.
At C:\Users\Daniel\Documents\WindowsPowerShell\Modules\PowerShellGet\2.2.3\PSModule.psm1:8873 char:9
+ PackageManagement\Find-Package #PSBoundParameters | Microsoft ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage
#>
Find-Package -Name 'SysInternals' -AllVersions |
Format-Table -AutoSize
<#
# Results
Find-Package : No match was found for the specified search criteria and package name 'SysInternals'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Find-Package -Name 'SysInternals' -AllVersions |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage
#>
Yet, if you do a wildcard search...
Find-Module -Name '*Internals*' |
Format-Table -AutoSize
<#
# Results
Version Name Repository Description
------- ---- ---------- -----------
1.0.34 PoshInternals PSGallery Collection of system internals tools for PowerShell.
4.3 DSInternals PSGallery The DSInternals PowerShell Module exposes several internal features of Active Directory and Azure Active Directory. These include FIDO2 and NGC key aud...
0.2.8 AADInternals PSGallery The AADInternals PowerShell Module utilises several internal features of Azure Active Directory, Office 365, and related admin tools. DISCLAIMER: Funct...
0.1 LCMInternals PSGallery Demo scripts explaining the internals of LCM
#>
Find-Package -Name '*Internals*' |
Format-Table -AutoSize
<#
# Results
Name Version Source Summary
---- ------- ------ -------
PoshInternals 1.0.34 PSGallery Collection of system internals tools for PowerShell.
DSInternals 4.3 PSGallery The DSInternals PowerShell Module exposes several internal features of Active Directory and Azure Active Directory. These incl...
AADInternals 0.2.8 PSGallery The AADInternals PowerShell Module utilises several internal features of Azure Active Directory, Office 365, and related admin...
LCMInternals 0.1 PSGallery Demo scripts explaining the internals of LCM
SilverlightToolkit-Internals-Unofficial 1.0.0 nuget.org The missing part of Microsoft Silverlight Toolkit. The internals DLL. 'System.Windows.Controls.Toolkit.Internals'
AppInternals.Agent.Cloud.Support 10.10.0 nuget.org Configure an Azure Cloud Service solution for AppInternals application performance monitoring.
InternalsVisibleTo.MSBuild 1.0.3 nuget.org Enables declaring 'InternalsVisibleTo' items in a .NET project file, rather than declaring them to an AssemblyInfo.cs file.
Akrual.DDD.Utils.Internals 1.0.8 nuget.org Useful Classes yo use everywhere
Meziantou.MSBuild.InternalsVisibleTo 1.0.1 nuget.org Allow to declare 'InternalsVisibleTo' in the csproj file, rather than declaring them to an AssemblyInfo.cs file.
microServiceBus.InternalService 1.0.0 nuget.org This package creates a stub from which you can create an Internal Service for microServiceBus.com
#>
So, as you can see, there is no such module/package called SysInternals to install.
What you do is just download the zip file from here and unpack and use it as normal.
Sysinternals Suite
https://learn.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite
I was having the same issue and found the answer here helpful. It seems like something about TLS 1.3 is causing the issue, and the second part of the answer—changing the .Net Framework default TLS version—allowed me to finish my sysinternals install via PowerShell. Then I just deleted the new reg key I had created. I guess I'll just have to wait and see if this is something that comes up again as I continue to learn more and work more with package management in PS.

PowerShell SqlModule corrupted

I have installed SqlServer moduled with Install-Module -Name SqlServer -Repository PSGallery -Verbose command. PS says that it was successfuly.
But when I'm runneng import-module I only see 3 items imported from this module:
PS >import-module sqlserver -erroraction stop -verbose
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\sqlserver\21.0.17240\sqlserver.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module sqlserver.
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\sqlserver\21.0.17240\SqlServer.psm1'.
VERBOSE: Exporting function 'SQLSERVER:'.
VERBOSE: Exporting alias 'Encode-SqlName'.
VERBOSE: Exporting alias 'Decode-SqlName'.
VERBOSE: Importing function 'SQLSERVER:'.
VERBOSE: Importing alias 'Decode-SqlName'.
VERBOSE: Importing alias 'Encode-SqlName'.
Question: how to get all the commands (like Invoike-Sqlcmd and other) from SqlServer working?
PS Version
Name Value
---- -----
PSVersion 5.1.16299.251
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.251
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
UPDATE:
Running Get-Command -Module SqlServer | Measure gives even after force reinstall with Install-Module SqlServer -Force:
PS H:\> Get-Command -Module SqlServer | Measure
Count : 3
Average :
Sum :
Maximum :
Minimum :
Property :
Checked event log. Found bunch of Information records, when importing the SqlServer module like this:
Context Information:
DetailSequence=1
DetailTotal=1
SequenceNumber=17
UserId=DOMAIN/User
HostName=ConsoleHost
HostVersion=5.1.16299.251
HostId=GUID
HostApplication=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
EngineVersion=5.1.16299.251
RunspaceId=GUID
PipelineId=6
ScriptName=C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.0.17240\SqlServer.psm1
CommandLine= Add-Type -Path $binaryPath
Details:
CommandInvocation(Add-Type): "Add-Type"
ParameterBinding(Add-Type): name="Path"; value="C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.0.17240\Microsoft.SqlServer.Dmf.dll"
Hmm. Okay do this...
Find all your various module folders -- you can use the following to do this:
$env:PSModulePath.Split(';')
Removing the "sqlserver" folder from each directory, if it exists.
Re-import the module.
Install-Module -Name SqlServer -AllowClobber
Steps-1 and -2 make sure there are no mangled SqlServer module installations lurking anywhere. Step-3 gives us a fresh pull of the module.
The only thing I can think of. Maybe there is a mangled module installed somewhere. It isn't getting overwritten during re-install, but it's accidentally getting loaded.

Why can Find-Package not find a package by name on my local package source

I have a local package source to mess around with some things. I created a brain-dead package called CoolUtils, adding it using nuget add. You can find it using nuget:
PS> nuget list -source E:\nuget-repo-test-01\
CoolUtils 2.0.20171024.1
PS> nuget list coolutils -source E:\nuget-repo-test-01\
CoolUtils 2.0.20171024.1
However, Find-Package can't find it by name, but can find it with wildcards or no name specified:
PS> Find-Package -Source E:\nuget-repo-test-01\
Name Version Source Summary
---- ------- ------ -------
CoolUtils 2.0.20171024.1 E:\nuget-repo-test-01\ Test package with dumb scripts.
PS> Find-Package *cool* -Source E:\nuget-repo-test-01\
Name Version Source Summary
---- ------- ------ -------
CoolUtils 2.0.20171024.1 E:\nuget-repo-test-01\ Test package with dumb scripts.
PS> Find-Package CoolUtils -Source E:\nuget-repo-test-01\
Find-Package : No match was found for the specified search criteria and package name 'CoolUtils'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Find-Package CoolUtils -Source E:\nuget-repo-test-01\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage
I also can't install it using Install-Package, though I can using nuget.
Cmdlet Find-Package is part of PackageManagement module, while Nuget.exe is one of a dozen of package providers for PackageManagement module.
An analogy (not fully correct) is an application and plugins: Nuget is like one of plug-ins which provides functionality to its application (Find-Package, Install-Package and other cmdlets from PackageManagement).
Despite Nuget can do some package management tasks, in order to work under control of standardized PackageManagement commands you should properly declare ("register") nuget's package locations to make them known for PackageManagement:
Register-PackageSource -name MyPackages -location E:\nuget-repo-test-01 -provider Nuget
Now Find-Package can search and Install-Package can install packages from newly registered package source. Full list of known package sources can be retrieved by
Get-PackageSource
I experienced the same issue and managed to solve it by moving the .nupkg file to the root of the registered local package source, i.e. "C:\projects\packages\"
PS> Get-PackageSource -Name Local
Name ProviderName IsTrusted Location
---- ------------ --------- --------
Local NuGet False C:\projects\packages\
PS> Find-Package -Source Local -Name TestCmdlet
Name Version Source Summary
---- ------- ------ -------
TestCmdlet 1.0.0 Local Package Description

Powershell not importing functions from module

I'm trying to setup a NuGet Feed here, and that worked ok. I installed a module from my feed via
Install-Module -Name MyCmdlets -Repository $RepoName -Scope CurrentUser -Force
Import-Module -Name MyCmdlets
However when I run Get-Module, I get no functions and it's a manifest?
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0 MyCmdlets
If I manually go to the installed location and import manually
Import-Module <my-path>\1.0\MyCmdlets.psm1
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0 MyCmdlets {Create-Project, Get-AuditLogs, Get-..
My manifest file does have these lines so I don't understand why Import-Module isn't working correctly.
FunctionsToExport = '*'
CmdletsToExport = '*'
I guess you haven't set the root module in your .psd1 like so
#
# Module manifest for module 'YourModule'
#
#{
# Script module or binary module file associated with this manifest
RootModule = 'YourModule.psm1'
# Version number of this module.
ModuleVersion = '1.0.0'
...
This is necessary so that when you import your manifest module it also loads the script module
For anyone coming across this looking for why their module wont import check that RootModule = 'YourModule.psm1' isn't commented out.
By default when creating a new manifest using New-ModuleManifest it throws a hash in front of this line..
ugh I feel so stupid.