Open psinnathurai opened 9 months ago
It seems like some of the formatting got lost in the posting process.
Configuration PowerShell7 {
Import-DscResource -ModuleName Microsoft.WinGet.DSC
node localhost {
WinGetPackage PowerShell7 {
Id = 'Microsoft.PowerShell'
source = 'winget'
InstallMode = 'silent'
}
}
}
PowerShell7
New-GuestConfigurationPackage -Configuration powershell7\localhost.mof -Name WinGet_PowerShell7 -Type AuditAndSet
$existingAccountParams = @{
ResourceGroupname = 'rg-machineconfiguration-mgt-dev-szn-01'
Name = 'stsimgtdevsznmachineconf'
}
$container = Get-AzStorageAccount @existingAccountParams |
Get-AzStorageContainer -Name machineconfiguration
$setParams = @{
Container = 'machineconfiguration'
File = '.\WinGet_PowerShell7.zip'
Context = $container.Context
}
$blob = Set-AzStorageBlobContent @setParams
$contentUri = $blob.ICloudBlob.Uri.AbsoluteUri
$PolicyConfig = @{
PolicyId = (New-Guid)
ContentUri = $contentUri
DisplayName = 'WinGet_PowerShell7'
Description = 'Install PowerShell 7 using WinGet'
Path = './WinGet_PowerShell7'
Platform = 'Windows'
PolicyVersion = '1.0.0'
Mode = 'ApplyAndAutoCorrect'
}
New-GuestConfigurationPolicy @PolicyConfig
New-AzPolicyDefinition -Name 'Winget_PowerShell7' -Policy WinGet_PowerShell7\WinGet_PowerShell7_DeployIfNotExists.json
Hi @psinnathurai,
Thanks for the very detailed error report.
Machine
scope. So this could be a scope mismatch if installed in User
scope, or in a non-elevated session.
@psinnathurai Does it work if you test applying the Machine Configuration package using Start-GuestConfigurationPackageRemediation -Path ".\WinGet_PowerShell7.zip"
?
Reason for asking is that Machine Configuration applies configurations as SYSTEM
, so was wondering whether it behaves differently when applying the configuration as a regular (admin) user account.
Being in SYSTEM
context might complicate the situation. The client only recently gained the ability to run in this context:
Hello all, we've published Microsoft.WinGet.Client with the ability to run WinGet in the system context. It does require running in PowerShell 7 with "-MTA".
Edit: And would require as prerequisite the same Powershell 7 package as this Issue was opened to install. Bit of a catch.
Hi @psinnathurai,
Thanks for the very detailed error report.
- From the error "NoApplicableInstallers", it sounds like a package manager level error - as though the package manager is successfully being interacted with and emitting an error.
- From here, it could be a manifest issue. Reviewing the most recent Microsoft.Powershell installer file, all installers are set to
Machine
scope.So this could be a scope mismatch if installed in
User
scope, or in a non-elevated session.
- Is this running in an Administrator session or a non-elevated session?
- Can the WinGet logs for the install be uploaded?
- Have you tried installing any other software packages in this way?
How can I set the Machine Scope for the DSC Resource? I didn't found a Scope Property in the DSC Resources.
Machine Configuration should run in SYSTEM Context.
I also tried to install Visual Studio Code in the same Method now, with Visual Studio Code the Machine Configuration appears as Compliant even if Visual Studio code is not installed.
@psinnathurai Does it work if you test applying the Machine Configuration package using
Start-GuestConfigurationPackageRemediation -Path ".\WinGet_PowerShell7.zip"
?Reason for asking is that Machine Configuration applies configurations as
SYSTEM
, so was wondering whether it behaves differently when applying the configuration as a regular (admin) user account.
I was able to run it in a Elevated Session but I needed to install PowerShell 7 first.. So to install PowerShell 7 using Winget a Prereq would be PowerShell 7 itself?
I tried to install Visual Studio Code now.
The WinGet DSC Resource depends on the Microsoft.WinGet.Client PowerShell module for most operations. We still have work to see if we can get it to work correctly using Windows PowerShell. There are several missing dependencies we're working to identify and include in the module. For now, you would need PowerShell 7 to run cmdlets like "Install-WinGetPackage".
Note: Repair-WinGetPackageManager should work in Windows PowerShell.
Brief description of your issue
I have a created a Machine Configuration Policy using the PowerShell DSC Module Microsoft.WinGet.DSC and deployed it to an Azure Arc Enabled Server with the Windows Server Insider Version 26063 which has winget installed. I receive the following Issue "PowerShell DSC resource Microsoft.WinGet.DSC failed to execute Set functionality with error message: WinGetPackage Failed installing Microsoft.PowerShell. InstallStatus 'NoApplicableInstallers' InstallerErrorCode '0' ExtendedError '-1978335216' The SendConfigurationApply function did not succeed. LCM failed to start desired state configuration manually."
Steps to reproduce
Create a DSC File and convert it to a Machine Configuration using the following COmmands: `Configuration PowerShell7
PowerShell7
New-GuestConfigurationPackage -Configuration powershell7\localhost.mof -Name WinGet_PowerShell7 -Type AuditAndSet
$existingAccountParams = @{ ResourceGroupname = 'rg-machineconfiguration-mgt-dev-szn-01' Name = 'stsimgtdevsznmachineconf' }
$container = Get-AzStorageAccount @existingAccountParams | Get-AzStorageContainer -Name machineconfiguration
$setParams = @{ Container = 'machineconfiguration' File = '.\WinGet_PowerShell7.zip' Context = $container.Context }
$blob = Set-AzStorageBlobContent @setParams $contentUri = $blob.ICloudBlob.Uri.AbsoluteUri
$PolicyConfig = @{ PolicyId = (New-Guid) ContentUri = $contentUri DisplayName = 'WinGet_PowerShell7' Description = 'Install PowerShell 7 using WinGet' Path = './WinGet_PowerShell7' Platform = 'Windows' PolicyVersion = '1.0.0' Mode = 'ApplyAndAutoCorrect' }
New-GuestConfigurationPolicy @PolicyConfig
New-AzPolicyDefinition -Name 'Winget_PowerShell7' -Policy