Cannot install any power modules

David Barkley 1 Reputation point
2021-05-22T20:12:38.187+00:00

When I try to install any powershell modules i get the same error, that a file is being used by another process. This relates to the temp folders and files that are created when downloading the modules. it is almost as if the same download is holding open the file so the install process can not install it. this is happening on all modules I try to install.

PowerShell 7.1.3
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
PS C:\Windows\System32> install-module msonline

Untrusted repository
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
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
Install-Package: C:\Users########\Documents\PowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711
Line |
9711 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Package 'MSOnline' failed to be installed because: The process cannot access the file
| 'C:\Users########\AppData\Local\Temp\ffmrzguy\Microsoft.Data.OData.dll' because it is being used by
| another process.

PS C:\Windows\System32>

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,504 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Aydin, Serkar 6 Reputation points
    2021-07-10T05:15:26.767+00:00

    Have you tried this?
    install-module "msonline" -Scope CurrentUser

    0 comments No comments

  2. Rich Matheisen 46,551 Reputation points
    2021-07-10T14:47:31.423+00:00

    Use "Process Explorer" to find the process holding the file handle.

    process-explorer

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.