PowerShell のスクリプトを実行するには

PowerShell管理者として実行後、ExecutionPolicy を RemoteSigned にするとスクリプトを実行できます。

> Get-Content .\sample.ps1 #★サンプルコード
$strMsg = "Hello World !"
write-host $strMsg

> .\sample.ps1 #★エラーになります
File C:\Users\user01\Desktop\log\sample.ps1 cannot be loaded because the execution of scripts is disabled on this syste
m. Please see "get-help about_signing" for more details.
At line:1 char:13
+ .\sample.ps1 <<<<
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException

> Get-ExecutionPolicy
Restricted
> Set-ExecutionPolicy RemoteSigned #★ポリシーを "RemoteSigned" にします

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Yes
PS C:\Users\user01\Desktop\log> Get-ExecutionPolicy
RemoteSigned
> .\sample.ps1
Hello World ! #★実行できました
>

参考サイト
http://www.atmarkit.co.jp/fwin2k/win2ktips/1023ps1sec/ps1sec.html