How to set the ExecutionPolicy using Powershell

To set the ExecutionPolicy using Powershell, run Powershell as Administrator.
Type in Set-ExecutionPolicy followed by the ExecutionPolicy you wish to use.

  • Restricted: Restricted is the default execution policy. PowerShell scripts are not allowed to run.
  • All Signed: All Signed means thath if they are signed by a trusted publisher.
  • Remote Signed: Remote Signed means, any PowerShell scripts that have been locally created will be allowed to run.
  • Unrestricted: As the name implies, Unrestricted removes all restrictions from the execution policy.
  • Microsoft has disabled scripting by default to prevent malicious code from being executed.

    How to measure execution time of a Action in C# and VB.NET

    To measure execution time of a Action in C# and VB.NET you can use the following Extension Method snippet.

    Sample C#

    public static TimeSpan Time(this Action @this)
    	var watch = Stopwatch.StartNew();
    	return watch.Elapsed;

    Sample VB.NET

    <System.Runtime.CompilerServices.Extension> _
    Public Shared Function Time(this As Action) As TimeSpan
    	Dim watch = Stopwatch.StartNew()
    	Return watch.Elapsed
    End Function