Powershell cannot be loaded because running scripts is disabled on this system - windows

My question related to yarn. Before when I start create projects I installed with npm.
After a long time when I want to start running with yarn it shows the following error:
yarn : File C:\Users\pc\AppData\Roaming\npm\yarn.ps1 cannot be loaded because running scripts is disabled on this system.
(in Windows machine, Powershell)
Windows: 10
I tried with git bash terminal it worked!
but not in my powershell terminal

I have just fixed it by myself, anyway I am going to post answer here:
//open windows command Power shell as administrator and run command
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Set-ExecutionPolicy Unrestricted

Related

Package Manager Console prompt is messed up after installing oh-my-posh

I have oh-my-posh and posh-git installed and added to my Powershell profile, which looks like this
Import-Module posh-git
Import-Module oh-my-posh
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\thecyberden.omp.json" | Invoke-Expression
I'm using the CaskaydiaCove NF font in Powershell, which I also set as the font for the Package Manager Console.
My Windows Terminal prompt is correct:
However, the Package Manager Console in Visual Studio is weird, like it's not able to find the correct glyphs:
Is there a way to fix my Package Manager Console prompt so that either it displays correctly like Powershell, or so that it ignores the Powershell profile and just uses its default prompt?
This is because that shell doesn't support ANSI. Have a look at the PowerShell settings in case this is 7, otherwise there's no fix for it.

Microsoft Deployment Workbench chocolatey problem

I am currently testing Microsoft Deployment Workbench for automated Windows installation.
I have created a workflow with Windows 11 and would like to install the various programs via chocolatey after the Windows 11 installation.
Here you can see my workflow:
chocolatey is installed with a .bat script using:
command line: cmd.exe /c "%SCRIPTROOT%\BTNHD\chocoinstall.bat"
with the following content:
#powershell -noProfile -ExecutionPolicy unrestricted -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
then we restart the computer
then the script is started with the different programs, which looks like this:
command line: cmd.exe /c "%SCRIPTROOT%\BTNHD\installtemplate.bat"
with the following content:
choco install firefox --yes
choco install vlc --yes
Unfortunately it installs only the first software in the list at step 3, in my case Firefox and after that it takes a while and aborts with these error messages:
Now I have already tried the following things:
the reboot removed unfortunately no improvement
for each program a separate script and accordingly a separate installation step
tested other programs
changed the script
unfortunately there is nothing in the chocolatey log that can help me.
If I start the script manually, but everything works fine.
I currently do not know what to do and hope someone can help me, if there is any information missing, please let me know.
Thank you!

How to use Neo4j in command prompt without running as administrator

I am trying to use Neo4j 3.0.3 (zip file) command line tools in the command prompt on Windows 10. The problem is that it won't execute the files unless I run the command prompt as administrator. This is an issue for me because I can't run the command prompt as administrator on my machine I use for production. How can I run the Neo4j command prompt tools (neo4j-import.bat, etc.) without administrator mode? Is it possible?

Chocolatey setup on USB drive

I'm trying to set up Chocolatey for the first time. My ultimate goal is to be able to install the packages on a USB drive which shows up in my computer as F: so following the directions in the Chocolatey wiki, I created a folder on the F drive called Chocolatey and set an environmental variable ChocolateyInstall to F:/Chocolatey. I followed the basic directions, by opening up a command prompt and then pasting in the following.
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
After installation I went to the PowerShell command prompt as follows and tried to install Notepad++ I got the following:
C:\Windows\system32>cinst notepadplusplus
The filename, directory name, or volume label syntax is incorrect.
How can I fix this problem?
It appears that you went to a custom location with Chocolatey's install. When it finished the install, did it say it was installed on F:/chocolatey? Is it actually installed there? If so, take a look at your path environment variable and see if that is included in the path. Also close and reopen the shell/command line. Does it work now? If the path (user PATH) has the choco location in it and the shell/command line is not proper after reloading, then reboot and see if that fixes the issue.
If all of that is good, type just chocolatey /? and see what you get. Then try cinst again. If it has issues again, try cinst pkgname -debug and see where the error happens.
NOTE: Trying to install Chocolatey to a USB drive is not a supported case. Sure you might be able to get it to work but I'm not sure what you really gain. Say you install Notepad++, now it is installed to the system (not the USB drive). What do you gain by having the choco repository on the USB drive?

Powershell ExecutionPolicy is wrong when run through VisualStudio

I am trying to run a powershell script as part of my Pre-Build on a VS2005 project. I have run
$> powershell Set-ExecutionPolicy UnRestricted
from a command line before the build and I can run the same script from from the command line. However when the script is run as part of the Pre-Build step it fails with
The execution of scripts is disabled on this system.
Please see “get-help about_signing” for more details.
The script works on a co-worker's x32 XP machine, but not on my x64 Windows7 machine.
Did you set the execution policy in both the 64 and 32 bit Powershell environments? Your 64 bit machine will have both, and each has it's own executionpolicy setting.

Resources