如果在Win7中要想运行Powershell脚本或者Command,必须要用Set-ExecutionPolicy,一般来说开发用Bypass是比较合适的:
Set-ExecutionPolicy -ExcutionPolicy Bypass -Force
Syntax
Set-ExecutionPolicy [-ExecutionPolicy] {<Unrestricted> | <RemoteSigned> | <AllSigned> | <Restricted> | <Default> | <Bypass> | <Undefined>}
[[-Scope] {<Process> | <CurrentUser> | <LocalMachine> | <UserPolicy> | <MachinePolicy>}]
[-Force]
[-Confirm]
[-WhatIf] [<CommonParameters>]
Parameters
-ExecutionPolicy <ExecutionPolicy>
Specifies the new execution policy. Valid values are:
-- Restricted: Does not load configuration files or run scripts. "Restricted" is the default execution policy.
-- AllSigned: Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
-- RemoteSigned: Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
-- Unrestricted: Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
-- Bypass: Nothing is blocked and there are no warnings or prompts.
-- Undefined: Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.
-Scope <ExecutionPolicyScope>
Specifies the scope of the execution policy. The default is LocalMachine.
Valid values are:
-- Process: The execution policy affects only the current Windows PowerShell process.
-- CurrentUser: The execution policy affects only the current user.
-- LocalMachine: The execution policy affects all users of the computer.
-Force
Suppresses all prompts. By default, Set-ExecutionPolicy displays a warning whenever you change the execution policy.
-Confirm
Prompts you for confirmation before executing the command.
-WhatIf
Describes what would happen if you executed the command without actually executing the command.