restricted--default settings, do not allow any script to run
allsigned--only script that has been signed with a digital certificate can be run
remotesigned--running local script does not require a digital signature, but running a script downloaded from the network must have a digital signature
unrestricted--allows all script to run
Windows does not allow any scripts to run by default, and you can use the "Set-executionpolicy" cmdlet to change your PowerShell environment. For example, you can use the following command to allow PowerShell to run under unlimited conditions:
Copy Code code as follows:
Set-executionpolicy Unrestricted
However, under Win7, you must start the command command line with administrator privileges, or you will report "Set-executionpolicy: to registry Entries" Hkey_local_machine\software\microsoft\powershell\1\ Access to Shellids\microsoft.powershell "was denied. Error
Using Java to invoke the PowerShell script, you can use the following command:
Copy Code code as follows:
String cmd = "cmd/c powershell-executionpolicy remotesigned-noprofile-noninteractive-file \" "+ Scriptfilename +" "";