Share via

Ran Normal PowerShell Command- Scriptblock Logging Says Things About 'Untrusted Repository'?

Anonymous
2023-11-06T01:53:46+00:00

I ran "Get-InstalledModule" to check if there are any modules installed, to which it returned empty and indicated that there were no installed modules, which is how it should be

however, I looked in the PowerShell > Operational log in Event Viewer > Applications and Services > Windows, and saw around 4 Warning events. after combing through what they said, I'm kind of concerned

I've run 'Get-InstalledModule' several times today, and these Warning scriptblock events happen in response to that command. They mention things like this;

"UnableToUninstallAsOtherScriptsNeedThisScript=The script '{0}' of version '{1}' in script base folder '{2}' cannot be uninstalled, because one or more other scripts '{3}' are dependent on this script. Uninstall the scripts that depend on this script before uninstalling script '{4}'"

"RepositoryIsNotTrusted=Untrusted repository"

"QueryInstallUntrustedPackage=You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from '{1}'?"

"QueryInstallUntrustedScriptPackage=You are installing the scripts from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the scripts from '{1}'?"

"QuerySaveUntrustedPackage=You are downloading the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to download the modules from '{1}'?"

"QuerySaveUntrustedScriptPackage=You are downloading the scripts from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to download the scripts from '{1}'?"

"SourceNotFound=Unable to find repository '{0}'. Use Get-PSRepository to see all available repositories."

"NuGet.exe must be available in '{0}' or '{1}, or under one of the paths specified in PATH environment variable value. NuGet.exe can be downloaded from [link]. Do you want PowerShellGet to install NuGet.exe now?"

"InstallNuGetBinariesShouldContinueCaption2=NuGet.exe and NuGet provider are required to continue"

"InstallNuGetProviderShouldContinueCaption=NuGet provider is required to continue"

"InstallNuGetExeShouldContinueCaption=NuGet.exe is required to continue"

"DownloadingNugetExe=Installing NuGet.exe."

"DownloadingNugetProvider=Installing NuGet provider."

"ModuleNotFound=Module '{0}' was not found."

I checked my other device because I remember running Get-InstalledModule a few times on it over the past few days and these same Warning events appear in the Operational log as well.

did I infect myself? I don't get why it says the repository is untrusted

why are these Warning events being logged and why is it claiming to download NuGet for me, or downloading scripts/modules when I never said to do that or confirmed it??

is this normal? can anyone else confirm if these events are logged in PowerShell > Operational by running Get-InstalledModule (if it returns empty). or can someone with knowledge explain what this all means?

Windows for home | Windows 10 | Security and privacy

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-11-07T03:00:55+00:00

    Hello, JamLow

    Welcome to Microsoft Community.

    The warning messages you are encountering do not necessarily indicate a problem or infection. They are part of PowerShell's inherent security measures designed to safeguard against potentially harmful scripts or modules from untrusted sources.

    Moreover, when you execute the Get-InstalledModule command, PowerShell scans its known repositories for modules. If a repository is not set as trusted, you will receive the "Untrusted repository" warning. However, this doesn't imply that there is an issue; it simply informs you that the repository's trust level is currently set to untrusted.

    Additionally, the references to NuGet arise because PowerShell employs NuGet as a package provider for installing modules. If NuGet is not found in the specified locations or the PATH environment variable, PowerShell offers to install it for you.

    Conversely, the "UnableToUninstallAsOtherScriptsNeedThisScript" warning is displayed when attempting to uninstall a script that other scripts are dependent on.

    To mitigate these warnings, you can designate the repository as trusted using the Set-PSRepository cmdlet. However, only proceed with this action if you are certain that the repository is secure.

    For instance, you can use the following command:

    Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
    

    This command establishes the PowerShell Gallery (PSGallery) as a trusted repository, thereby averting the "Untrusted repository" warnings. However, it's crucial to exercise caution and exclusively install scripts and modules from sources you trust to evade potential security risks. If uncertain, it's advisable to leave the repository as untrusted and manually inspect scripts and modules before installation.

    Yuhao Li

    Microsoft Community Technical Support

    Was this answer helpful?

    0 comments No comments