Exemplo n.º 1
0
        private static void LoadModules(Runspace runspace)
        {
            ExecutionPolicy policy = runspace.GetEffectiveExecutionPolicy();
            if (policy != ExecutionPolicy.Unrestricted &&
                policy != ExecutionPolicy.RemoteSigned &&
                policy != ExecutionPolicy.Bypass)
            {

                ExecutionPolicy machinePolicy = runspace.GetExecutionPolicy(ExecutionPolicyScope.MachinePolicy);
                ExecutionPolicy userPolicy = runspace.GetExecutionPolicy(ExecutionPolicyScope.UserPolicy);

                if (machinePolicy == ExecutionPolicy.Undefined && userPolicy == ExecutionPolicy.Undefined)
                {
                    runspace.SetExecutionPolicy(ExecutionPolicy.RemoteSigned, ExecutionPolicyScope.Process);
                }
            }

            runspace.ImportModule(NuGetCoreModuleName);
#if DEBUG
            if (File.Exists(DebugConstants.TestModulePath))
            {
                runspace.ImportModule(DebugConstants.TestModulePath);
            }
#endif
        }
Exemplo n.º 2
0
 private static void LoadModules(Runspace runspace)
 {
     var policy = runspace.GetEffectiveExecutionPolicy();
     if (policy != ExecutionPolicy.Unrestricted && policy != ExecutionPolicy.RemoteSigned && policy != ExecutionPolicy.Bypass)
     {
         var machinePolicy = runspace.GetExecutionPolicy(ExecutionPolicyScope.MachinePolicy);
         var userPolicy = runspace.GetExecutionPolicy(ExecutionPolicyScope.UserPolicy);
         if (machinePolicy == ExecutionPolicy.Undefined && userPolicy == ExecutionPolicy.Undefined)
             runspace.SetExecutionPolicy(ExecutionPolicy.RemoteSigned, ExecutionPolicyScope.Process);
     }
     runspace.ImportModule(DagentCoreModuleName);
 }
Exemplo n.º 3
0
        private static void LoadStartupScripts(Runspace runspace)
        {
            ExecutionPolicy policy = runspace.GetEffectiveExecutionPolicy();
            if (policy != ExecutionPolicy.Unrestricted &&
                policy != ExecutionPolicy.RemoteSigned &&
                policy != ExecutionPolicy.Bypass) {

                ExecutionPolicy machinePolicy = runspace.GetExecutionPolicy(ExecutionPolicyScope.MachinePolicy);
                if (machinePolicy != ExecutionPolicy.Undefined) {
                    throw new InvalidOperationException(VsResources.Console_GroupPolicyError);
                }

                ExecutionPolicy userPolicy = runspace.GetExecutionPolicy(ExecutionPolicyScope.UserPolicy);
                if (userPolicy != ExecutionPolicy.Undefined) {
                    throw new InvalidOperationException(VsResources.Console_GroupPolicyError);
                }

                runspace.SetExecutionPolicy(ExecutionPolicy.RemoteSigned, ExecutionPolicyScope.Process);
            }

            runspace.ImportModule(NuGetCoreModuleName);

            #if DEBUG
            if (File.Exists(DebugConstants.TestModulePath)) {
                runspace.ImportModule(DebugConstants.TestModulePath);
            }
            #endif
        }