Open Outek opened 5 years ago
@Outek thanks for opening this issue...we are having some trouble reproducing it...could you please provide the full error message by piping the output $Error[0] | Format-List * -Force
writeErrorStream : True
PSMessageDetails :
OriginInfo : localhost
Exception : Microsoft.Management.Infrastructure.CimException: The SendConfigurationApply function did not succeed.
at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncObserverProxyBase`1.ProcessNativeCallback(OperationCallbackProcessingContext callbackProcessingContext, T currentItem, Boolean
moreResults, MiResult operationResult, String errorMessage, InstanceHandle errorDetailsHandle)
TargetObject : root/Microsoft/Windows/DesiredStateConfiguration:MSFT_DSCLocalConfigurationManager
CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
FullyQualifiedErrorId : MI RESULT 1
ErrorDetails :
InvocationInfo :
ScriptStackTrace :
PipelineIterationInfo : {}
Is this maybe a problem with a provider or something like this? I tried everything from without luck, With our current configuration, we cannot deploy new Powershell modules.
I altered the current PowershellGet Module to use this line: https://github.com/PowerShell/PowerShellGet/blob/development/DSC/DscResources/MSFT_PSRepository/MSFT_PSRepository.psm1#L297
with this:
Register-PSRepository -Name 'TestRepo' -SourceLocation 'https://<validreponame>/' -InstallationPolicy 'Trusted' -PackageManagementProvider 'NuGet' -Verbose
Without any luck.. if i execute this exact line in a shell, everything is working correctly.
VERBOSE: Performing the operation "Register Module Repository." on target "Module Repository 'TestRepo' (https://<validreponame>) in provider 'PowerShellGet'.".
VERBOSE: The specified PackageManagement provider name 'NuGet'.
VERBOSE: Successfully registered the repository 'TestRepo' with source location 'https://<validreponame>/'.
VERBOSE: Repository details, Name = 'TestRepo', Location = 'https://repo.pnet.ch/artifactory/api/nuget/windows-powershellgallery-local'; IsTrusted = 'True'; IsRegistered = 'True'.
Maybe a Nuget feed from Artifactory is the problem?
Hey @Outek, I've seen authentication issues previously (ProGet) when doing this as System, because the Computer account needs to authenticate to the feed's server (which, iirc, is not straight forward with say IIS & Windows Auth).
Can you also share the content of the Generated MOF, just to be sure? Also, maybe @johlju has seen this before?
/*
@TargetNode='localhost'
@GeneratedBy=<username>
@GenerationDate=09/11/2019 10:55:33
@GenerationHost=<hostname>
*/
instance of MSFT_PSRepository as $MSFT_PSRepository1ref
{
ResourceID = "[PSRepository]AddRepository";
InstallationPolicy = "Trusted";
SourceInfo = "C:\\Temp\\PSRepo.ps1::18::9::PSRepository";
Name = "TestRepo";
ModuleName = "PowerShellGet";
SourceLocation = "https://<reponame>";
ModuleVersion = "2.1.2";
ConfigurationName = "PSRepository_AddRepositoryConfig";
};
instance of OMI_ConfigurationDocument
{
Version="2.0.0";
MinimumCompatibleVersion = "1.0.0";
CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
Author="<username>";
GenerationDate="09/11/2019 10:55:33";
GenerationHost="<hostname>";
Name="PSRepository_AddRepositoryConfig";
};
If the problem is the authentication, i think this is the same problem #534
Well, could be but I wonder if it's because of what I mentioned. You said it's working when running in a Shell. Could you also try the DSC Resource using PSDscRunAsCredential, using your user account?
Then for the error, it's not very convenient in DSC so try something like $Error[0..5] | FL *
, pretty please ;)
This is the output with my user Credentials..
$Error[0] | Format-List * -Force
PSMessageDetails :
Exception : System.Management.Automation.ItemNotFoundException: Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\DSC' because it does not exist.
at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean allowNonexistingPaths, PSDriveInfo drive, ContainerCmdletProvider provider, CmdletProviderContext context)
at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context, Boolean allowNonexistingPaths, CmdletProvider& providerInstance)
at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, CmdletProvider& providerInstance)
at System.Management.Automation.LocationGlobber.GetGlobbedProviderPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, ProviderInfo& provider,
CmdletProvider& providerInstance)
at System.Management.Automation.SessionStateInternal.GetProperty(String[] paths, Collection`1 providerSpecificPickList, CmdletProviderContext context)
at Microsoft.PowerShell.Commands.GetItemPropertyCommand.ProcessRecord()
TargetObject : HKLM:\SOFTWARE\Microsoft\PowerShell\3\DSC
CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell\3\DSC:String) [Get-ItemProperty], ItemNotFoundException
FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at ConvertTo-MOFInstance, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1: line 614
at <ScriptBlock>, <No file>: line 341
at <ScriptBlock>, C:\Temp\PSRepo.ps1: line 21
at Node, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1: line 1026
at <ScriptBlock>, C:\Temp\PSRepo.ps1: line 19
at Configuration, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1: line 2232
at <ScriptBlock>, C:\Temp\PSRepo.ps1: line 5
at <ScriptBlock>, C:\Temp\PSRepo.ps1: line 41
PipelineIterationInfo : {0, 1}
$Error[0..5] | FL *
Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\DSC' because it does not exist.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:614 char:32
+ ... $reg = Get-ItemProperty -path $key -name "PSDscAllowDomainUser" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell\3\DSC:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\DSC' because it does not exist.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:607 char:32
+ ... $reg = Get-ItemProperty -path $key -name "PSDscAllowPlainTextPas ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell\3\DSC:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\DSC' because it does not exist.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:614 char:32
+ ... $reg = Get-ItemProperty -path $key -name "PSDscAllowDomainUser" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell\3\DSC:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\DSC' because it does not exist.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:607 char:32
+ ... $reg = Get-ItemProperty -path $key -name "PSDscAllowPlainTextPas ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell\3\DSC:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Microsoft.PowerShell.Core\Get-Command : The term 'NuGet.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:12810 char:25
+ ... $nugetCmd = Microsoft.PowerShell.Core\Get-Command -Name $script:NuGet ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (NuGet.exe:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Microsoft.PowerShell.Core\Get-Command : The term 'NuGet.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:11530 char:21
+ ... $nugetCmd = Microsoft.PowerShell.Core\Get-Command -Name $script:NuGet ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (NuGet.exe:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
VERBOSE: An LCM method call arrived from computer <servername> with user sid <some sid>.
VERBOSE: [<servername>]: LCM: [ Start Set ]
VERBOSE: [<servername>]: LCM: [ Start Resource ] [[PSRepository]AddRepository]
VERBOSE: [<servername>]: LCM: [ Start Test ] [[PSRepository]AddRepository]
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Determining if the repository 'TestRepo' is in the desired state.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Return the current state of the repository 'TestRepo'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.psm1'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.psd1'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Loading 'FormatsToProcess' from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.format.ps1xml'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.psm1'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Find-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Find-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Get-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Get-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Get-PackageSource'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Import-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Install-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Install-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Register-PackageSource'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Save-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Set-PackageSource'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Uninstall-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Exporting cmdlet 'Unregister-PackageSource'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Find-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Find-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Get-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Get-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Get-PackageSource'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Import-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Install-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Install-PackageProvider'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Register-PackageSource'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Save-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Set-PackageSource'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Uninstall-Package'.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Importing cmdlet 'Unregister-PackageSource'.
WARNING: [<servername>]: [[PSRepository]AddRepository] MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
WARNING: [<servername>]: [[PSRepository]AddRepository] Unable to download the list of available providers. Check your internet connection.
VERBOSE: [<servername>]: [[PSRepository]AddRepository] Repository 'TestRepo' is in the desired state.
VERBOSE: [<servername>]: LCM: [ End Test ] [[PSRepository]AddRepository] in 6.8420 seconds.
VERBOSE: [<servername>]: LCM: [ Skip Set ] [[PSRepository]AddRepository]
VERBOSE: [<servername>]: LCM: [ End Resource ] [[PSRepository]AddRepository]
VERBOSE: [<servername>]: LCM: [ End Set ]
VERBOSE: [<servername>]: LCM: [ End Set ] in 7.2700 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 8.286 seconds
But there is no Repo...
I did a lot of testing, remodeling the Dsc Resources for PowerShellGet, but still i get this error. Even with Credentials, i'm not able to configure PSRepository with Dsc. I took out the Set-TargetResource and run it in a shell with or without admin privs, everything is working. As soon i try to run it with Dsc(even with Credentials) the error is there.
<#
.SYNOPSIS
Creates, removes or updates the repository.
.PARAMETER Ensure
If the repository should be present or absent on the server
being configured. Default values is 'Present'.
.PARAMETER Name
Specifies the name of the repository to manage.
.PARAMETER SourceLocation
Specifies the URI for discovering and installing modules from
this repository. A URI can be a NuGet server feed, HTTP, HTTPS,
FTP or file location.
.PARAMETER ScriptSourceLocation
Specifies the URI for the script source location.
.PARAMETER PublishLocation
Specifies the URI of the publish location. For example, for
NuGet-based repositories, the publish location is similar
to http://someNuGetUrl.com/api/v2/Packages.
.PARAMETER ScriptPublishLocation
Specifies the URI for the script publish location.
.PARAMETER InstallationPolicy
Specifies the installation policy. Valid values are 'Trusted'
or 'Untrusted'. The default value is 'Untrusted'.
.PARAMETER PackageManagementProvider
Specifies a OneGet package provider. Default value is 'NuGet'.
#>
function Set-TargetResource {
[CmdletBinding()]
param
(
[Parameter()]
[ValidateSet('Present', 'Absent')]
[System.String]
$Ensure = 'Present',
[Parameter(Mandatory = $true)]
[System.String]
$Name,
[Parameter()]
[System.String]
$SourceLocation,
[Parameter()]
[System.String]
$ScriptSourceLocation,
[Parameter()]
[System.String]
$PublishLocation,
[Parameter()]
[System.String]
$ScriptPublishLocation,
[Parameter()]
[ValidateSet('Trusted', 'Untrusted')]
[System.String]
$InstallationPolicy = 'Untrusted',
[Parameter()]
[System.String]
$PackageManagementProvider = 'NuGet'
)
$null = $PSBoundParameters.Remove('Ensure')
$getTargetResourceResult = Get-PSRepository -Name $Name -ErrorAction SilentlyContinue
# Determine if the repository should be present or absent.
if ($Ensure -eq 'Present') {
# Determine if the repository is already present.
if ($getTargetResourceResult) {
Write-Verbose -Message ($localizedData.RepositoryExist -f $Name)
# Repository exist, update the properties.
$null = Set-PSRepository @PSBoundParameters -ErrorAction 'Stop'
}
else {
Write-Verbose -Message ($localizedData.RepositoryDoesNotExist -f $Name)
# Repository did not exist, create the repository.
$null = Register-PSRepository @PSBoundParameters
}
}
if ($Ensure -eq 'Absent') {
Write-Verbose -Message ($localizedData.RemoveExistingRepository -f $Name)
# Repository did exist, remove the repository.
$null = Unregister-PSRepository @PSBoundParameters -ErrorAction 'Stop'
}
}
# Register Repo
Set-TargetResource -Name "TestRepo" -SourceLocation '<ValidNuGetFeedfromArtifactory>' -Ensure Present -InstallationPolicy Trusted
Get-PSRepository -Name "TestRepo"
$Present = Get-PSRepository -Name "TestRepo" -ErrorAction SilentlyContinue
if($Present) {
Write-Output "yay, Repo registered"
Write-Output "$Present"
}
# Unregister it
Set-TargetResource -Name "TestRepo" -Ensure Absent
$Absent = Get-PSRepository -Name "TestRepo" -ErrorAction SilentlyContinue
if(!($Absent)) {
Write-Output "yay, Repo unregistered"
Write-Output "$Absent"
Get-PSRepository -Name "TestRepo"
}
PS> PowershellGet_Set-TargetResource.ps1
Name InstallationPolicy SourceLocation
---- ------------------ --------------
TestRepo Trusted <ValidNuGetFeedfromArtifactory>
yay, Repo registered
@{Name=TestRepo; SourceLocation=<ValidNuGetFeedfromArtifactory>; Trusted=True; Registered=True; InstallationPolicy=Trusted; PackageManagementProvider=NuGet; PublishLocation=; ScriptS
ourceLocation=; ScriptPublishLocation=; ProviderOptions=System.Collections.Hashtable}
yay, Repo unregistered
PackageManagement\Get-PackageSource : Unable to find repository 'TestRepo'. Use Get-PSRepository to see all available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:9509 char:35
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource], Exception
+ FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
VERBOSE: An LCM method call arrived from computer Servername with user sid S-<somesid>.
VERBOSE: [Servername]: LCM: [ Start Set ]
VERBOSE: [Servername]: LCM: [ Start Resource ] [[PSRepository]AddRepository]
VERBOSE: [Servername]: LCM: [ Start Test ] [[PSRepository]AddRepository]
VERBOSE: [Servername]: [[PSRepository]AddRepository] Determining if the repository 'TestRepo' is in the desired state.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.psm1'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.psd1'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Loading 'FormatsToProcess' from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.format.ps1xml'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.psm1'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Find-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Find-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Get-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Get-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Get-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Import-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Install-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Install-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Register-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Save-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Set-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Uninstall-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Exporting cmdlet 'Unregister-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Find-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Find-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Get-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Get-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Get-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Import-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Install-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Install-PackageProvider'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Register-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Save-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Set-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Uninstall-Package'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Importing cmdlet 'Unregister-PackageSource'.
VERBOSE: [Servername]: [[PSRepository]AddRepository] Repository 'TestRepo' is not in the desired state.
VERBOSE: [Servername]: LCM: [ End Test ] [[PSRepository]AddRepository] in 3.8530 seconds.
VERBOSE: [Servername]: LCM: [ Start Set ] [[PSRepository]AddRepository]
VERBOSE: [Servername]: [[PSRepository]AddRepository] Creating the repository 'TestRepo'.
The property 'Name' cannot be found on this object. Verify that the property exists.
@Outek Adding your example in the issue description to a integration tests does not generate this issue.
configuration MSFT_PSRepository_AddRepository_TestRepo_Config
{
Import-DscResource -ModuleName 'PowerShellGet'
Node $AllNodes.NodeName
{
PSRepository 'Integration_Test'
{
Name = 'TestRepo'
SourceLocation = $Node.TestSourceLocation
InstallationPolicy = 'Trusted'
}
}
}
Context When using configuration MSFT_PSRepository_AddRepository_TestRepo_Config
The 'Microsoft.PowerShell.Management' module was not imported because the 'Microsoft.PowerShell.Management' snap-in was already imported.
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer APPVYR-WIN with user sid S-1-5-21-1930758936-441951309-2831684283-1000.
VERBOSE: [APPVYR-WIN]: LCM: [ Start Set ]
VERBOSE: [APPVYR-WIN]: LCM: [ Start Resource ] [[PSRepository]Integration_Test]
VERBOSE: [APPVYR-WIN]: LCM: [ Start Test ] [[PSRepository]Integration_Test]
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Determining if the repository 'TestRepo' is in the desired state.
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Return the current state of the repository 'TestRepo'.
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] The repository 'TestRepo' was not found.
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Repository 'TestRepo' is not in the desired state.
VERBOSE: [APPVYR-WIN]: LCM: [ End Test ] [[PSRepository]Integration_Test] in 0.0150 seconds.
VERBOSE: [APPVYR-WIN]: LCM: [ Start Set ] [[PSRepository]Integration_Test]
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Return the current state of the repository 'TestRepo'.
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] The repository 'TestRepo' was not found.
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Creating the repository 'TestRepo'.
VERBOSE: [APPVYR-WIN]: LCM: [ End Set ] [[PSRepository]Integration_Test] in 2.2810 seconds.
VERBOSE: [APPVYR-WIN]: LCM: [ End Resource ] [[PSRepository]Integration_Test]
VERBOSE: [APPVYR-WIN]: LCM: [ End Set ]
VERBOSE: [APPVYR-WIN]: LCM: [ End Set ] in 2.3430 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.364 seconds
[+] Should compile and apply the MOF without throwing 2.72s
VERBOSE: An LCM method call arrived from computer APPVYR-WIN with user sid S-1-5-21-1930758936-441951309-2831684283-1000.
VERBOSE: [APPVYR-WIN]: LCM: [ Start Get ]
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Return the current state of the repository 'TestRepo'.
VERBOSE: [APPVYR-WIN]: LCM: [ End Get ] [[PSRepository]Integration_Test] in 0.0450 seconds.
VERBOSE: [APPVYR-WIN]: LCM: [ End Get ] in 0.0890 seconds.
[+] Should be able to call Get-DscConfiguration without throwing 137ms
[+] Should have set the resource and all the parameters should match 62ms
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = TestConfiguration,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer APPVYR-WIN with user sid S-1-5-21-1930758936-441951309-2831684283-1000.
VERBOSE: [APPVYR-WIN]: LCM: [ Start Test ]
VERBOSE: [APPVYR-WIN]: LCM: [ Start Resource ] [[PSRepository]Integration_Test]
VERBOSE: [APPVYR-WIN]: LCM: [ Start Test ] [[PSRepository]Integration_Test]
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Determining if the repository 'TestRepo' is in the desired state.
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Return the current state of the repository 'TestRepo'.
VERBOSE: [APPVYR-WIN]: [[PSRepository]Integration_Test] Repository 'TestRepo' is in the desired state.
VERBOSE: [APPVYR-WIN]: LCM: [ End Test ] [[PSRepository]Integration_Test] True in 0.0520 seconds.
VERBOSE: [APPVYR-WIN]: LCM: [ End Resource ] [[PSRepository]Integration_Test]
VERBOSE: [APPVYR-WIN]: LCM: [ End Test ] Completed processing test operation. The operation returned True.
VERBOSE: [APPVYR-WIN]: LCM: [ End Test ] in 0.0950 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 0.114 seconds
[+] Should return $true when Test-DscConfiguration is run 154ms
Where you are seeing this issue, is it using the correct version of PowerShellGet? So it does not load older version for another user or something. Just guessing here. 🤔
Hi guys, any updates? We have the same issue. It reproducible only with DSC and only on some machines.
@alex-titarenko can you reproduce this on one machine? If so it possible for you to figure out what is different from one that do work? Would help if we can figure out what line in the code that throws the error, it might help narrow down what the cause is.,
@johlju thank you for the replay. I attached logs from good and bad VM (sensitive information was replaced).
The main difference in logs I see that in VM when it fails:
PowerShell Script 'PSModule' Function 'Resolve-PackageSource' returns null.
The property 'Name' cannot be found on this object. Verify that the property exists.
+ CategoryInfo : NotSpecified: (Microsoft.Power...erPackageSource:) [], CimException
+ FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource
+ PSComputerName : localhost
And on VM where it works:
[[xPackageManagement]Package] Done calling powershell «Resolve-PackageSource» «PSModule»
You can compare logs to see more details.
On code side it fails inside our xPackageManagement DSC module when we try Register-PSRepository
.
I did notice, some package version differences on VMs
Good VM:
PS C:\windows\system32> Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Con...
PowerShellGet 2.2.3.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, Insta...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
PS C:\windows\system32> Get-Module PackageManagement
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.6 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackagePr...
Bad VM:
PS C:\windows\system32> Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Con...
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, Insta...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
PS C:\windows\system32> Get-Module PackageManagement
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.7 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackagePr...
But, after changing package versions, I did not see any differences in logs. The issue is still there.
I found the root cause of the issue.
The file %localappdata%\Microsoft\windows\PowerShell\PowerShellGet\PSRepositories.xml
was in a bad state.
After deleting it everything started working.
The issue was reproduceable only with DSC because %localappdata%
variable will be resolved to C:\Windows\System32\config\systemprofile\AppData\Local
when run through DSC and to you local profile if you run with the shell.
I found the root cause of the issue. The file
%localappdata%\Microsoft\windows\PowerShell\PowerShellGet\PSRepositories.xml
was in a bad state. After deleting it everything started working.The issue was reproduceable only with DSC because
%localappdata%
variable will be resolved toC:\Windows\System32\config\systemprofile\AppData\Local
when run through DSC and to you local profile if you run with the shell.
Do you know where this path might be on PowerShell Core for Mac?
Edit, found: /Users/<user>/.cache/powershell/PowerShellGet/
- but deleting PSRepositories.xml
didn't fix the issue
Steps to reproduce
Expected behavior
A new source should be registered after the Dsc
Actual behavior
An Error occured.
Environment data