I am trying to install DSC Module on a basic Windows 2019 Server. It just fails silently. This is a brand new servers that are failing
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if(!(get-packageprovider -name nuget)){
Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force -Scope CurrentUser
}
Set-PSRepository -Name 'PsGallery' -InstallationPolicy Trusted
Install-Module -Name NetworkingDsc -RequiredVersion 8.1.0 -AllowClobber -Repository PSGallery -Verbose
What is the error you are getting ?
No error. It just fails silently
use -ErrorAction Stop for all the cmdlets. It should fail, else its wont be easy to find the reason.
I am getting these errors:
Exception calling "ShouldContinue" with "2" argument(s): "Windows PowerShell
is in NonInteractive mode. Read and Prompt functionality is not available."
At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7392 char:8
+ if($Force -or $psCmdlet.ShouldContinue($shouldContinueQueryMessag ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PSInvalidOperationException
Set-PSRepository : NuGet provider is required to interact with NuGet-based
repositories. Please ensure that â2.8.5.201â or newer version of NuGet
provider is installed.
At C:\ProgramData\Amazon\SSM\InstanceData\i-015ccaaf3fcfd076a\document\orchestr
ation\800b245a-c7c4-4340-943a-bdea231b4760\runPowerShellScript_script.ps1:7
char:5
Get-PackageProvider : Unable to find package provider âNugetâ.
At C:\ProgramData\Amazon\SSM\InstanceData\i-015ccaaf3fcfd076a\document\orchestr
ation\800b245a-c7c4-4340-943a-bdea231b4760\runPowerShellScript_script.ps1:11
char:7
If ( (Get-PackageProvider -Name Nuget -ListAvailable).Version -le 2.8 âŚ
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (Microsoft.PowerâŚPackageProvid
er:GetPackageProvider) [Get-PackageProvider], Exception
FullyQualifiedErrorId : UnknownProvider,Microsoft.PowerShell.PackageMana
gement.Cmdlets.GetPackageProvider
I am trying to run this script:
âImport-Module -Name PowerShellGet -Force\nâ,
âImport-Module -Name PackageManagement -Force\nâ,
âif ( (Get-PSRepository -Name âPSGalleryâ).InstallationPolicy -eq âUntrustedâ ) {\nâ,
" Set-PSRepository -Name âPSGalleryâ -InstallationPolicy Trusted \n",
â}\nâ,
âIf ( (Get-PackageProvider -Name Nuget -ListAvailable).Version -le 2.8.5.208 ) {\nâ,
" Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.208 -Force\n",
â}\nâ,
âif ( -not ( Get-Module -Name PSDscResources -ListAvailable ) ) {\nâ,
" Install-Module PSDscResources -AllowClobber -SkipPublisherCheck -Confirm:$false -Force\n",
â}\nâ,
âif ( -not ( Get-Module -Name PSDscResources ) ) {\nâ,
" Import-Module -Name PSDscResources -Global -Force -PassThru \n",
â}\n\nâ
I think I got it:
"Import-Module -Name PowerShellGet -Force\n",
"Import-Module -Name PackageManagement -Force\n",
"try {\n",
" If ( (Get-PackageProvider -Name Nuget -ListAvailable -ErrorAction Stop ).Version -le 2.8.5.208 ) {\n",
" Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.208 -Force\n",
" }\n",
"} catch {\n",
" Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.208 -Force\n",
"}\n",
"if ( (Get-PSRepository -Name 'PSGallery').InstallationPolicy -eq 'Untrusted' ) {\n",
" Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted \n",
"}\n",
"if ( -not ( Get-Module -Name PSDscResources -ListAvailable ) ) {\n",
" Install-Module PSDscResources -AllowClobber -SkipPublisherCheck -Confirm:$false -Force\n",
"}\n",
"if ( -not ( Get-Module -Name PSDscResources ) ) {\n",
" Import-Module -Name PSDscResources -Global -Force -PassThru \n",
"}\n\n",
Olaf
May 15, 2021, 1:33pm
8
dan-iverson:
I think I got it:
Could you please format your codse as code here in the forum? You can go back and edit your already existing posts to correct the formatting.
Thanks in advacne.
It is in â <\code>â blocks.
Olaf
May 18, 2021, 4:08pm
10
I donât know how it looks for you but for me it does not look like code at all.
Do you see any difference between one of your code blocks and the code block @monterey610 posted in his initial question?
Yes, I see the difference, his is PowerShell and mine is JSON.
Olaf
May 21, 2021, 6:29pm
12
No.
His looks like correctly formated code including syntax highlighting and indentation
And yours just does not.
1 Like
@dan-iverson Iâve formatted the json content. The best way to format is , once the code is pasted/typed while posting, select all the code and click on the prefrmatted text button (the sixth option in the tool bar on top while posting)
2 Likes