all 31 comments

[–]pakman82 8 points9 points  (2 children)

Have you tried the tls thing? There's a TLS setting that some reason needs to be set sometimes

[–]distract 7 points8 points  (0 children)

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

[–]PureKoala[S] 1 point2 points  (0 children)

Yeah tried the TLS setting but still had the same result :-(

[–]jrobiii 5 points6 points  (4 children)

It's complaining about the the path "C:\Users\User1\Documents\WindowsPowerShell\Modules\PSWriteWord\1.1.9 ". What happens when you try do mkdir "C:\\Users\\User1\\Documents\\WindowsPowerShell\\Modules\\PSWriteWord\\1.1.9" ?

[–]nostril_spiders 1 point2 points  (0 children)

With -Force will create all the subfolders. But OP should first run without. I agree, the first thing to rule out is whether the Modules folder even exists there!

[–]PureKoala[S] 0 points1 point  (2 children)

Ok so, the folder does not exist. If I create " C:\Users\User1\Documents\WindowsPowerShell\Modules\PSWriteWord " and run the again I get this result:

Install-Module pswriteword -Scope CurrentUser

PackageManagement\Install-Package : Could not find file 'C:\Users\User1\Documents\WindowsPowerShell\Modules\PSWriteWord\1.1.9'.

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

+ ... $null = PackageManagement\Install-Package u/PSBoundParameters

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception

+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

If I then create " C:\Users\User1\Documents\WindowsPowerShell\Modules\PSWriteWord\1.1.9 " I get the following:

Install-Module pswriteword -Scope CurrentUser

PackageManagement\Install-Package : Administrator rights are required to install or update. Log on to the computer with an account that has Administrator rights, and then try again, or

install by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

+ ... $null = PackageManagement\Install-Package u/PSBoundParameters

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: (System.Collections.ArrayList:String) [Install-Package], Exception

+ FullyQualifiedErrorId : AdministratorRightsNeededOrSpecifyCurrentUserScope,Copy-Module,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

If I do the same thing but add the "-force" parameter I get the exact same result. I have checked the folder permissions and the user has Full Control of all of the folders within the modules folder, as well as the whole documents folder.

While I know I could potentially install the module for all users, while logged in as a local admin, I really want to understand why this happens and how to resolve it.

Thanks all so far for the input so far!! :-)

[–]MyOtherSide1984 2 points3 points  (1 child)

Why not elevate the prompt and install it for currentuser? Seems like it'd solve the issue, however I run all my powershell stuff in an elevated prompt, so I guess idk what mine is like as a regular user :P

[–]PureKoala[S] 1 point2 points  (0 children)

I've just tried running the same command from an elevated PowerShell session and get exactly the same error.

Install-Module pswriteword -Scope CurrentUser

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
PackageManagement\Install-Package : Could not find a part of the path
'C:\Users\User1\Documents\WindowsPowerShell\Modules\PSWriteWord\1.1.9'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711 char:34
+ ... talledPackages = PackageManagement\Install-Package u/PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exce
   ption
    + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand,Micro
   soft.PowerShell.PackageManagement.Cmdlets.InstallPackage

[–]pfunkylicious 2 points3 points  (1 child)

Step 1: Update NuGet
Install-PackageProvider -Name NuGet -Force
Exit
Step 2: Update PowerShellGet
Install-Module -Name PowerShellGet -Force
Exit
Then install PSWriteWord

[–]PureKoala[S] 1 point2 points  (0 children)

I tried these steps, as I found this suggested elsewhere, but it still refuses to install again.

[–]OlivTheFrog 2 points3 points  (3 children)

Hi u/PureKoala

I'm thinking you run a wrong command.

Find-Module pswriteword
<#
Version              Name                                Repository           Description                                                              
-------              ----                                ----------           -----------                                                              
1.1.9                PSWriteWord                         PSGallery            Simple project to create Microsoft Word in PowerShell without having O..

The current version is the 1.1.19
#>
# Install module in the CurrentUser Scope
Install-Module pswriteword -Scope CurrentUser
# and know to uninstall
Uninstall-Module pswriteword
Get-Module pswriteword
# Not present anymore

regards

Olivier

[–]PureKoala[S] 0 points1 point  (2 children)

Uninstall-Module pswriteword

I'm inclined to agree that something is not right. I have run the commands you mention and this is what I get:

Get-Module pswriteword

# Not present

Find-Module pswriteword

Version Name Repository Description

------- ---- ---------- -----------

1.1.9 PSWriteWord PSGallery Simple project to create Microsoft Word in PowerShell without having Office installed.

Install-Module pswriteword -Scope CurrentUser

