I created a folder named Scripts in the c:\ drive, move my 2 scripts that were on my Desktop screen to this folder.
When I go to run any of the scripts the powershel screen opens and closes quickly and nothing is executed! On desktop they run normally. My PC user is administrator.
I saw instructions in the link below, but I preferred not to change the profile.ps1 file:
changing-execution-policy
Execution Policy command:
Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigne
What do I have to do for my scripts to run from any folder on my PC?
I don't have powershell profile
PS C:\WINDOWS\system32> Test-Path $profile
false
PS C:\WINDOWS\system32>
To try to work around the problem i created a .bat file to run the script.
see in:
how-to-run-a-powershell-script-from-a-batch-file
But the command shows the error:
Command in .bat file:
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile - ExecutionPolicy Bypass -File "%~dpn0.ps1'" -Verb RunAs}
Error message:
The string does not have the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
I changed the terminator '
in the command but I couldn't resolve the error! What is the correct syntax of the command?