PowerShell cannot open shim file for read - powershell

I have installed scoop in my Windows PowerShell for ability to install some apps.
When I install app and then try to run it I get an error that there is no possibility to find shim file. 'C:\Windows\System32\apps\scoop\new' from my logs actually really doesn't exist. Maybe somebody had the same problem. I have found a clue that scoop could be out of date. I checked it and it really is but I cannot update it because i have still the same problem that it cannot read shim file.'scoop config rm SCOOP_REPO' also doesn't help. Any idea how to solve this problem?
PS C:\Windows\System32\apps\railway\current> scoop update
Updating Scoop...
Cannot open shim file for read.
Could not read shim file.
Remove-Item : Cannot find path 'C:\Windows\System32\apps\scoop\new' because it does not exist.
At C:\Windows\System32\apps\scoop\current\libexec\scoop-update.ps1:79 char:13
+ Remove-Item $newdir -Force -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Windows\System32\apps\scoop\new:String) [Remove-Item], ItemNotFoun
dException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Scoop download failed. If this appears several times, try removing SCOOP_REPO by 'scoop config rm SCOOP_REPO'

Related

Clojure installed, but clj fails

I installed Clojure via Powershell on Windows 10 and it installed without any errors. When I typed "clj" however, it gave me the following error:
clj : The 'clj' command was found in the module 'ClojureTools', but the module could not be loaded. For more
information, run 'Import-Module ClojureTools'.
At line:1 char:1
+ clj
+ ~~~
+ CategoryInfo : ObjectNotFound: (clj:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
I installed it to the following location: C:\Program Files\WindowsPowerShell\Modules
How can I resolve this error?
I think you need to do run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Because your system does not allow execution of downloaded scripts. Of course decision about how much this is secure for you is completely up to you.
I'd recommend to check this tutorial, written by me:
https://github.com/littleli/scoop-clojure/wiki/Getting-started
It provides alternative, and more convenient way to install Clojure. Also it provides easy path for updates and enables access to a growing amount of utilities that you may find helpful.
Finally. If you have access to Windows Subsystem for Linux (WSL2), I'd probably go in that direction.

Add-appxPackage deployment failed: does not find files

I am trying to deploy windows 10 app that I created to a laptop. In my computer everything goes fine, but in the laptop the Add-appPackage first recognizes the relevant package files, but when running the line in the script that makes the unbundle it fails and returns with:
' The system cannot find the file specified' eventhough the files exists.
I tried to make a deploy using the -register flag from working solution directory but the result was the same.
I use in my computer Windows 10 HOME and the Laptop is Windows 10 Pro but I think it does not matter.
The line in the script file generated by the visual studio packager which fails is:
Add-AppxPackage -Path $DeveloperPackagePath.FullName -DependencyPath $DependencyPackages.FullName -ForceApplicationShutdown
I checked the variables - they contain correct data.
Afterwards it outputs the error with the line:
$Error[0] # Dump details about the last error
that does not give me too much details about which file is missing as you can see in the full output:
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x86\Microsoft.NET.Native.Framework.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x86\Microsoft.NET.Native.Runtime.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x86\Microsoft.VCLibs.x86.14.00.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x64\Microsoft.NET.Native.Framework.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x64\Microsoft.NET.Native.Runtime.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x64\Microsoft.VCLibs.x64.14.00.appx
Add-AppxPackage : The system cannot find the file specified.
The system cannot find the file specified.
At C:\users\User\AlephBet_1.0.4.0_Test\Add-AppDevPackage.ps1:388 char:13
+ Add-AppxPackage -Path $DeveloperPackagePath.FullName -Dep ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AppxPackage], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Windows.Appx.PackageManager.Commands.A ddAppx
PackageCommand
I tried also getting information with get-AppxLog but it does log the error.
What happens? What is missing? Is there a way to get more information about the error?
Where does Windows 10 put the appx? Is there a way to make a bypass and take the files from an existing executable version, something like .exe files and copy them as is to the laptop?

PowerShell Copy-Item gives error in Octopus

I try to copy a DLL file from my computer to another and register it:
net use \\RemoteIp\C$\Dev 'pass'/USER:'user'
copy-item "D:\test.dll" -Destination "\\RemoteIp\c$\Dev";
regsvr32 "\\RemoteIp\C$\Dev\test.dll"
The problem that I have is that when I try to run this script from Octopus I receive this error :
Copy-Item : Cannot find path 'D:\test.dll' because it does
not exist.
At C:\Octopus\Work\20160606100457-74\Script.ps1:3 char:10
+ copy-item <<<< "D:\test.dll" -Destination "\RemoteIp\c$\Dev";
+ CategoryInfo : ObjectNotFound: (D:\test.dll
:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyI
temCommand
The remote script failed with exit code 1
If I try to run these lines of code in PowerShell it works properly.
Any suggestions ?
Thank you
Actually this was my fault. When you are running a script in Octopus that is meant to run on the Deployment target:
you have to define your local pc with the ip address. For example, in my case I had to write the address "D:\test.dll" like this : "\192.168.00.00\D$\test.dll" .
For the regsvr32 problem, I added a bat file on the server that runs the regsvr32 instruction and I just call that file and it does the rest.
Hopefully that helps others :)

All commands failing in powershell (4.0.) Even "c:" and "cd" and "dir"

I'm not sure when this started... whenever I open PowerShell, I can't execute even the most basic commands. I always get the following error message:
PS C:\> dir
dir : Cannot find drive. A drive with the name '.' does not exist.
At line:1 char:1
+ dir
+ ~~~
+ CategoryInfo : ObjectNotFound: (.:String) [], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound
---
This had been working fine but now all of a sudden I can't do anything. I've tried removing PowerShell 4 and re-installing... no change. Sorry for the formatting here... It looks organized in my view above but the preview text looks horrid.
I don't remember ever having java installed, but looking at my regular %path% I see that %java_home% is in there, but the value is never used or defined anywhere. Once I removed that from my path, the error above went away.
Strange that it would even be an issue for powershell. You'd think it would just skip past a non-existent directory in my path and move onto the next one when resolving a command.

How to import splitpipeline module from a shared server?

My script uses the Powershell splitpipeline module, to bring parallel process and queues features.
The script and the module are stored on shared server, like \server\c$ , the idea is be able to run it from any computer.
Tried to put at begining of the script import-module \\server\c$\SplitPipeline but I recieve the error:
import-module : Could not load file or assembly 'file://\\server\c$\SplitPipeline\SplitPipeline.dll' or one of its dependencies.
Operation is not supported. (Exception from HRESULT: 0x80131515)
At D:\scripts\powershell\OstReport_BETA-PIPE.ps1:6 char:1
+ import-module \\server\c$\SplitPipeline
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
If I try to copy it from the srv to the pc with:
Copy-Item -Path \\server\c$\SplitPipeline -Destination C:\windows\system32\WindowsPowerShell\v1.0\Modules -recurse -force
I get a access denied
any ideas¿?
thanks
The issue you're experiencing is that .NET assemblies can't be loaded from an untrusted UNC path, without special configuration. As you already discovered, the simplest solution is to copy the module to your local computer first.
To work around the "Access Denied" message, copy the module to your user directory, not the system-wide directory.
c:\users\<username>\Documents\WindowsPowerShell\Modules
You need to run PowerShell "as Administrator" in order to have permission to copy to the system folder, however it is generally recommended not to modify the default system directory. Instead, copy the module to your user folder (as above).