Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

How to use PSEnsure Module and Custom PSRepository ?



  • Hello

    I usually defined a new PSRepository using Otter with this :

    Rôle : 000- INIT SERVER

    # PSRepository
    {
        call PackageManagementSource
        (
            Nom: public-psm,
            SourceLocation: https://proget.ocapiat.fr/nuget/public-psm,
            InstallationPolicy: Trusted
        );
    
        call PackageManagementSource
        (
            Nom: internal-psm,
            SourceLocation: https://proget.ocapiat.fr/nuget/internal-psm,
            InstallationPolicy: Trusted
        );
    }
    

    The called module is:

    ##AH:UseTextMode
    module PackageManagementSource<$Nom, $Ensure = present, $SourceLocation, $ProviderName = PowerShellGet, $InstallationPolicy = Untrusted>
    
    {
            call Log-DSI
            (
                Texte: PSRepository : $Nom
            );
        Ensure-DscResource
        (
            ConfigurationKey: Name,
            Name: PackageManagementSource,
            Module: PackageManagement,
            Properties: %(Name:$Nom,ProviderName:$ProviderName,SourceLocation:$SourceLocation,InstallationPolicy:$InstallationPolicy,Ensure:$Ensure)
        )
    }
    

    Then I am using the Ensure PowerModule is a second role (linked to the first role)
    And it failed :(

    Rôle 020 - SERVER - PSMODULE

    # General
    foreach %Module in @FromJSON($PSModules)
    {
        {
            Ensure-PsModule
            (
                Module: %Module.Nom,
                Force: true,
                Repository: public-psm,
                Scope: AllUsers,
                Exists: %Module.Ensure,
                AllowClobber: true,
                AllowPrerelease: false,
                AllVersions: true,
                Parameters: %(MinimumVersion:%Module.Version),
                Verbose: true,
                DebugLogging: true
            );
        }
    }
    

    Variable :

    $PSModules= [{
    		"Nom": "PSDscResources",
    		"Version": "2.12.0.0",
    		"Ensure": "true",
    		"Source": "public-psm"
    	},
    	{
    		"Nom": "Carbon",
    		"Version": "2.9.2",
    		"Ensure": "true",
    		"Source": "public-psm"
    	},
    	{
    		"Nom": "xActiveDirectory",
    		"Version": "3.0.0",
    		"Ensure": "true",
    		"Source": "public-psm"
    	},
    	{
    		"Nom": "NetworkingDSC",
    		"Version": "8.2.0",
    		"Ensure": "true",
    		"Source": "public-psm"
    	},
    	{
    		"Nom": "ComputerManagementDsc",
    		"Version": "8.4.0",
    		"Ensure": "true",
    		"Source": "public-psm"
    	}
    ]
    

    The remediation of the second role failed with the error:
    Short version

    Unable to find repository 'public-psm'. Use Get-PSRepository to see all available repositories
    

    Long Version

    Install-Module -Name $Name -Force -AllowClobber -Scope $Scope -Repository $Repository -Verbose -MinimumVersion $MinimumVersion
    Importing Name...
    Importing Version...
    Importing Scope...
    Importing Repository...
    Importing $MinimumVersion...
    Renseignement de la propriété RepositorySourceLocation pour le module PackageManagement.
    Chargement du module à partir du chemin « C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psm1 ».
    Chargement du module à partir du chemin « C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psd1 ».
    Chargement de « FormatsToProcess » à partir du chemin « C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.format.ps1xml ».
    Renseignement de la propriété RepositorySourceLocation pour le module PackageManagement.
    Chargement du module à partir du chemin « C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psm1 ».
    Chargement du module à partir du chemin « C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.dll ».
    Chargement du module à partir du chemin « C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PowerShell.PackageManagement.dll ».
    Importation de l'applet de commande « Find-Package ».
    Importation de l'applet de commande « Find-PackageProvider ».
    Importation de l'applet de commande « Get-Package ».
    Importation de l'applet de commande « Get-PackageProvider ».
    Importation de l'applet de commande « Get-PackageSource ».
    Importation de l'applet de commande « Import-PackageProvider ».
    Importation de l'applet de commande « Install-Package ».
    Importation de l'applet de commande « Install-PackageProvider ».
    Importation de l'applet de commande « Register-PackageSource ».
    Importation de l'applet de commande « Save-Package ».
    Importation de l'applet de commande « Set-PackageSource ».
    Importation de l'applet de commande « Uninstall-Package ».
    Importation de l'applet de commande « Unregister-PackageSource ».
    Exportation de l'applet de commande « Find-Package ».
    Exportation de l'applet de commande « Find-PackageProvider ».
    Exportation de l'applet de commande « Get-Package ».
    Exportation de l'applet de commande « Get-PackageProvider ».
    Exportation de l'applet de commande « Get-PackageSource ».
    Exportation de l'applet de commande « Import-PackageProvider ».
    Exportation de l'applet de commande « Install-Package ».
    Exportation de l'applet de commande « Install-PackageProvider ».
    Exportation de l'applet de commande « Register-PackageSource ».
    Exportation de l'applet de commande « Save-Package ».
    Exportation de l'applet de commande « Set-PackageSource ».
    Exportation de l'applet de commande « Uninstall-Package ».
    Exportation de l'applet de commande « Unregister-PackageSource ».
    Importation de l'applet de commande « Find-Package ».
    Importation de l'applet de commande « Find-PackageProvider ».
    Importation de l'applet de commande « Get-Package ».
    Importation de l'applet de commande « Get-PackageProvider ».
    Importation de l'applet de commande « Get-PackageSource ».
    Importation de l'applet de commande « Import-PackageProvider ».
    Importation de l'applet de commande « Install-Package ».
    Importation de l'applet de commande « Install-PackageProvider ».
    Importation de l'applet de commande « Register-PackageSource ».
    Importation de l'applet de commande « Save-Package ».
    Importation de l'applet de commande « Set-PackageSource ».
    Importation de l'applet de commande « Uninstall-Package ».
    Importation de l'applet de commande « Unregister-PackageSource ».
    
    using System;
    using System.Net;
    
    namespace Microsoft.PowerShell.Commands.PowerShellGet
    {
        /// <summary>
        /// Used by Ping-Endpoint function to supply webproxy to HttpClient
        /// We cannot use System.Net.WebProxy because this is not available on CoreClr
        /// </summary>
        public class InternalWebProxy : IWebProxy
        {
            Uri _proxyUri;
            ICredentials _credentials;
    
            public InternalWebProxy(Uri uri, ICredentials credentials)
            {
                Credentials = credentials;
                _proxyUri = uri;
            }
    
            /// <summary>
            /// Credentials used by WebProxy
            /// </summary>
            public ICredentials Credentials
            {
                get
                {
                    return _credentials;
                }
                set
                {
                    _credentials = value;
                }
            }
    
            public Uri GetProxy(Uri destination)
            {
                return _proxyUri;
            }
    
            public bool IsBypassed(Uri host)
            {
                return false;
            }
        }
    }
    
    using System;
    using System.Management.Automation;
    
    namespace Microsoft.PowerShell.Commands.PowerShellGet
    {
        public static class Telemetry
        {
            public static void TraceMessageArtifactsNotFound(string[] artifactsNotFound, string operationName)
            {
                Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI.TraceMessage(operationName, new { ArtifactsNotFound = artifactsNotFound });
            }
    
            public static void TraceMessageNonPSGalleryRegistration(string sourceLocationType, string sourceLocationHash, string installationPolicy, string packageManagementProvider, string publishLocationHash, string scriptSourceLocationHash, string scriptPublishLocationHash, string operationName)
            {
                Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI.TraceMessage(operationName, new { SourceLocationType = sourceLocationType, SourceLocationHash = sourceLocationHash, InstallationPolicy = installationPolicy, PackageManagementProvider = packageManagementProvider, PublishLocationHash = publishLocationHash, ScriptSourceLocationHash = scriptSourceLocationHash, ScriptPublishLocationHash = scriptPublishLocationHash });
            }
        }
    }
    
    using System;
    using System.Net;
    using Microsoft.Win32.SafeHandles;
    using System.Security.Cryptography;
    using System.Runtime.InteropServices;
    using System.Runtime.ConstrainedExecution;
    using System.Runtime.Versioning;
    using System.Security;
    
    namespace Microsoft.PowerShell.Commands.PowerShellGet
    {
        [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
        public struct CERT_CHAIN_POLICY_PARA {
            public CERT_CHAIN_POLICY_PARA(int size) {
                cbSize = (uint) size;
                dwFlags = 0;
                pvExtraPolicyPara = IntPtr.Zero;
            }
            public uint   cbSize;
            public uint   dwFlags;
            public IntPtr pvExtraPolicyPara;
        }
    
        [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
        public struct CERT_CHAIN_POLICY_STATUS {
            public CERT_CHAIN_POLICY_STATUS(int size) {
                cbSize = (uint) size;
                dwError = 0;
                lChainIndex = IntPtr.Zero;
                lElementIndex = IntPtr.Zero;
                pvExtraPolicyStatus = IntPtr.Zero;
            }
            public uint   cbSize;
            public uint   dwError;
            public IntPtr lChainIndex;
            public IntPtr lElementIndex;
            public IntPtr pvExtraPolicyStatus;
        }
    
        // Internal SafeHandleZeroOrMinusOneIsInvalid class to remove the dependency on .Net Framework 4.6.
        public abstract class InternalSafeHandleZeroOrMinusOneIsInvalid : SafeHandle
        {
            protected InternalSafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle)
                : base(IntPtr.Zero, ownsHandle)
            {
            }
    
            public override bool IsInvalid
            {
                get
                {
                    return handle == IntPtr.Zero || handle == new IntPtr(-1);
                }
            }
        }
    
        // Internal SafeX509ChainHandle class to remove the dependency on .Net Framework 4.6.
        [SecurityCritical]
        public sealed class InternalSafeX509ChainHandle : InternalSafeHandleZeroOrMinusOneIsInvalid {
            private InternalSafeX509ChainHandle () : base(true) {}
    
            internal InternalSafeX509ChainHandle (IntPtr handle) : base (true) {
                SetHandle(handle);
            }
    
            internal static InternalSafeX509ChainHandle InvalidHandle {
                get { return new InternalSafeX509ChainHandle(IntPtr.Zero); }
            }
    
            [SecurityCritical]
            override protected bool ReleaseHandle()
            {
                CertFreeCertificateChain(handle);
                return true;
            }
    
            [DllImport("Crypt32.dll", SetLastError=true)]
    
            [SuppressUnmanagedCodeSecurity,
             ResourceExposure(ResourceScope.None),
             ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
            
            private static extern void CertFreeCertificateChain(IntPtr handle);
        }
    
        public class Win32Helpers
        {
            [DllImport("Crypt32.dll", CharSet=CharSet.Auto, SetLastError=true)]
            public extern static
            bool CertVerifyCertificateChainPolicy(
                [In]     IntPtr                       pszPolicyOID,
                [In]     SafeX509ChainHandle  pChainContext,
                [In]     ref CERT_CHAIN_POLICY_PARA   pPolicyPara,
                [In,Out] ref CERT_CHAIN_POLICY_STATUS pPolicyStatus);
    
            [DllImport("Crypt32.dll", CharSet=CharSet.Auto, SetLastError=true)]
            public static extern
            SafeX509ChainHandle CertDuplicateCertificateChain(
                [In]     IntPtr pChainContext);
    
            [DllImport("Crypt32.dll", CharSet=CharSet.Auto, SetLastError=true)]
        
            [ResourceExposure(ResourceScope.None)]
        
            public static extern
            SafeX509ChainHandle CertDuplicateCertificateChain(
                [In]     SafeX509ChainHandle pChainContext);
    
            public static bool IsMicrosoftCertificate([In] SafeX509ChainHandle pChainContext)
            {
                //-------------------------------------------------------------------------
                //  CERT_CHAIN_POLICY_MICROSOFT_ROOT
                //
                //  Checks if the last element of the first simple chain contains a
                //  Microsoft root public key. If it doesn't contain a Microsoft root
                //  public key, dwError is set to CERT_E_UNTRUSTEDROOT.
                //
                //  pPolicyPara is optional. However,
                //  MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG can be set in
                //  the dwFlags in pPolicyPara to also check for the Microsoft Test Roots.
                //
                //  MICROSOFT_ROOT_CERT_CHAIN_POLICY_CHECK_APPLICATION_ROOT_FLAG can be set
                //  in the dwFlags in pPolicyPara to check for the Microsoft root for
                //  application signing instead of the Microsoft product root. This flag
                //  explicitly checks for the application root only and cannot be combined
                //  with the test root flag.
                //
                //  MICROSOFT_ROOT_CERT_CHAIN_POLICY_DISABLE_FLIGHT_ROOT_FLAG can be set
                //  in the dwFlags in pPolicyPara to always disable the Flight root.
                //
                //  pvExtraPolicyPara and pvExtraPolicyStatus aren't used and must be set
                //  to NULL.
                //--------------------------------------------------------------------------
                const uint MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG       = 0x00010000;
                const uint MICROSOFT_ROOT_CERT_CHAIN_POLICY_CHECK_APPLICATION_ROOT_FLAG = 0x00020000;
                //const uint MICROSOFT_ROOT_CERT_CHAIN_POLICY_DISABLE_FLIGHT_ROOT_FLAG    = 0x00040000;
    
                CERT_CHAIN_POLICY_PARA PolicyPara = new CERT_CHAIN_POLICY_PARA(Marshal.SizeOf(typeof(CERT_CHAIN_POLICY_PARA)));
                CERT_CHAIN_POLICY_STATUS PolicyStatus = new CERT_CHAIN_POLICY_STATUS(Marshal.SizeOf(typeof(CERT_CHAIN_POLICY_STATUS)));
                int CERT_CHAIN_POLICY_MICROSOFT_ROOT = 7;
    
                PolicyPara.dwFlags = (uint) MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG;
                bool isMicrosoftRoot = false;
    
                if(CertVerifyCertificateChainPolicy(new IntPtr(CERT_CHAIN_POLICY_MICROSOFT_ROOT),
                                                    pChainContext,
                                                    ref PolicyPara,
                                                    ref PolicyStatus))
                {
                    isMicrosoftRoot = (PolicyStatus.dwError == 0);
                }
    
                // Also check for the Microsoft root for application signing if the Microsoft product root verification is unsuccessful.
                if(!isMicrosoftRoot)
                {
                    // Some Microsoft modules can be signed with Microsoft Application Root instead of Microsoft Product Root,
                    // So we need to use the MICROSOFT_ROOT_CERT_CHAIN_POLICY_CHECK_APPLICATION_ROOT_FLAG for the certificate verification.
                    // MICROSOFT_ROOT_CERT_CHAIN_POLICY_CHECK_APPLICATION_ROOT_FLAG can not be used
                    // with MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG,
                    // so additional CertVerifyCertificateChainPolicy call is required to verify the given certificate is in Microsoft Application Root.
                    //
                    CERT_CHAIN_POLICY_PARA PolicyPara2 = new CERT_CHAIN_POLICY_PARA(Marshal.SizeOf(typeof(CERT_CHAIN_POLICY_PARA)));
                    CERT_CHAIN_POLICY_STATUS PolicyStatus2 = new CERT_CHAIN_POLICY_STATUS(Marshal.SizeOf(typeof(CERT_CHAIN_POLICY_STATUS)));
                    PolicyPara2.dwFlags = (uint) MICROSOFT_ROOT_CERT_CHAIN_POLICY_CHECK_APPLICATION_ROOT_FLAG;
    
                    if(CertVerifyCertificateChainPolicy(new IntPtr(CERT_CHAIN_POLICY_MICROSOFT_ROOT),
                                                        pChainContext,
                                                        ref PolicyPara2,
                                                        ref PolicyStatus2))
                    {
                        isMicrosoftRoot = (PolicyStatus2.dwError == 0);
                    }
                }
    
                return isMicrosoftRoot;
            }
        }
    }
    Exportation de la fonction « Find-Command ».
    Exportation de la fonction « Find-DscResource ».
    Exportation de la fonction « Find-Module ».
    Exportation de la fonction « Find-RoleCapability ».
    Exportation de la fonction « Find-Script ».
    Exportation de la fonction « Get-CredsFromCredentialProvider ».
    Exportation de la fonction « Get-InstalledModule ».
    Exportation de la fonction « Get-InstalledScript ».
    Exportation de la fonction « Get-PSRepository ».
    Exportation de la fonction « Install-Module ».
    Exportation de la fonction « Install-Script ».
    Exportation de la fonction « New-ScriptFileInfo ».
    Exportation de la fonction « Publish-Module ».
    Exportation de la fonction « Publish-Script ».
    Exportation de la fonction « Register-PSRepository ».
    Exportation de la fonction « Save-Module ».
    Exportation de la fonction « Save-Script ».
    Exportation de la fonction « Set-PSRepository ».
    Exportation de la fonction « Test-ScriptFileInfo ».
    Exportation de la fonction « Uninstall-Module ».
    Exportation de la fonction « Uninstall-Script ».
    Exportation de la fonction « Unregister-PSRepository ».
    Exportation de la fonction « Update-Module ».
    Exportation de la fonction « Update-ModuleManifest ».
    Exportation de la fonction « Update-Script ».
    Exportation de la fonction « Update-ScriptFileInfo ».
    Exportation de la fonction « Add-PackageSource ».
    Exportation de la fonction « Download-Package ».
    Exportation de la fonction « Find-Package ».
    Exportation de la fonction « Get-DynamicOptions ».
    Exportation de la fonction « Get-Feature ».
    Exportation de la fonction « Get-InstalledPackage ».
    Exportation de la fonction « Get-PackageProviderName ».
    Exportation de la fonction « Initialize-Provider ».
    Exportation de la fonction « Install-Package ».
    Exportation de la fonction « Remove-PackageSource ».
    Exportation de la fonction « Resolve-PackageSource ».
    Exportation de la fonction « Uninstall-Package ».
    Exportation de la variable « PSGetPath ».
    Exportation de l'alias « fimo ».
    Exportation de l'alias « inmo ».
    Exportation de l'alias « upmo ».
    Exportation de l'alias « pumo ».
    Exportation de l'alias « uimo ».
    00:00:00.0000002 Current running environment: Windows PowerShell.
    00:00:00.0409141 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsiProvider.dll
    00:00:00.0409171 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.ArchiverProviders.dll
    00:00:00.0409136 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.NuGetProvider.dll
    00:00:00.0409679 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
    00:00:00.0412470 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.CoreProviders.dll
    00:00:00.0412699 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsuProvider.dll
    00:00:00.0420513 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
    00:00:00.0421320 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsuProvider.dll
    00:00:00.0422013 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.ArchiverProviders.dll
    00:00:00.0422681 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.CoreProviders.dll
    00:00:00.0424206 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsiProvider.dll
    00:00:00.0425076 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.NuGetProvider.dll
    Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
    Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.CoreProviders.dll
    Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsuProvider.dll
    Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.ArchiverProviders.dll
    Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsiProvider.dll
    Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.NuGetProvider.dll
    00:00:00.0995375 Registering providers via metaproviders for assembly Microsoft.PackageManagement.MetaProvider.PowerShell.Internal.PowerShellMetaProvider
    00:00:00.1429840 Initializing provider 'zipfile'
    00:00:00.1431664 Initializing provider 'WebDownloader'
    00:00:00.1432405 Initializing provider 'Bootstrap'
    00:00:00.1432709 Initializing provider 'Programs'
    00:00:00.1433983 Initializing provider 'msu'
    00:00:00.1434329 Initializing provider 'msi'
    00:00:00.1435730 Initializing provider 'NuGet'
    00:00:00.1742315 Provider 'WebDownloader' Initialized
    00:00:00.1742657 Provider 'zipfile' Initialized
    00:00:00.1742804 Using Downloader Provider WebDownloader
    00:00:00.1742916 Using Archiver Provider zipfile
    00:00:00.1752022 Initialize Bootstrapper
    00:00:00.1754217 Provider 'Bootstrap' Initialized
    00:00:00.1754477 Using Package Provider Bootstrap
    00:00:00.1785106 Calling 'msi::InitializeProvider'
    00:00:00.1785183 Calling 'Programs::InitializeProvider'
    00:00:00.1785447 Provider 'msi' Initialized
    00:00:00.1785457 Provider 'Programs' Initialized
    00:00:00.1785590 Using Package Provider msi
    00:00:00.1785603 Using Package Provider Programs
    00:00:00.1786129 Calling 'msu::InitializeProvider'
    00:00:00.1786502 Provider 'msu' Initialized
    00:00:00.1786646 Using Package Provider msu
    00:00:00.1787321 Calling 'NuGet'::'InitializeProvider'.
    00:00:00.1787731 Provider 'NuGet' Initialized
    00:00:00.1787864 Using Package Provider NuGet
    00:00:00.1790461 Trying to register metaprovider
    00:00:00.1936506 Initializing PowerShell MetaProvider
    00:00:00.1961897 Calling 'Programs::GetFeatures' 
    00:00:00.1962144 Calling 'msi::GetFeatures' 
    00:00:00.1962318 Calling 'Bootstrap::GetFeatures'
    00:00:00.1962764 Calling 'NuGet'::'GetFeatures'.
    00:00:00.1963291 Calling 'msu::GetFeatures' 
    00:00:00.1963715 Calling 'WebDownloader::GetFeatures' 
    00:00:00.1964346 Calling 'zipfile::GetFeatures' 
    00:00:00.1971251 The provider 'Programs' is imported
    00:00:00.1982903 The provider 'msu' is imported
    00:00:00.1983136 The provider 'Bootstrap' is imported
    00:00:00.1983144 The provider 'msi' is imported
    00:00:00.1984682 The provider 'NuGet' is imported
    00:00:00.1985542 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsuProvider.dll
    00:00:00.1988048 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MsiProvider.dll
    00:00:00.1988880 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.ArchiverProviders.dll
    00:00:00.1991170 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.CoreProviders.dll
    00:00:00.1995544 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.NuGetProvider.dll
    00:00:00.2086319 Calling 'WebDownloader::DownloadFile' 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409','C:\Users\svc-inedo\AppData\Local\Temp\Microsoft.PackageManagement\evi4ojfr.adc','40000','False'
    00:00:00.2168660 Attempting to load PowerShell Provider Module [C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1]
    00:00:00.3548969 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag','C:\Users\svc-inedo\AppData\Local\Temp\Microsoft.PackageManagement\3pqkgnso.vfk','40000','False'
    00:00:00.3707818 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/psl-1.0.0.210.package.swidtag','C:\Users\svc-inedo\AppData\Local\Temp\Microsoft.PackageManagement\bs5wy4jx.3bw','40000','False'
    00:00:00.3746673 Loaded PowerShell package provider: '[C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1]'.
    00:00:00.3811891 Loaded PowerShell Provider: PowerShellGet
    00:00:00.3830792 Initializing provider 'PowerShellGet'
    00:00:00.3871533 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/ChocolateyPrototype-2.8.5.130.package.swidtag','C:\Users\svc-inedo\AppData\Local\Temp\Microsoft.PackageManagement\dqjzpfhm.zdy','40000','False'
    00:00:00.3898807 Calling New() : MethodName = 'InitializeProvider'
    00:00:00.3899178 ErrorAction: SilentlyContinue
    00:00:00.3899290 WarningAction: SilentlyContinue
    00:00:00.4008578 INVOKING PowerShell Fn Initialize-Provider with args  that has length 0
    00:00:00.4527793 In PowerShellGet Provider - 'Initialize-Provider'.
    00:00:00.4530119 PowerShell Script 'PSModule' Function 'Initialize-Provider' returns null.
    00:00:00.4539599 Done calling powershell «Initialize-Provider» «PSModule»
    00:00:00.4540134 Provider 'PowerShellGet' Initialized
    00:00:00.4540261 Using Package Provider PowerShellGet
    00:00:00.4592491 Calling New() : MethodName = 'GetFeatures'
    00:00:00.4592844 ErrorAction: SilentlyContinue
    00:00:00.4593029 WarningAction: SilentlyContinue
    00:00:00.4598243 INVOKING PowerShell Fn Get-Feature with args  that has length 0
    00:00:00.5012206 In PowerShellGet Provider - 'Get-Feature'.
    00:00:00.5113543 Done calling powershell «Get-Feature» «PSModule»
    00:00:00.5114479 The provider 'PowerShellGet' is imported
    00:00:00.5125800 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
    00:00:00.0000002 Calling New() : MethodName = 'ResolvePackageSources'
    00:00:00.0002003 Verbose: False
    00:00:00.0002236 Name: public-psm
    00:00:00.0002355 ErrorVariable: ev
    00:00:00.0008344 INVOKING PowerShell Fn Resolve-PackageSource with args  that has length 0
    00:00:00.0440115 In PowerShellGet Provider - 'Resolve-PackageSource'.
    00:00:00.3266117 PowerShell Script 'PSModule' Function 'Resolve-PackageSource' returns null.
    00:00:00.3271033 Done calling powershell «Resolve-PackageSource» «PSModule»
    Unable to find repository 'public-psm'. Use Get-PSRepository to see all available repositories.
    Storing configuration template...
    

    What's wrong ?


  • inedo-engineer

    Hi @philippe-camelio_3885,

    What it looks like is happening is that the repository registered to the DSC module is not reachable via the Install-Module command. The Ensure-PsModule operation runs the Install-Module PowerShell command. I think the best way to test this is to run Get-PSRepository and see if your repository is listed in that operation.

    It shouldn't be too difficult to use PSEnsure to make a script to add the repository to be used with Ensure-PSModule.

    I do have a question though. Is there a reason you are using MinimumVersion over Version?

    Thanks,
    Rich



  • @rhessinger
    Thank you for the suggestion I did not think about this.
    I did run the Get-PSRepository and there was only the powershell gallery ...

    As PSRepo can t defined at the server level this behaviour is not a big surprise.

    About the version, I had problems with module version month ago as I am using Proget for Powershell Gallery proxy
    Due to a known bug made by Microsoft on Powershell Gallery, version was a mess for some modules.
    I found that using Minimumversion overcomes the problem in my situation.

    I think you should add a function to manage PSRepo to complete the Ensure Module function.
    As you have Proget it would make sense.
    Thanks again.


  • inedo-engineer

    Hi @philippe-camelio_3885,

    Thanks for the information. I'll look at adding a new operation Ensure-PsRepository which at least should help with adding the repo for installing modules. I'll also add MinimumVersion to the Ensure-PsModule operation as well. I would expect it to take either version or minimum version but not both. Do you see any issues with that solution?

    Thanks,
    Rich



  • Hi
    Good news.

    About your question, typical PSModule with problem is PSDscResources.
    The required version is 2.12.0 according Proget or Powershell Gallery.

    So if I put 2.21.0 as expected, I have this error msg:

    'PSDscResources' matched module 'PSDscResources/2.12.0' from provider: 'PowerShellGet', repository 'public-psm'.
    00:00:02.9523782 Calling New() : MethodName = 'ResolvePackageSources'
    00:00:02.9574228 ProviderName: PowerShellGet
    00:00:02.9588935 Type: Module
    00:00:02.9640191 Source: public-psm
    00:00:02.9647101 AllowClobber: True
    00:00:02.9653443 Force: True
    00:00:02.9661637 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
    00:00:02.9665059 Scope: AllUsers
    00:00:02.9669827 Verbose: True
    00:00:02.9673645 RequiredVersion: 2.12.0
    00:00:02.9680437 AllowPrereleaseVersions: True
    00:00:02.9685090 Name: PSDscResources
    00:00:02.9701497 INVOKING PowerShell Fn Resolve-PackageSource with args  that has length 0
    00:00:02.9714322 In PowerShellGet Provider - 'Resolve-PackageSource'.
    Repository details, Name = 'public-psm', Location = 'http://proget.ocapiat.fr/nuget/public-psm'; IsTrusted = 'True'; IsRegistered = 'True'.
    00:00:02.9748490 Yielding package source for public-psm at location http://proget.ocapiat.fr/nuget/public-psm
    00:00:02.9780498 Done calling powershell «Resolve-PackageSource» «PSModule»
    'PSDscResources' matched module 'PSDscResources/2.12.0.0' from provider: 'PowerShellGet', repository 'public-psm'.
    Unable to install, multiple modules matched 'PSDscResources'. Please specify an exact -Name and -RequiredVersion.
    

    If I put 2.12.0.0, I have this error msg.

    00:00:00.9132094 Done calling powershell «Resolve-PackageSource» «PSModule»
    'PSDscResources' matched module 'PSDscResources/2.12.0' from provider: 'PowerShellGet', repository 'public-psm'.
    00:00:00.9191831 Calling New() : MethodName = 'ResolvePackageSources'
    00:00:00.9195904 ProviderName: PowerShellGet
    00:00:00.9200664 Type: Module
    00:00:00.9203234 Source: public-psm
    00:00:00.9205802 AllowClobber: True
    00:00:00.9210930 Force: True
    00:00:00.9217331 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
    00:00:00.9222181 Scope: AllUsers
    00:00:00.9227262 Verbose: True
    00:00:00.9230757 RequiredVersion: 2.12.0.0
    00:00:00.9234290 AllowPrereleaseVersions: True
    00:00:00.9237662 Name: PSDscResources
    00:00:00.9249879 INVOKING PowerShell Fn Resolve-PackageSource with args  that has length 0
    00:00:00.9277038 In PowerShellGet Provider - 'Resolve-PackageSource'.
    Repository details, Name = 'public-psm', Location = 'http://proget.ocapiat.fr/nuget/public-psm'; IsTrusted = 'True'; IsRegistered = 'True'.
    00:00:00.9306787 Yielding package source for public-psm at location http://proget.ocapiat.fr/nuget/public-psm
    00:00:00.9327326 Done calling powershell «Resolve-PackageSource» «PSModule»
    'PSDscResources' matched module 'PSDscResources/2.12.0.0' from provider: 'PowerShellGet', repository 'public-psm'.
    Unable to install, multiple modules matched 'PSDscResources'. Please specify an exact -Name and -RequiredVersion.
    

    As I said, this was an original problem in PSGAllery, I found a trick to overcome it (ie Minimumversion with the DSC PackageManagement)
    Now as I am triyng to move to the new ensure-PSModule, I have again the damned problem.


  • inedo-engineer

    Hi @philippe-camelio_3885,

    Thanks for the information. I'll let you know when I get the minimum version added and you can give it a try.

    Thanks,
    Rich


  • inedo-engineer

    Hi @philippe-camelio_3885,

    I have just built a new CI version of the [Scripting Extension 1.10.3-CI.3] (https://proget.inedo.com/feeds/PrereleaseExtensions/inedox/Scripting/1.10.3-CI.3). This version includes the Minimum Version on Ensure PS Module and adds a new Ensure-PsRepository operation. Please take a look and let me know if you have any issues.

    Thanks,
    Rich


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation