Warnings When Attempting to Install Sysinternals With Powershell - 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.

Related

How to fix Nuget Provider "Find-Module" Installation error with PowerShell 7.3?

I've been trying to run a PowerShell script, and upon doing so, I receive a message that NuGet Provider is required.
NuGet provider is required to continue
This version of PowerShellGet requires minimum version '2.8.5.201' of NuGet provider to publish an item to NuGet-based
repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\timothy.granata\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider
by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
If I input Y, an error is returned:
Find-Module: 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.
If I try running Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force as it recommends, I also get an error:
Install-PackageProvider: Unable to find repository with SourceLocation ''. Use Get-PSRepository to see all available repositories.
And finally, if I run Get-PSRepository, that also errors:
Get-PackageSource: Unable to find module providers (PowerShellGet).
In the script I am trying to debug, the code that seems to trigger this prompt is Install-AWSToolsModule SecurityToken -Force. The surrounding code looks like:
if (-not (Get-Module AWS.Tools.Installer -ListAvailable)) {
Install-Module AWS.Tools.Installer -Force
}
Install-AWSToolsModule SecurityToken -Force
Get-AWSCredential -ListProfileDetail | ForEach-Object {
Remove-AWSCredentialProfile -ProfileName $_.ProfileName -Force
}
I have tried:
Reinstalling PowerShell 7
Making sure I am using TLS 1.2 by running [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Running PowerShell as Administrator
Deleting the Modules folder found in my C:\Users<user>\Documents\WindowsPowerShell folder
I'm unsure what else I can try at this point. How can I install the NuGet provider for use with PowerShell 7.3?
Try
$sourceArgs = #{
Name = 'nuget.org'
Location = 'https://api.nuget.org/v3/index.json'
ProviderName = 'NuGet'
}
Register-PackageSource #sourceArgs
Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider
EDIT
Perhaps try
Invoke-WebRequest 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.8.1' -OutFile $env:temp\nuget.zip
And confirm you're able to download the nuget package. If so, then try
Expand-Archive $env:temp\nuget.zip -DestinationPath 'C:\Program Files\PowerShell\7\Modules\PackageManagement' -Force
Import-Module PackageManagement -Verbose -Force
It seems something with OneDrive was indeed throwing this off as I wondered in my one comment. I found this post which stated (from some Microsoft Documentation):
The user-specific CurrentUser location on Windows is the PowerShell\Modules folder located in the Documents location in your user profile ... Microsoft OneDrive can also change the location of your Documents folder.
I ran $env:PSModulePath and sure enough their was a OneDrive location. I ended up doing what the answer on that post suggested, and excluded the PowerShell directory from OneDrive. After doing this, my script seems to work now (it doesn't produce errors, or that prompt). Ever after doing this, the OneDrive location still shows up from the $env:PSModulePath command, but I guess it falls back to the next modules location if it can't find a directory.

PowerShellGet "unable to find package source" upon Install-Module, despite Find-Module working correctly

I recently created an Azure Artifacts feed for one of the projects in my organization. I followed the instructions at this link.
Most things work. In particular, I'm able to:
Create the feed
Use nuget to push a package to said feed
Register the feed with PowerShell via Register-PSRepository
Run Find-Module -Repository <Repository Name>
The last bit -- running Find-Module -- generates the expected output, viz., a single module with the expected version, name, and description. However, I get the following message when I attempt Install-Module:
PS C:\Windows\System32> install-module -name ADHelpers -Repository 'ADHelpersTest2'
Install-Package: C:\Users\my_name\OneDrive\Documents\PowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711
Line |
9711 | … talledPackages = PackageManagement\Install-Package #PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unable to resolve package source
| 'https://pkgs.dev.azure.com/my_organization/my_project/_packaging/my_feed/nuget/v2'.
I've scrubbed my organization, project, and feed name, as I don't think that's important for solving this problem.
My question is simple: What could cause this? I'm confused that I'm able to Find-Module just fine, but unable to run Install-Module for the result that Find-Module successfully fetches.
I've been unsuccessful in finding guidance elsewhere, and am unsure what I'm doing wrong.
Thanks in advance -- I appreciate your time.
If you want to install the custom package in the Azure DevOps pipeline, you could add task power shell and run the script Install-Package ADHelpers -Scope CurrentUser -Force
to install the package.
In my sample, the package name is Get-Hello and the result is:
You could refer to this blog and my previous answers for more details

Update-Module not finding PSGallery repo in script as a scheduled task

I have a scheduled task which runs an exported function from my PowerShell module which is hosted at powershellgallery.com. The function performs a check against the built-in PSGallery repository to see if a newer version is available and if so, update it.
I've noticed my module is not being updated as it should and to troubleshoot the issue I've redirected the output from two separate commands. First, to make sure the repository is 'visible' to the SYSTEM account running the task I run:
Get-PSRepository *>> c:\repo.log
This yields the following output:
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2
So the SYSTEM account running the function as a scheduled task can 'see' the repo; no problem. Next, the function runs the Update-Module command as such:
Update-Module -Name $ProductName -Confirm:$false -Force -Verbose *>> c:\update.log
This yields the following output:
Checking for updates for module '[removed by me]'.
PackageManagement\Install-Package : Unable to find repository 'https://www.powershellgallery.com/api/v2/'. Use
Get-PSRepository to see all available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:12546 char:20
+ ... $sid = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Lastly, I checked the module to make sure it is indeed associated with PSGallery by running:
Get-InstalledModule -Name $ProductName | fl
The output shows:
RepositorySourceLocation : https://www.powershellgallery.com/api/v2/
Repository : PSGallery
UPDATE: I decided to use the Install-Module with the -Force switch to 'update' the module instead as I couldn't get the other command to work. Oddly though, when I do a Get-InstalledModule -AllVersions I can clearly see a difference between a module installed interactively and one installed under the SYSTEM account (running as a scheduled task). Pay attention to the Repository column:
If I run the function interactively it works without issue.
If I run Find-Module -Name $ProductName from within the function it finds the module without issue.
Tried both solutions from other question to no avail...
Any idea why the Update-Module command can't find the repo??
I believe you are seeing the bug described in https://github.com/PowerShell/PowerShellGet/issues/349 . It's not really related to SYSTEM account. Simplest workaround until fixed version is released is to uninstall the module then reinstall it again. You should only have to do that once, and update-module should work thereafter.
UPDATE: This is resolved in newer builds of PowerShellGet.

powershell update-help fails

I just started to learn PowerShell from the Microsoft virtual academy and I was running one of the commands indicated. while on their end it worked mine did not. I did look around for a solution to this issue. I just don't know what went wrong. any tips will helpful for this new PowerShell learner.
PS C:\Windows\system32> Update-Help -Force
Update-Help : Failed to update Help for the module(s) 'WindowsUpdateProvider' with UI culture(s) {en-US} : Unable to retrieve the HelpInfo XML file for UI culture en-US. Make sure the
HelpInfoUri property in the module manifest is valid or check your network connection and then try the command again.
At line:1 char:1
+ Update-Help -Force
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCommand
PS C:\Windows\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.228
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.228
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Agreed, that this should be a SuperUser post, but since it is here.
This sort of error common and in most cases expected.
Not all the help files, update as expected for various reasons, most of the time its do to the update link associated. As shown in your error message.
Many module either have no online updateable help or the URL has been removed.
These sorts of error can be safely ignored. They do not impact PS functionality or use.
Get-Module -ListAvailable | Where HelpInfoUri | Update-Help
Or if you want to see all the message going back and forth with this, do...
Update-Help -Force -Verbose -ErrorAction SilentlyContinue
# Results
VERBOSE: Resolving URI: "http://go.microsoft.com/fwlink/?linkid=390758"
VERBOSE: Your connection has been redirected to the following URI: "http://download.microsoft.com/download/0/1/C/01CCC594-2F13-40E8-98FE-185486228BF4/"
VERBOSE: Performing the operation "Update-Help" on target "CimCmdlets, Current Version: 5.0.0.0, Available Version: 5.0.0.0, UICulture: en-US".
If you want to see the full error message in a more human readable for, do this...
Update-Help -Force -Ea 0 -Ev ErrMsgDetail
$ErrorMsgDetail.Exception
Failed to update Help for the module(s) 'AnyBox' with UI culture(s) {en-US} : Unable to connect to Help content. The server on which Help content is stored might not be available.
Verify that the server is available, or wait until the server is back online, and then try the command again.
Failed to update Help for the module(s) 'HostNetworkingService, WindowsUpdateProvider' with UI culture(s) {en-US} : Unable to retrieve the HelpInfo XML file for UI culture en-US.
Make sure the HelpInfoUri property in the module manifest is valid or check your network connection and then try the command again.
Actually the problem might also be related to privileges. At least it was for me. On a default Windows 10 install, Update-Help would not work at all, nor did all the other versions with -Force or -ErrorAction.
It turned out, also according to the official online help, you need to be administrator to update the help for powershell <6.0 (which Windows 10 defaults to PS5.1). Starting a new PowerShell with admin privileges immediately removed the problems and I could also view the help as a non-admin.
TL;DR:
Open Powershell, paste the command below and run Update-Help and it should download all AVAILABLE help files:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
It will a give a red warning for the modules that did not have any help files like:
update-help : Failed to update Help for the module(s) 'ConfigDefender, ConfigDefenderPerformance, PSReadline,
WindowsUpdateProvider' with UI culture(s) {en-US} : Unable to retrieve the HelpInfo XML file for UI culture en-US.
Make sure the HelpInfoUri property in the module manifest is valid or check your network connection and then try the
command again.
At line:1 char:1
+ update-help
+ ~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCommand
Long story:
I was trying to find a module and install it:
Find-Module -Name AudioDeviceCmdlets
But it needs NuGet so it prompts to install it but it failed for me:
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet
provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'$HOME\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import
the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
So I googled for a solution and found out that I need to paste this on Powershell:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
And the NuGet installed just fine, so I remember the issue I had with Update-Help, so I tried it and it worked, and now when I do for example Get-Help Get-Item the help is shown fully.
From Niels Weistra on answers.microsoft:
The solution mentioned above is a workaround, to solve your issue permanently
Open Powershell and check for supported protocols by using [Net.ServicePointManager]::SecurityProtocol
Run the following 2 cmdlets to set .NET Framework strong cryptography registry keys:
Set strong cryptography on 64 bit .Net Framework (version 4 and above):
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Set strong cryptography on 32 bit .Net Framework (version 4 and above):
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Restart Powershell and check again for supported protocol by using [Net.ServicePointManager]::SecurityProtocol
Source:
https://answers.microsoft.com/en-us/windows/forum/all/trying-to-install-program-using-powershell-and/4c3ac2b2-ebd4-4b2a-a673-e283827da143
Install NuGet via PowerShell script
I am new to Powershell and found this fixed my problem.
reference link
Update-Help -Verbose -Force -ErrorAction SilentlyContinue

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