Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error during installing PSWindows Update module

I was going to automate some regular task on client computers using Powershell module. In this way, PSWINDOWSUPDATE is one of bests. But, I receive an error during install that:

    PS C:\Users\stackoverflow> install-module -name pswindowsupdate -scope currentuser 
    PackageManagement\Install-Package : Package 'PSWindowsUpdate' failed to be installed because: 
Access to the path        'C:\Users\stackoverflow\AppData\Local\Temp\ipufiq2h\PSWindowsUpdate.dll' is denied.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
    + ...          $null = PackageManagement\Install-Package @PSBoundParameters
    +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidResult: (PSWindowsUpdate:String) [Install-Package], Exception
        + FullyQualifiedErrorId : Package '{0}' failed to be installed because: {1},Microsoft.PowerShell.PackageManagement
       .Cmdlets.InstallPackage

running the command in administrative mode and without -scope switch didn't solve the problem.

Edit1: The problem is solved. But there is another problem. When I call import-module pswindowsupdate following error occurs:

import-module : Errors occurred while loading the format data file:
C:\Users\stackoverflow\Documents\WindowsPowerShell\Modules\pswindowsupdate\2.2.0.2\PSWindowsUpdate.Format.ps1xml, ,
C:\Users\stackoverflow\Documents\WindowsPowerShell\Modules\pswindowsupdate\2.2.0.2\PSWindowsUpdate.Format.ps1xml: The file was skipped because of the following validation exception: File
C:\Users\stackoverflow\Documents\WindowsPowerShell\Modules\pswindowsupdate\2.2.0.2\PSWindowsUpdate.Format.ps1xml cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170..
At line:1 char:1
+ import-module pswindowsupdate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
like image 905
Salem Avatar asked Aug 28 '26 08:08

Salem


1 Answers

Use Get-ExecutionPolicy to set it e.g. to RemoteSigned:

Get-ExecutionPolicy -List
Set-ExecutionPolicy RemoteSigned

also see here

like image 195
Albin Avatar answered Aug 31 '26 04:08

Albin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!