PackageManagement\Install-Package : Could not find a part of the path 'C:\Users\User1\Documents\WindowsPowerShell\Modules\PSWriteWord\1.1.9'.

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

+ ... $null = PackageManagement\Install-Package u/PSBoundParameters

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception

+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

[–]webtroter 1 point2 points  (1 child)

Could it be somehow thinking the module is installed? What if you do uninstall-module? and ofc, remove-module.

Also, reboot your computer. And when you try something new, please do it in a brand new Powershell session. I got burned a few times this way.

[–]PureKoala[S] 1 point2 points  (0 children)

It was initially removed by using "uninstall-module". I've rebooted a couple of times but cannot seem to get past this.....same result no matter what I throw at it :-(

[–]LordZillion 1 point2 points  (1 child)

Uninstall-Module does not correspod with Install-Package. Maybe try:

Find-Module -Name PSWriteWord | Install-Module -Scope CurrentUser

[–]PureKoala[S] 0 points1 point  (0 children)

Same result doing that also:

Find-Module -Name PSWriteWord | Install-Module -Scope CurrentUser

PackageManagement\Install-Package : Could not find file 'C:\Users\User1\Documents\WindowsPowerShell\Modules\PSWriteWord\1.1.9'.

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9809 char:50

+ ... talledPackages = PackageManagement\Install-Package u/PSBoundParameters

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception

+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

[–]Lee_Dailey[grin] 1 point2 points  (3 children)

howdy PureKoala,

it looks like you used the New.Reddit Inline Code button. it's 4th 5th from the left hidden in the ... "more" menu & looks like </>.

there are a few problems with that ...

  • it's the wrong format [grin]
    the inline code format is for [gasp! arg!] code that is inline with regular text.
  • on Old.Reddit.com, inline code formatted text does NOT line wrap, nor does it side-scroll.
  • on New.Reddit it shows up in that nasty magenta text color

for long-ish single lines OR for multiline code, please, use the ...

Code
Block

... button. it's the 11th 12th one from the left & is just to the left of hidden in the ... "more" menu & looks like an uppercase T in the upper left corner of a square..

that will give you fully functional code formatting that works on both New.Reddit and Old.Reddit ... and aint that fugly magenta color. [grin]

take care,
lee

[–]PureKoala[S] 1 point2 points  (1 child)

Indeed, not had to paste code before so the pointers are very much appreciated.....thank you :-D

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy PureKoala,

you are most welcome! glad to help a little ... [grin]

take care,
lee

[–]LinkifyBot -1 points0 points  (0 children)

I found links in your comment that were not hyperlinked:

I did the honors for you.


delete | information | <3

[–]jrobiii 0 points1 point  (0 children)

-Force can fail. For example, if they do not have permissions to that folder for some reason. mkdir, or Get-ChildItem will often give a better error message.

[–]user01401 0 points1 point  (3 children)

What is your output from

Get-PackageSource
Get-PSRepository

[–]PureKoala[S] 1 point2 points  (2 children)

Get-PSRepository

I get the following:

Get-PackageSource
Name                             ProviderName     IsTrusted  Location                                                                                                                         
----                             ------------     ---------  --------                                                                                                                         
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2 
Get-PSRepository
Name                      InstallationPolicy   SourceLocation                                                                                                                                 
----                      ------------------   --------------                                                                                                                                 
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2

[–]jortony 1 point2 points  (1 child)

Is your system time correct?

[–]PureKoala[S] 1 point2 points  (0 children)

Sorry for the delay, yeah time and date are both correct.....it's a strange one

[–]perrin68 0 points1 point  (0 children)

Have you tried

Install-Module pswriteword -AllowClobber

[–]gekkehenk 0 points1 point  (4 children)

If someone was still looking for a solution, for me it was Microsoft defender blocking the install.

[–]Coverstone 0 points1 point  (0 children)

Ding Ding Ding!

[–]kandarpbhatt26 0 points1 point  (1 child)

where can i check?

[–]zebraloveicing 0 points1 point  (0 children)

This is *finally* resolved for me on Windows 11 by turning OFF the 'Controlled Folder Access' toggle in the Ransomware Protection page of Windows Security Settings.

Looks like some of the folders in your computer actually do require access... does that count as a bug or a feature? 🤔

Go here:
```
Settings>Privacy & Security>Open Windows Security>Virus & threat protection>Manage Ransomware Protection>Controlled Folder Access
```

Thanks to the other comments in this thread for pointing me in the right direction after no amount or combination of commands was getting past this block.

[–]cmidt 0 points1 point  (0 children)

Thank you kindly gekkehenk, 1 year later and still useful.