Remove src\Microsoft.PowerShell.Activities (#4582)

This commit is contained in:
Dongbo Wang 2017-08-16 17:35:36 -07:00 committed by Aditya Patwardhan
parent 55fe5263e4
commit 580fb7baf5
26 changed files with 0 additions and 14211 deletions

View file

@ -1,795 +0,0 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
using System;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Reflection;
using Microsoft.CSharp;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Microsoft.PowerShell.Cmdletization;
using Microsoft.PowerShell.Cmdletization.Xml;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.CodeDom.Compiler;
using System.CodeDom;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Generates an activity that corresponds to a PowerShell command
/// </summary>
public static class ActivityGenerator
{
private static readonly Lazy<XmlSerializer> xmlSerializer = new Lazy<XmlSerializer>(ConstructXmlSerializer);
private static readonly Lazy<XmlReaderSettings> xmlReaderSettings = new Lazy<XmlReaderSettings>(ConstructXmlReaderSettings);
static XmlSerializer ConstructXmlSerializer()
{
XmlSerializer xmlSerializer = new Microsoft.PowerShell.Cmdletization.Xml.PowerShellMetadataSerializer();
return xmlSerializer;
}
static XmlReaderSettings ConstructXmlReaderSettings()
{
//
// XmlReaderSettings
//
XmlReaderSettings result = new XmlReaderSettings();
// general settings
result.CheckCharacters = true;
result.CloseInput = false;
result.ConformanceLevel = ConformanceLevel.Document;
result.IgnoreComments = true;
result.IgnoreProcessingInstructions = true;
result.IgnoreWhitespace = false;
result.MaxCharactersFromEntities = 16384; // generous guess for the upper bound
result.MaxCharactersInDocument = 128 * 1024 * 1024; // generous guess for the upper bound
result.DtdProcessing = DtdProcessing.Parse; // Allowing DTD parsing with limits of MaxCharactersFromEntities/MaxCharactersInDocument
result.XmlResolver = null; // do not fetch external documents
// xsd schema related settings
result.ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints |
XmlSchemaValidationFlags.ReportValidationWarnings;
result.ValidationType = ValidationType.Schema;
string cmdletizationXsd = ActivityResources.Xml_cmdletsOverObjectsXsd;
XmlReader cmdletizationSchemaReader = XmlReader.Create(new StringReader(cmdletizationXsd), result);
result.Schemas = new XmlSchemaSet();
result.Schemas.Add(null, cmdletizationSchemaReader);
result.Schemas.XmlResolver = null; // do not fetch external documents
return result;
}
static string templateCommand = @"
using Microsoft.PowerShell.Activities;
using System.Management.Automation;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace {0}
{{
/// <summary>
/// Activity to invoke the {1} command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode(""Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName"", ""3.0"")]
public sealed class {2} : {6}
{{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public {2}()
{{
this.DisplayName = ""{8}"";
}}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName {{ get {{ return ""{4}""; }} }}
// Arguments
{3}
// Module defining this command
{7}
// Optional custom code for this activity
{9}
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name=""context"">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
{5}
return new ActivityImplementationContext() {{ PowerShellInstance = invoker }};
}}
}}
}}";
const string templateParameter = @"
/// <summary>
/// Provides access to the {1} parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<{0}> {1} {{ get; set; }}";
const string templateParameterSetter = @"
if({0}.Expression != null)
{{
targetCommand.AddParameter(""{1}"", {0}.Get(context));
}}";
const string customRemotingMapping = @"
if(GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
{
targetCommand.AddParameter(""ComputerName"", PSComputerName.Get(context));
}";
const string supportsCustomRemoting = @"
/// <summary>
/// Declares that this activity supports its own remoting.
/// </summary>
protected override bool SupportsCustomRemoting { get { return true; } }";
/// <summary>
/// Generate an activity for the named command.
/// </summary>
/// <param name="command">The command name to generate.</param>
/// <param name="activityNamespace">The namespace that will contain the command - for example,
/// Microsoft.PowerShell.Activities.
/// </param>
/// <returns>A string representing the C# source code of the generated activity.</returns>
public static string GenerateFromName(string command, string activityNamespace)
{
return GenerateFromName(command, activityNamespace, false);
}
/// <summary>
/// Generate an activity for the named command.
/// </summary>
/// <param name="command">The command name to generate.</param>
/// <param name="activityNamespace">The namespace that will contain the command - for example,
/// Microsoft.PowerShell.Activities.
/// </param>
/// <param name="shouldRunLocally">True if remoting-related parameters should be suppressed. This
/// should only be specified for commands that offer no value when run on a remote computer.
/// </param>
/// <returns>A string representing the C# source code of the generated activity.</returns>
public static string GenerateFromName(string command, string activityNamespace, bool shouldRunLocally)
{
StringBuilder output = new StringBuilder();
// Get the command from the runspace
using (System.Management.Automation.PowerShell invoker = System.Management.Automation.PowerShell.Create())
{
invoker.AddCommand("Get-Command").AddParameter("Name", command);
Collection<CommandInfo> result = invoker.Invoke<CommandInfo>();
if (result.Count == 0)
{
string message = String.Format(CultureInfo.InvariantCulture, ActivityResources.ActivityNameNotFound, command);
throw new ArgumentException(message, "command");
}
foreach (CommandInfo commandToGenerate in result)
{
output.AppendLine(GenerateFromCommandInfo(commandToGenerate, activityNamespace, shouldRunLocally));
}
}
return output.ToString().Trim();
}
/// <summary>
/// By default, the activity wrapper uses the remoting command base.
/// </summary>
/// <param name="command">The command name to generate.</param>
/// <param name="activityNamespace">The namespace that will contain the command - for example,
/// Microsoft.PowerShell.Activities.
/// </param>
/// <returns></returns>
public static string GenerateFromCommandInfo(CommandInfo command, string activityNamespace)
{
return GenerateFromCommandInfo(command, activityNamespace, false);
}
/// <summary>
/// By default, the activity wrapper uses the remoting command base.
/// </summary>
/// <param name="command">The command name to generate.</param>
/// <param name="activityNamespace">The namespace that will contain the command - for example,
/// Microsoft.PowerShell.Activities.
/// </param>
/// <param name="shouldRunLocally">True if remoting-related parameters should be suppressed. This
/// should only be specified for commands that offer no value when run on a remote computer.
/// </param>
/// <returns></returns>
public static string GenerateFromCommandInfo(CommandInfo command, string activityNamespace, bool shouldRunLocally)
{
string activityBaseClass = "PSRemotingActivity";
if (shouldRunLocally || (command.RemotingCapability == RemotingCapability.None))
{
activityBaseClass = "PSActivity";
}
return GenerateFromCommandInfo(command, activityNamespace, activityBaseClass, null, null, String.Empty);
}
/// <summary>
/// Generate an activity for the given command.
/// </summary>
/// <param name="command">The command to use as the basis of the generated activity.</param>
/// <param name="activityNamespace">The namespace that will contain the command - for example,
/// Microsoft.PowerShell.Activities.
/// </param>
/// <param name="activityBaseClass">The class to use as the base class for this activity</param>
/// <param name="parametersToExclude">
/// A list of parameters on the command being wrapped that should not
/// be copied to the activity.
/// </param>
/// <param name="moduleToLoad"> The module that contains the wrapped command</param>
/// <param name="moduleDefinitionText">Addition text to inset in the class definition</param>
/// <returns>A string representing the C# source code of the generated activity.</returns>
public static string GenerateFromCommandInfo(
CommandInfo command,
string activityNamespace,
string activityBaseClass,
string[] parametersToExclude,
string moduleToLoad,
string moduleDefinitionText
)
{
if (command == null)
{
throw new ArgumentNullException("command");
}
if (String.IsNullOrEmpty(activityNamespace))
{
throw new ArgumentNullException("activityNamespace");
}
if (String.IsNullOrEmpty(activityBaseClass))
{
throw new ArgumentNullException("activityBaseClass");
}
StringBuilder parameterBlock = new StringBuilder();
StringBuilder parameterInitialization = new StringBuilder();
string commandName = command.Name;
commandName = commandName.Substring(0, 1).ToUpper(CultureInfo.CurrentCulture) + commandName.Substring(1);
string activityName = command.Name.Replace("-", "");
activityName = activityName.Substring(0, 1).ToUpper(CultureInfo.CurrentCulture) + activityName.Substring(1);
String displayName = commandName;
// Verify that the activity name doesn't conflict with anything in the inheritance hierarchy
Type testType = typeof(PSRemotingActivity);
while (testType != null)
{
if (String.Equals(testType.Name, activityName, StringComparison.OrdinalIgnoreCase))
{
string message = String.Format(CultureInfo.InvariantCulture, ActivityResources.ActivityNameConflict, activityName);
throw new ArgumentException(message, "command");
}
testType = testType.BaseType;
}
// The default list of parameters that need to be ignored.
List<string> ignoredParameters = new List<string>(Cmdlet.CommonParameters.Concat<string>(Cmdlet.OptionalCommonParameters));
// Add in any additional parameters the caller requested to ignore
if (parametersToExclude != null && parametersToExclude.Length > 0)
{
ignoredParameters.AddRange(parametersToExclude);
}
// If this activity supports its own remoting, ignore the ComputerName
// parameter (we will add special handling for that later)
if (command.RemotingCapability == RemotingCapability.SupportedByCommand)
{
ignoredParameters.Add("ComputerName");
}
// Avoid properties in parent classes.
List<string> parentProperties = new List<string>();
testType = typeof(PSRemotingActivity);
while (testType != typeof(PSActivity).BaseType)
{
parentProperties.AddRange(
from property in testType.GetProperties() select property.Name
);
testType = testType.BaseType;
}
foreach(KeyValuePair<string,ParameterMetadata> parameter in command.Parameters)
{
// Get the name (with capitalized first letter)
string name = parameter.Key;
name = name.Substring(0, 1).ToUpper(CultureInfo.CurrentCulture) + name.Substring(1);
// Ignore the common parameters
if(ignoredParameters.Contains(name, StringComparer.OrdinalIgnoreCase))
{
continue;
}
// Avoid parameters used by the parent activity, currently "Id" and
// "DisplayName". If the command has a noun, we name it:
// NounId and NounDisplayName - for example, ProcessId, and
// ServiceDisplayName.
string originalName = name;
if (parentProperties.Contains(name, StringComparer.OrdinalIgnoreCase))
{
if (commandName.Contains('-'))
{
string[] commandParts = commandName.Split('-');
string noun = commandParts[1];
noun = noun.Substring(0, 1).ToUpper(CultureInfo.CurrentCulture) + noun.Substring(1);
name = noun + name;
}
else
{
name = commandName + name;
}
}
// If the parameter name is the same as the command name, add "Activity"
// to the command name. Otherwise, we run afoul of the error:
// "Member names cannot be the same as their enclosing type".
if (String.Equals(name, activityName, StringComparison.OrdinalIgnoreCase))
{
activityName += "Activity";
}
// And the type
string type = parameter.Value.ParameterType.ToString();
// Fix generic types
if(type.Contains('`'))
{
type = System.Text.RegularExpressions.Regex.Replace(type, "`[\\d]+", "");
type = System.Text.RegularExpressions.Regex.Replace(type, "\\[", "<");
type = System.Text.RegularExpressions.Regex.Replace(type, "\\]", ">");
}
// Fix nested classes...
if (type.Contains('+'))
{
type = System.Text.RegularExpressions.Regex.Replace(type, "\\+", ".");
}
// Append the parameter ( InArgument<type> Name { get; set } ... )
parameterBlock.AppendLine(
String.Format(CultureInfo.InvariantCulture,
templateParameter,
type,
name));
// Append the parameter initializer (... Parameters.Add(...) )
// This may have to be mapped from name to originalName when the
// parameter has a conflict with the parent activity.
parameterInitialization.AppendLine(
String.Format(CultureInfo.InvariantCulture,
templateParameterSetter,
name,
originalName));
}
// Append the remoting support to parameter initialization
if (command.RemotingCapability == RemotingCapability.SupportedByCommand)
{
parameterBlock.AppendLine(supportsCustomRemoting);
parameterInitialization.AppendLine(customRemotingMapping);
}
// If no module definition string has been included then add the defining module
// to the list of modules and make use a module-qualified name
string psDefiningModule = "";
if (string.IsNullOrEmpty(moduleDefinitionText))
{
// Prefer the module to load that was passed in over the module that
// eventually defined the cmdlet...
if (!string.IsNullOrEmpty(moduleToLoad))
{
commandName = moduleToLoad + "\\" + commandName;
}
else if (!String.IsNullOrEmpty(command.ModuleName))
{
commandName = command.ModuleName + "\\" + commandName;
}
if (!String.IsNullOrEmpty(moduleToLoad))
{
psDefiningModule = " /// <summary>\n/// Script module contents for this activity`n/// </summary>\n" +
@"protected override string PSDefiningModule { get { return """ + moduleToLoad + @"""; } }";
}
}
return String.Format(CultureInfo.InvariantCulture,
templateCommand,
activityNamespace,
commandName,
activityName,
parameterBlock.ToString(),
commandName.Replace("\\", "\\\\"),
parameterInitialization.ToString(),
activityBaseClass,
psDefiningModule,
displayName,
moduleDefinitionText);
}
/// <summary>
/// Generates a complete activity source file from a module.
/// </summary>
/// <param name="moduleToProcess"></param>
/// <param name="activityNamespace">The namespace to use for the target classes</param>
/// <returns>An array of code elements to compile into an assembly</returns>
static public string[] GenerateFromModuleInfo(PSModuleInfo moduleToProcess, string activityNamespace)
{
if (moduleToProcess == null)
throw new ArgumentNullException("moduleToProcess");
List<string> codeToCompile = new List<string>();
// Cmdlets and function need to exist in separate namespaces...
if (moduleToProcess.ExportedCmdlets != null)
{
string namespaceToUse = ! string.IsNullOrEmpty(activityNamespace) ? activityNamespace : moduleToProcess.Name + "_Cmdlet_Activities";
foreach (CmdletInfo ci in moduleToProcess.ExportedCmdlets.Values)
{
string code = Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromCommandInfo(ci, namespaceToUse, "PSRemotingActivity", null, null, "");
codeToCompile.Add(code);
}
}
Dictionary<string, string> modules = new Dictionary<string, string>();
PSModuleInfo cimModule = moduleToProcess;
if (moduleToProcess.ExportedFunctions != null)
{
string namespaceToUse = !string.IsNullOrEmpty(activityNamespace) ? activityNamespace : moduleToProcess.Name + "_Function_Activities";
foreach (FunctionInfo fi in moduleToProcess.ExportedFunctions.Values)
{
string moduleName = null;
string moduleDefinition = null;
// Save the module defining this function - we may need to extract
// embedded types further on
if (fi.ScriptBlock.Module != null && !string.IsNullOrEmpty(fi.ScriptBlock.Module.Definition))
{
moduleName = fi.ScriptBlock.Module.Name;
moduleDefinition = fi.ScriptBlock.Module.Definition;
}
string code;
if (fi.ScriptBlock.Module.ModuleType == ModuleType.Cim)
{
// Special-case CIM activities
string embeddedDefinition = "";
// Embed the module definition in the activity...
if (moduleDefinition != null)
{
// Remove all of the calls to Export-ModuleMember and getcommand
string editedDefinition = System.Text.RegularExpressions.Regex.Replace(moduleDefinition, @"Microsoft.PowerShell.Core\\Export-ModuleMember[^\n]*\n", "");
editedDefinition = System.Text.RegularExpressions.Regex.Replace(editedDefinition,
@"if \(\$\(Microsoft.PowerShell.Core\\Get-Command Set-StrictMode[^\n]*\n", "");
embeddedDefinition = "protected override string ModuleDefinition { get { return _moduleDefinition; } }\r\n const string _moduleDefinition = @\""
+ editedDefinition.Replace("\"", "\"\"") + "\";";
}
code = Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromCommandInfo(
fi, namespaceToUse, "PSGeneratedCIMActivity", new string[] { "Computer", "AsJob", "CimSession" }, null, embeddedDefinition);
cimModule = fi.ScriptBlock.Module;
}
else
{
code = Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromCommandInfo(
fi, namespaceToUse, "PSRemotingActivity", new string[] { "Computer", "AsJob" }, moduleToProcess.Name, "");
}
codeToCompile.Add(code);
if (moduleName != null && !modules.ContainsKey(fi.ScriptBlock.Module.Name))
{
modules.Add(moduleName, moduleDefinition);
}
}
}
string fileName = cimModule.Path;
// See if there are any embedded types to extract
if (Path.GetExtension(fileName).Equals(".cdxml", StringComparison.OrdinalIgnoreCase))
{
// generate cmdletization proxies
using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
XmlReader xmlReader = XmlReader.Create(file, xmlReaderSettings.Value);
PowerShellMetadata cmdletizationMetadata = (PowerShellMetadata)xmlSerializer.Value.Deserialize(xmlReader);
if (cmdletizationMetadata != null && cmdletizationMetadata.Enums != null)
{
foreach (EnumMetadataEnum enumMetadata in cmdletizationMetadata.Enums)
{
codeToCompile.Add(GetCSharpCode(enumMetadata));
}
}
}
}
return codeToCompile.ToArray<string>();
}
internal static string GetCSharpCode(EnumMetadataEnum enumMetadata)
{
var codeCompileUnit = CreateCodeCompileUnit(enumMetadata);
var stringWriter = new StringWriter(CultureInfo.InvariantCulture);
CodeDomProvider.CreateProvider("C#").GenerateCodeFromCompileUnit(
codeCompileUnit,
stringWriter,
new CodeGeneratorOptions());
return stringWriter.ToString();
}
private const string namespacePrefix = "Microsoft.PowerShell.Cmdletization.GeneratedTypes";
private static CodeCompileUnit CreateCodeCompileUnit(EnumMetadataEnum enumMetadata)
{
var codeDomProvider = CodeDomProvider.CreateProvider("C#");
string subnamespaceText = string.Empty;
string enumNameText;
int indexOfLastDot = enumMetadata.EnumName.LastIndexOf('.');
if (indexOfLastDot < 0)
{
enumNameText = enumMetadata.EnumName;
}
else
{
subnamespaceText = "." + enumMetadata.EnumName.Substring(0, indexOfLastDot);
enumNameText = enumMetadata.EnumName.Substring(
indexOfLastDot + 1, enumMetadata.EnumName.Length - indexOfLastDot - 1);
}
// defense in depth (in case xsd is allowing some invalid identifiers)
// + xsd allows reserved keywords (i.e. "namespace" passes the regex test, but is not a valid identifier)
if (!codeDomProvider.IsValidIdentifier(enumNameText))
{
var errorMessage = string.Format(
CultureInfo.InvariantCulture,
ActivityResources.EnumWriter_InvalidEnumName,
enumMetadata.EnumName);
throw new XmlException(errorMessage);
}
var newEnum = new CodeTypeDeclaration(codeDomProvider.CreateValidIdentifier(enumNameText)) { IsEnum = true, Attributes = MemberAttributes.Public };
if (enumMetadata.BitwiseFlagsSpecified && enumMetadata.BitwiseFlags)
{
newEnum.CustomAttributes.Add(
new CodeAttributeDeclaration(new CodeTypeReference(typeof(FlagsAttribute))));
}
Type underlyingType = null;
if (enumMetadata.UnderlyingType != null)
{
underlyingType = Type.GetType(enumMetadata.UnderlyingType, false, true);
if (underlyingType != null)
{
newEnum.BaseTypes.Add(underlyingType);
}
else
{
underlyingType = typeof(Int32);
}
}
else
{
underlyingType = typeof(Int32);
}
foreach (var value in enumMetadata.Value)
{
// defense in depth (in case xsd is allowing some invalid identifiers)
// + xsd allows reserved keywords (i.e. "namespace" passes the regex test, but is not a valid identifier)
if (!codeDomProvider.IsValidIdentifier(value.Name)) // defense in depth (in case xsd is allowing some invalid identifiers)
{
var errorMessage = string.Format(
CultureInfo.InvariantCulture,
ActivityResources.EnumWriter_InvalidValueName,
value.Name);
throw new XmlException(errorMessage);
}
var nameValuePair = new CodeMemberField(underlyingType, codeDomProvider.CreateValidIdentifier(value.Name));
object integerValue = LanguagePrimitives.ConvertTo(
value.Value, underlyingType, CultureInfo.InvariantCulture);
nameValuePair.InitExpression = new CodePrimitiveExpression(integerValue);
newEnum.Members.Add(nameValuePair);
}
var topLevelNamespace = new CodeNamespace(namespacePrefix + subnamespaceText);
topLevelNamespace.Types.Add(newEnum);
var codeCompileUnit = new CodeCompileUnit();
codeCompileUnit.Namespaces.Add(topLevelNamespace);
codeCompileUnit.ReferencedAssemblies.Add("System.dll");
return codeCompileUnit;
}
/// <summary>
///
/// </summary>
/// <param name="moduleToProcess"></param>
/// <param name="activityNamespace"></param>
/// <param name="outputAssemblyPath"></param>
/// <param name="referenceAssemblies"></param>
/// <param name="errors"></param>
/// <returns></returns>
public static Assembly GenerateAssemblyFromModuleInfo(
PSModuleInfo moduleToProcess,
string activityNamespace,
string outputAssemblyPath,
string[] referenceAssemblies,
out string errors
)
{
string[] src = GenerateFromModuleInfo(moduleToProcess, activityNamespace);
bool toAssembly = ! string.IsNullOrEmpty(outputAssemblyPath);
return CompileStrings(src, referenceAssemblies, toAssembly, outputAssemblyPath, out errors);
}
private static Assembly CompileStrings(
string[] src,
string[] referenceAssemblies,
bool toAssembly,
string outputAssemblyPath,
out string errors
)
{
var cpar = new System.CodeDom.Compiler.CompilerParameters()
{
GenerateInMemory = ! toAssembly,
OutputAssembly = outputAssemblyPath,
};
// Add default references...
cpar.ReferencedAssemblies.Add(typeof(System.Activities.Activity).Assembly.Location);
cpar.ReferencedAssemblies.Add(typeof(System.CodeDom.Compiler.CodeCompiler).Assembly.Location);
cpar.ReferencedAssemblies.Add(typeof(PSObject).Assembly.Location);
cpar.ReferencedAssemblies.Add(typeof(Microsoft.PowerShell.Activities.PSActivity).Assembly.Location);
cpar.ReferencedAssemblies.Add(ResolveReferencedAssembly("Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
cpar.ReferencedAssemblies.Add(ResolveReferencedAssembly("Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
// Add user supplied references...
if (referenceAssemblies != null)
{
foreach (string asm in referenceAssemblies)
{
cpar.ReferencedAssemblies.Add(ResolveReferencedAssembly(asm));
}
}
var compiler = new Microsoft.CSharp.CSharpCodeProvider();
var cr = compiler.CompileAssemblyFromSource(cpar, src);
if (cr.Errors == null || cr.Errors.Count == 0)
{
errors = string.Empty;
}
else
{
StringBuilder errorBuilder = new StringBuilder();
foreach (var err in cr.Errors)
{
errorBuilder.Append(err.ToString());
errorBuilder.Append('\n');
}
errors = errorBuilder.ToString();
}
if (errors.Length > 0)
{
return null;
}
// If the assembly was written to disk, return null
// since we don't want to load the assembly we've just created.
if (toAssembly)
{
return null;
}
else
{
return cr.CompiledAssembly;
}
}
[SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadWithPartialName")]
[SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom")]
private static string ResolveReferencedAssembly(string assembly)
{
Assembly asm = null;
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
if (System.IO.Path.IsPathRooted(assembly))
{
return assembly;
}
if (assembly.Contains(','))
{
try
{
asm = Assembly.Load(assembly);
return asm.Location;
}
catch (Exception)
{
;
}
}
if (asm == null)
{
try
{
#pragma warning disable 0618
asm = Assembly.LoadWithPartialName(assembly);
return asm.Location;
}
catch (Exception)
{
;
}
}
if (asm == null)
{
throw new InvalidOperationException(assembly);
}
return null;
}
}
}

View file

@ -1,135 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\Get-CimAssociatedInstance command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class GetCimAssociatedInstance : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public GetCimAssociatedInstance()
{
this.DisplayName = "Get-CimAssociatedInstance";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\Get-CimAssociatedInstance"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.GetCimAssociatedInstanceCommand); } }
// Arguments
/// <summary>
/// Provides access to the Association parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Association { get; set; }
/// <summary>
/// Provides access to the ResultClassName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> ResultClassName { get; set; }
/// <summary>
/// Provides access to the InputObject parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimInstance> InputObject { get; set; }
/// <summary>
/// Provides access to the Namespace parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Namespace { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Provides access to the KeyOnly parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> KeyOnly { get; set; }
/// <summary>
/// No module needed for this activity
/// </summary>
protected override string PSDefiningModule { get { return null; } }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(Association.Expression != null)
{
targetCommand.AddParameter("Association", Association.Get(context));
}
if (ResultClassName.Expression != null)
{
targetCommand.AddParameter("ResultClassName", ResultClassName.Get(context));
}
if (InputObject.Expression != null)
{
targetCommand.AddParameter("InputObject", InputObject.Get(context));
}
if(Namespace.Expression != null)
{
targetCommand.AddParameter("Namespace", Namespace.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if(KeyOnly.Expression != null)
{
targetCommand.AddParameter("KeyOnly", KeyOnly.Get(context));
}
if (ResourceUri != null)
{
targetCommand.AddParameter("ResourceUri", ResourceUri.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,131 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\Get-CimClass command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class GetCimClass : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public GetCimClass()
{
this.DisplayName = "Get-CimClass";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\Get-CimClass"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.GetCimClassCommand); } }
// Arguments
/// <summary>
/// Provides access to the ClassName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> ClassName { get; set; }
/// <summary>
/// Provides access to the Namespace parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Namespace { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Provides access to the MethodName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> MethodName { get; set; }
/// <summary>
/// Provides access to the PropertyName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> PropertyName { get; set; }
/// <summary>
/// Provides access to the QualifierName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> QualifierName { get; set; }
/// <summary>
/// No module needed for this activity
/// </summary>
protected override string PSDefiningModule { get { return null; } }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
// Specified ClassName cannot be WhiteSpace or NULL
//
if (ClassName.Expression != null && !string.IsNullOrWhiteSpace(ClassName.Get(context)))
{
targetCommand.AddParameter("ClassName", ClassName.Get(context));
}
if(Namespace.Expression != null)
{
targetCommand.AddParameter("Namespace", Namespace.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if(MethodName.Expression != null)
{
targetCommand.AddParameter("MethodName", MethodName.Get(context));
}
if(PropertyName.Expression != null)
{
targetCommand.AddParameter("PropertyName", PropertyName.Get(context));
}
if(QualifierName.Expression != null)
{
targetCommand.AddParameter("QualifierName", QualifierName.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,177 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\Get-CimInstance command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class GetCimInstance : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public GetCimInstance()
{
this.DisplayName = "Get-CimInstance";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\Get-CimInstance"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand); } }
// Arguments
/// <summary>
/// Provides access to the ClassName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> ClassName { get; set; }
/// <summary>
/// Provides access to the Filter parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Filter { get; set; }
/// <summary>
/// Provides access to the KeyOnly parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> KeyOnly { get; set; }
/// <summary>
/// Provides access to the Namespace parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Namespace { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Provides access to the InputObject parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimInstance> InputObject { get; set; }
/// <summary>
/// Provides access to the Query parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Query { get; set; }
/// <summary>
/// Provides access to the QueryDialect parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> QueryDialect { get; set; }
/// <summary>
/// Provides access to the Shallow parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> Shallow { get; set; }
/// <summary>
/// Provides access to the Property parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String[]> Property { get; set; }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(ClassName.Expression != null)
{
targetCommand.AddParameter("ClassName", ClassName.Get(context));
}
if (Filter.Expression != null)
{
targetCommand.AddParameter("Filter", Filter.Get(context));
}
if(KeyOnly.Expression != null)
{
targetCommand.AddParameter("KeyOnly", KeyOnly.Get(context));
}
if(Namespace.Expression != null)
{
targetCommand.AddParameter("Namespace", Namespace.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if (InputObject.Expression != null)
{
targetCommand.AddParameter("InputObject", InputObject.Get(context));
}
if(Query.Expression != null)
{
targetCommand.AddParameter("Query", Query.Get(context));
}
if(QueryDialect.Expression != null)
{
targetCommand.AddParameter("QueryDialect", QueryDialect.Get(context));
}
if(Shallow.Expression != null)
{
targetCommand.AddParameter("Shallow", Shallow.Get(context));
}
if (Property.Expression != null)
{
targetCommand.AddParameter("Property", Property.Get(context));
}
if (ResourceUri != null)
{
targetCommand.AddParameter("ResourceUri", ResourceUri.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,338 +0,0 @@
using System;
using System.Activities;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Management.Automation;
using System.Management.Automation.Tracing;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
///
/// </summary>
public enum PSWorkflowRuntimeVariable
{
// Command Parameters
/// <summary>
///
/// </summary>
PSComputerName = 0,
/// <summary>
///
/// </summary>
PSCredential = 1,
/// <summary>
///
/// </summary>
PSPort = 2,
/// <summary>
///
/// </summary>
PSUseSsl = 3,
/// <summary>
///
/// </summary>
PSConfigurationName = 4,
/// <summary>
///
/// </summary>
PSApplicationName = 5,
/// <summary>
///
/// </summary>
PSConnectionUri = 6,
/// <summary>
///
/// </summary>
PSAllowRedirection = 7,
/// <summary>
///
/// </summary>
PSSessionOption = 8,
/// <summary>
///
/// </summary>
PSAuthentication = 9,
/// <summary>
///
/// </summary>
PSAuthenticationLevel = 10,
/// <summary>
///
/// </summary>
PSCertificateThumbprint = 11,
/// <summary>
///
/// </summary>
Input = 13,
/// <summary>
///
/// </summary>
Verbose = 15,
// Retry policy constants
/// <summary>
///
/// </summary>
PSConnectionRetryCount = 19,
/// <summary>
///
/// </summary>
PSConnectionRetryIntervalSec = 21,
/// <summary>
///
/// </summary>
PSPrivateMetadata = 24,
// Timers
/// <summary>
///
/// </summary>
PSRunningTimeoutSec = 27,
/// <summary>
///
/// </summary>
PSElapsedTimeoutSec = 28,
/// <summary>
///
/// </summary>
PSWorkflowRoot = 31,
/// <summary>
///
/// </summary>
JobName = 32,
/// <summary>
///
/// </summary>
JobInstanceId = 33,
/// <summary>
///
/// </summary>
JobId = 34,
/// <summary>
///
/// </summary>
JobCommandName = 36,
/// <summary>
///
/// </summary>
ParentJobInstanceId = 40,
/// <summary>
///
/// </summary>
ParentJobName = 41,
/// <summary>
///
/// </summary>
ParentJobId = 42,
/// <summary>
///
/// </summary>
ParentCommandName = 43,
/// <summary>
///
/// </summary>
WorkflowInstanceId = 48,
/// <summary>
///
/// </summary>
PSSenderInfo = 49,
/// <summary>
///
/// </summary>
PSCulture = 50,
/// <summary>
///
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
PSUICulture = 51,
/// <summary>
///
/// </summary>
PSVersionTable = 52,
/// <summary>
/// PSPersist
/// </summary>
PSPersist = 53,
/// <summary>
/// ErrorAction
/// </summary>
ErrorAction = 54,
/// <summary>
/// WarningAction
/// </summary>
WarningAction = 55,
/// <summary>
/// InformationAction
/// </summary>
InformationAction = 56,
/// <summary>
/// Tell the activity to look for a custom string
/// </summary>
Other = 1000,
/// <summary>
/// Return all values as a hashtable
/// </summary>
All = 1001,
}
/// <summary>
/// Activity to retrieve the value of a workflow runtime variable.
/// </summary>
public sealed class GetPSWorkflowData<T> : NativeActivity<T>
{
/// <summary>
/// The variable to retrieve.
/// </summary>
[RequiredArgument]
public PSWorkflowRuntimeVariable VariableToRetrieve
{
get;
set;
}
/// <summary>
/// The variable to retrieve, if not included in the PSWorkflowRuntimeVariable enum.
/// </summary>
[DefaultValue(null)]
public InArgument<string> OtherVariableName
{
get;
set;
}
/// <summary>
/// Execute the logic for this activity...
/// </summary>
/// <param name="context"></param>
protected override void Execute(NativeActivityContext context)
{
// Retrieve our host overrides
HostParameterDefaults hostValues = context.GetExtension<HostParameterDefaults>();
PropertyDescriptorCollection col = context.DataContext.GetProperties();
string variableName = null;
if (VariableToRetrieve != PSWorkflowRuntimeVariable.Other)
{
// Get the symbolic name for the enum
variableName = LanguagePrimitives.ConvertTo<string>(VariableToRetrieve);
}
else
{
if (OtherVariableName.Expression != null)
{
string value = OtherVariableName.Get(context);
if (!string.IsNullOrWhiteSpace(value))
{
variableName = value;
}
}
}
//BUGBUG need a better exception here, could also do this as a custom validator
// Make sure we have a variable here...
if (string.IsNullOrWhiteSpace(variableName))
{
throw new InvalidOperationException("OtherVariable");
}
object valueToReturn = null;
PSDataCollection<PSObject> outputStream = null;
foreach (System.ComponentModel.PropertyDescriptor property in context.DataContext.GetProperties())
{
if (string.Equals(property.Name, "ParameterDefaults", StringComparison.OrdinalIgnoreCase))
{
foreach (var parameter in ((Microsoft.PowerShell.Activities.HostParameterDefaults)property.GetValue(context.DataContext)).Parameters)
{
if (parameter.Key.Equals(variableName, StringComparison.OrdinalIgnoreCase))
{
valueToReturn = parameter.Value;
}
else if (parameter.Key.Equals("Result"))
{
outputStream = parameter.Value as PSDataCollection<PSObject>;
}
}
//
// If the property to return was all, then just return the entire collection as a hashtable.
// (We still needed to loop to find the output stream to write into.)
//
if (VariableToRetrieve == PSWorkflowRuntimeVariable.All)
{
System.Collections.Hashtable workflowRuntimeVariables = new System.Collections.Hashtable(StringComparer.OrdinalIgnoreCase);
string[] enumNames = VariableToRetrieve.GetType().GetEnumNames();
// Skipping last two enum names, Other and All, as they are not actual variable names
//
for (int i=0; i < (enumNames.Length - 2); i++)
{
workflowRuntimeVariables.Add(enumNames[i], null);
}
Dictionary<String, Object> dictionaryParam = ((Microsoft.PowerShell.Activities.HostParameterDefaults)property.GetValue(context.DataContext)).Parameters;
foreach(string varKey in dictionaryParam.Keys)
{
// We need to get the values of required runtime variables only, not everything from DataContext parameters
//
if (workflowRuntimeVariables.ContainsKey(varKey))
{
Object value = null;
dictionaryParam.TryGetValue(varKey, out value);
workflowRuntimeVariables[varKey] = value;
}
}
valueToReturn = workflowRuntimeVariables;
}
break;
}
}
if (this.Result.Expression != null)
{
this.Result.Set(context, valueToReturn);
}
else if (outputStream != null)
{
if (valueToReturn != null)
{
outputStream.Add(PSObject.AsPSObject(valueToReturn));
}
}
else
{
//BUGBUG need a better exception here...
throw new InvalidOperationException("Result");
}
}
}
}

View file

@ -1,812 +0,0 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
using System;
using System.Activities;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Language;
using System.ComponentModel;
using System.Text;
using System.Reflection;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to support the invocation of PowerShell script content in a Workflow.
/// </summary>
#if _NOTARMBUILD_
[Designer(typeof(InlineScriptDesigner))]
#endif
public sealed class InlineScript : PSRemotingActivity
{
/// <summary>
/// The script text to invoke.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public string Command
{
get { return _command; }
set
{
_command = value;
_commandSpecified = true;
}
}
private string _command;
private bool _commandSpecified;
/// <summary>
/// Name of the command to invoke
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<string> CommandName { get; set; }
/// <summary>
/// Parameters to invoke the command with.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Collections.Hashtable> Parameters { get; set; }
/// <summary>
/// Declares that this activity supports its own remoting.
/// </summary>
protected override bool SupportsCustomRemoting { get { return true; } }
private ScriptBlock _compiledScriptForInProc;
private ScriptBlock _compiledScriptForOutProc;
private string _scriptWithoutUsing;
private HashSet<string> _usingVariables;
// Remember the names of the variables/arguments that statically exist in the
// workflow context and potentially can be referenced by a using variable in
// an InlineScript. Those static variables/arguments include:
// 1. the default arguments of InlineScript and its parents
// 2. the workflow runtime variables
//
// This static set is used to decide whether to add the special prefix
// to a variable or not, when replacing a using variable.
private static readonly HashSet<string> StaticPotentialUsingVariableSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
private const string VariablePrefix = "__PSUsingVariable_";
static InlineScript()
{
PopulatePotentialUsingVariableStaticSet();
}
private static void PopulatePotentialUsingVariableStaticSet()
{
var namesToExclude = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
// from inlinescript common arguments
"Result", "PSError", "PSWarning", "PSVerbose", "PSDebug", "PSProgress", "PSInformation",
// from workflow runtime variables
"Other", "All",
// some workflow variables/arguments conflict with the built-in powershell variables, including:
// Input, PSSessionOption, PSCulture, PSUICulture, PSVersionTable
//
// per discussion with Hemant and Rahim, we want to:
// 1. treat $using:input, $using:PSSessionOption, $using:PSCulture, and $using:PSUICulture as workflow
// variable; add the special prefix when replacing 'using'.
// 2. treat PSVersionTable as powershell variable, so never add special prefix to it.
"PSVersionTable"
};
// Handle InlineScript activity common arguments
foreach (string argumentName in GetInlineScriptActivityArguments())
{
if (namesToExclude.Contains(argumentName)) { continue; }
if (!StaticPotentialUsingVariableSet.Contains(argumentName))
{
StaticPotentialUsingVariableSet.Add(argumentName);
}
}
// Handle workflow runtime variables
var wfRuntimeVariables = typeof(PSWorkflowRuntimeVariable).GetEnumNames();
foreach (string variableName in wfRuntimeVariables)
{
if (namesToExclude.Contains(variableName)) { continue; }
if (!StaticPotentialUsingVariableSet.Contains(variableName))
{
StaticPotentialUsingVariableSet.Add(variableName);
}
}
}
// Use the same logic as the PSActivity.GetActivityArguments to retrieve the names of all default
// arguments from the InlineScript and its parents
internal static IEnumerable<string> GetInlineScriptActivityArguments()
{
Type activityType = typeof(InlineScript);
while (activityType != null)
{
// We don't want to support parameter defaults for arguments on
// concrete types (as they almost guaranteed to collide with other types),
// but base classes make sense.
if (activityType.IsAbstract)
{
// Populate any parameter defaults. We only look at fields that are defined on this
// specific type (as opposed to derived types) so that we don't make assumptions about
// other activities and their defaults.
foreach (PropertyInfo field in activityType.GetProperties())
{
// See if it's an argument
if (typeof(Argument).IsAssignableFrom(field.PropertyType))
{
// Get the argument name
yield return field.Name;
}
}
}
// Go to our base type, but stop when we go above PSActivity
activityType = activityType.BaseType;
if (!typeof(PSActivity).IsAssignableFrom(activityType))
activityType = null;
}
}
/// <summary>
/// Validates the contents of the script block for this command.
/// </summary>
/// <param name="metadata">Metadata for this activity</param>
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
base.CacheMetadata(metadata);
if (! string.IsNullOrWhiteSpace(Command))
{
Token[] tokens;
ParseError[] errors;
Parser.ParseInput(Command, out tokens, out errors);
if (errors != null && errors.Length > 0)
{
string compositeErrorString = "";
foreach (var e in errors)
{
// Format and add each error message...
compositeErrorString += string.Format(CultureInfo.InvariantCulture,
"[{0}, {1}]: {2}\n", e.Extent.StartLineNumber, e.Extent.StartColumnNumber, e.Message);
}
metadata.AddValidationError(compositeErrorString);
}
}
}
/// <summary>
/// Indicates if preference variables need to be updated
/// </summary>
protected override bool UpdatePreferenceVariable
{
get { return false; }
}
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the script to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Reliability",
"CA2000:Dispose objects before losing scope",
Justification = "Disposed by the infrastructure.")]
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
ValidateParameters();
System.Management.Automation.PowerShell invoker = null;
HashSet<string> allWorkflowVarNames = new HashSet<string>(StaticPotentialUsingVariableSet, StringComparer.OrdinalIgnoreCase);
Dictionary<string, object> defaults = this.ParameterDefaults.Get(context);
Dictionary<string, object> activityVariables = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, object> activityUsingVariables = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
string[] streams =
{
"Result", "PSError", "PSWarning", "PSVerbose", "PSDebug", "PSProgress", "PSInformation"
};
// First, set the variables from the user's variables
foreach (System.ComponentModel.PropertyDescriptor property in context.DataContext.GetProperties())
{
if (String.Equals(property.Name, "ParameterDefaults", StringComparison.OrdinalIgnoreCase))
continue;
// Add all user-defined variables/parameters in the same scope of the InlineScript activity
if (!allWorkflowVarNames.Contains(property.Name))
{
allWorkflowVarNames.Add(property.Name);
}
Object value = property.GetValue(context.DataContext);
if (value != null)
{
object tempValue = value;
PSDataCollection<PSObject> collectionObject = value as PSDataCollection<PSObject>;
if (collectionObject != null && collectionObject.Count == 1)
{
tempValue = collectionObject[0];
}
activityVariables[property.Name] = tempValue;
}
}
// Then, set anything we received from parameters
foreach (PSActivityArgumentInfo currentArgument in GetActivityArguments())
{
string @default = currentArgument.Name;
if (streams.Any(item => string.Equals(item, @default, StringComparison.OrdinalIgnoreCase)))
continue;
object argumentValue = currentArgument.Value.Get(context);
if (argumentValue != null && !activityVariables.ContainsKey(currentArgument.Name))
{
activityVariables[currentArgument.Name] = argumentValue;
}
}
// Then, set the variables from the host defaults
if (defaults != null)
{
foreach (string hostDefault in defaults.Keys)
{
string @default = hostDefault;
if (streams.Any(item => string.Equals(item, @default, StringComparison.OrdinalIgnoreCase)))
continue;
object propertyValue = defaults[hostDefault];
if (propertyValue != null && !activityVariables.ContainsKey(hostDefault))
{
activityVariables[hostDefault] = propertyValue;
}
}
}
if (_commandSpecified)
{
string script = string.IsNullOrEmpty(Command) ? string.Empty : Command;
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Inline Script: '{1}'.", context.ActivityInstanceId, script));
if (IsBlocked(script))
{
throw new PSInvalidOperationException(String.Format(CultureInfo.InvariantCulture, ActivityResources.CannotLaunchFormat, script));
}
string[] targetNodes = null;
if (this.PSComputerName.Expression != null)
{
targetNodes = this.PSComputerName.Get(context);
}
else
{
if (defaults != null && defaults.ContainsKey("PSComputerName"))
{
targetNodes = this.ParameterDefaults.Get(context)["PSComputerName"] as string[];
}
}
// See if this command will be run in process.
if ((targetNodes == null || targetNodes.Length == 0) && GetRunInProc(context))
{
if (_compiledScriptForInProc == null || _ci == null)
{
lock (Syncroot)
{
if (_compiledScriptForInProc == null)
{
if (_scriptWithoutUsing == null)
{
_scriptWithoutUsing = RemoveUsingPrefix(script, allWorkflowVarNames, out _usingVariables);
}
_compiledScriptForInProc = ScriptBlock.Create(_scriptWithoutUsing);
}
// Invoke using the CommandInfo for Invoke-Command directly, rather than going through
// the command discovery since this is much faster.
if (_ci == null)
{
_ci = new CmdletInfo("Invoke-Command", typeof(Microsoft.PowerShell.Commands.InvokeCommandCommand));
}
}
}
SetAvailableUsingVariables(activityVariables, activityUsingVariables);
Tracer.WriteMessage("PowerShell activity: executing InlineScript locally with ScriptBlock.");
invoker = System.Management.Automation.PowerShell.Create();
invoker.AddCommand(_ci).AddParameter("NoNewScope").AddParameter("ScriptBlock", _compiledScriptForInProc);
}
else
{
// Try to convert the ScriptBlock to a powershell instance
if (_compiledScriptForOutProc == null)
{
lock (Syncroot)
{
if (_compiledScriptForOutProc == null)
{
_compiledScriptForOutProc = ScriptBlock.Create(script);
}
}
}
try
{
// we trust the code inside inlinescript, set isTrusted as True.
invoker = _compiledScriptForOutProc.GetPowerShell(activityVariables, out activityUsingVariables, true);
Tracer.WriteMessage("PowerShell activity: executing InlineScript with ScriptBlock to powershell conversion.");
}
catch (Exception)
{
invoker = null;
}
if (invoker == null)
{
// Since scriptblocks aren't serialized with fidelity in the remote case, we need to
// use AddScript instead.
if (_scriptWithoutUsing == null)
{
lock (Syncroot)
{
if (_scriptWithoutUsing == null)
{
_scriptWithoutUsing = RemoveUsingPrefix(script, allWorkflowVarNames, out _usingVariables);
}
}
}
SetAvailableUsingVariables(activityVariables, activityUsingVariables);
Tracer.WriteMessage("PowerShell activity: executing InlineScript by using AddScript.");
invoker = System.Management.Automation.PowerShell.Create();
invoker.AddScript(_scriptWithoutUsing);
}
}
}
else
{
string commandName = CommandName.Get(context);
if (String.IsNullOrEmpty(commandName))
{
throw new ArgumentException(ActivityResources.CommandNameRequired);
}
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Invoking command '{1}'.", context.ActivityInstanceId, commandName));
invoker = System.Management.Automation.PowerShell.Create();
invoker.AddCommand(commandName);
System.Collections.Hashtable parameters = Parameters.Get(context);
if (parameters != null && parameters.Count > 0)
{
foreach (var key in parameters.Keys)
{
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity: Adding parameter '-{0} {1}'.",
key, parameters[key]));
}
invoker.AddParameters(parameters);
}
}
var implementationContext = new ActivityImplementationContext
{
PowerShellInstance = invoker,
WorkflowContext = activityUsingVariables
};
return implementationContext;
}
private void SetAvailableUsingVariables(Dictionary<string, object> allActivityVariables, Dictionary<string, object> activityUsingVariables)
{
if (_usingVariables == null) { return; }
foreach (string varName in _usingVariables)
{
object value;
string varNameToUse = VariablePrefix + varName;
if (allActivityVariables.TryGetValue(varName, out value) && !activityUsingVariables.ContainsKey(varNameToUse))
{
activityUsingVariables.Add(varNameToUse, value);
}
}
}
private void ValidateParameters()
{
if (_commandSpecified)
{
if (CommandName.Expression != null || Parameters.Expression != null)
{
throw new ArgumentException(ActivityResources.CannotSpecifyBothCommandAndCommandName);
}
}
else
{
if (CommandName.Expression == null)
{
throw new ArgumentException(ActivityResources.CannotSpecifyBothCommandAndCommandName);
}
}
}
/// <summary>
/// Checks if the script is blocked
/// </summary>
/// <param name="script"></param>
private bool IsBlocked(string script)
{
string[] psUnsupportedConsoleApplications = new string[]
{
"cmd",
"cmd.exe",
"diskpart",
"diskpart.exe",
"edit.com",
"netsh",
"netsh.exe",
"nslookup",
"nslookup.exe",
"powershell",
"powershell.exe",
};
foreach (string app in psUnsupportedConsoleApplications)
{
if (script.Equals(app, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
#region "Using variable utility"
/// <summary>
/// Remove the "Using" prefix for all UsingExpressionAsts that appear in the given script
/// </summary>
/// <param name="script">script text</param>
/// <param name="allWorkflowVariables">all workflow variables/arguments that potentially can be referred by a using variable</param>
/// <param name="usingVariables">names of the variables in the script that have the "Using" prefix</param>
/// <returns>
/// Return <para>script</para> if the script text is empty string or null
/// Return <para>script</para> if there are errors when parsing the script text
/// Return <para>script</para> if there is no UsingExpressionAst in the given script
/// Return a new script text that has all the "Using" prefixes removed
/// </returns>
private static string RemoveUsingPrefix(string script, HashSet<string> allWorkflowVariables, out HashSet<string> usingVariables)
{
usingVariables = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var usingAsts = GetUsingExpressionAsts(script);
if (usingAsts == null || !usingAsts.Any()) { return script; }
StringBuilder newScript = null;
int startOffset = 0;
foreach (Ast ast in usingAsts)
{
var usingAst = ast as UsingExpressionAst;
if (usingAst == null) { continue; }
VariableExpressionAst variableAst = UsingExpressionAst.ExtractUsingVariable(usingAst);
if (variableAst == null) { continue; }
if (newScript == null)
{
newScript = new StringBuilder();
}
string varName = variableAst.VariablePath.UserPath;
string varSign = variableAst.Splatted ? "@" : "$";
bool needPrefix = allWorkflowVariables.Contains(varName);
string newVar = needPrefix ? (varSign + VariablePrefix + varName) : (varSign + varName);
// Add those variable names that potentially refer to workflow variables/arguments
if (needPrefix && !usingVariables.Contains(varName))
{
usingVariables.Add(varName);
}
newScript.Append(script.Substring(startOffset, variableAst.Extent.StartOffset - startOffset));
newScript.Append(newVar);
startOffset = variableAst.Extent.EndOffset;
}
if (newScript != null)
{
newScript.Append(script.Substring(startOffset));
return newScript.ToString();
}
return script;
}
/// <summary>
/// Get the UsingExpressionAsts out of a script
/// </summary>
/// <param name="script"></param>
/// <returns>a list of UsingExpressionAsts ordered by the StartOffset</returns>
private static IEnumerable<Ast> GetUsingExpressionAsts(string script)
{
if (String.IsNullOrEmpty(script))
{
return null;
}
ParseError[] errors;
Token[] tokens;
ScriptBlockAst scriptAst = Parser.ParseInput(script, out tokens, out errors);
if (errors.Length != 0)
{
return null;
}
var list = scriptAst.FindAll(ast => ast is UsingExpressionAst, searchNestedScriptBlocks: true).ToList();
if (list.Count > 1)
{
return list.OrderBy(a => a.Extent.StartOffset);
}
return list;
}
#endregion "Using variable utility"
/// <summary>
/// Adds the PSActivity variable to the active runspace, which is of type InlineScriptContext.
/// </summary>
/// <param name="implementationContext">The ActivityImplementationContext returned by the call to GetCommand.</param>
protected override void PrepareSession(ActivityImplementationContext implementationContext)
{
if (implementationContext.PSActivityEnvironment == null)
{
implementationContext.PSActivityEnvironment = new PSActivityEnvironment();
}
// Update the preference variables
UpdatePreferenceVariables(implementationContext);
System.Management.Automation.PowerShell session = implementationContext.PowerShellInstance;
implementationContext.PSActivityEnvironment.Variables["UserName"] = System.Environment.UserName;
string computerName = null;
if (implementationContext.ConnectionInfo != null)
{
computerName = implementationContext.ConnectionInfo.ComputerName;
}
if (string.IsNullOrEmpty(computerName))
{
computerName = "localhost";
}
implementationContext.PSActivityEnvironment.Variables["ComputerName"] = computerName;
implementationContext.PSActivityEnvironment.Variables["PSComputerName"] = computerName;
string workflowCommandName = null;
Dictionary<string, object> activityVariables = (Dictionary<string, object>)implementationContext.WorkflowContext;
if (activityVariables != null && activityVariables.ContainsKey("ParameterDefaults"))
{
HostParameterDefaults defaults = activityVariables["ParameterDefaults"] as HostParameterDefaults;
if (defaults != null)
{
workflowCommandName = defaults.Parameters["WorkflowCommandName"] as string;
}
}
if (string.IsNullOrEmpty(workflowCommandName))
{
workflowCommandName = "unknown";
}
implementationContext.PSActivityEnvironment.Variables["CommandName"] = workflowCommandName;
// Populate the default variables
InlineScriptContext inlineScriptContext = new InlineScriptContext(this);
// Populate the activity variables
foreach (KeyValuePair<string, object> entry in activityVariables)
{
if (String.Equals(entry.Key, "ParameterDefaults", StringComparison.OrdinalIgnoreCase))
{
System.Diagnostics.Debug.Assert(entry.Value is HostParameterDefaults, "ParameterDefaults does not contain a HostParameterDefaults object");
inlineScriptContext.Variables[entry.Key] = ((HostParameterDefaults)entry.Value).Parameters;
continue;
}
inlineScriptContext.Variables[entry.Key] = entry.Value;
}
// Set the PowerShell session variables...
foreach (KeyValuePair<string, object> entry in activityVariables)
{
var value = entry.Value;
if (String.Equals(entry.Key, "ParameterDefaults", StringComparison.OrdinalIgnoreCase))
continue;
implementationContext.PSActivityEnvironment.Variables[entry.Key] = value;
}
}
// InlineScript needs to handle these specially, since it might go through the PowerShell AddScript() API.
// If the parameter "CommandName" is in use, we add the preference configuration to the command parameters,
// otherwise, we add the preference configuration to the preference variable.
// All other activities have this set automatically by the infrastructure via parameters.
private void UpdatePreferenceVariables(ActivityImplementationContext implementationContext)
{
System.Management.Automation.PowerShell session = implementationContext.PowerShellInstance;
System.Management.Automation.Runspaces.Command command = null;
if (!_commandSpecified)
{
// "CommandName" and "Parameters" are in use
command = session.Commands.Commands[0];
}
if (implementationContext.Verbose != null)
{
if (command != null)
{
command.Parameters.Add("Verbose", implementationContext.Verbose);
}
else
{
// Map the boolean / switch to an actual action preference
ActionPreference preference = ActionPreference.SilentlyContinue;
if (implementationContext.Verbose.Value)
preference = ActionPreference.Continue;
implementationContext.PSActivityEnvironment.Variables["VerbosePreference"] = preference;
}
}
if (implementationContext.Debug != null)
{
if (command != null)
{
command.Parameters.Add("Debug", implementationContext.Debug);
}
else
{
// Map the boolean / switch to an actual action preference
ActionPreference preference = ActionPreference.SilentlyContinue;
if (implementationContext.Debug.Value)
preference = ActionPreference.Continue;
implementationContext.PSActivityEnvironment.Variables["DebugPreference"] = preference;
}
}
if (implementationContext.WhatIf != null && command != null)
{
command.Parameters.Add("WhatIf", implementationContext.WhatIf);
}
if (implementationContext.ErrorAction != null)
{
if (command != null)
{
command.Parameters.Add("ErrorAction", implementationContext.ErrorAction);
}
else
{
implementationContext.PSActivityEnvironment.Variables["ErrorActionPreference"] = implementationContext.ErrorAction;
}
}
if (implementationContext.WarningAction != null)
{
if (command != null)
{
command.Parameters.Add("WarningAction", implementationContext.WarningAction);
}
else
{
implementationContext.PSActivityEnvironment.Variables["WarningPreference"] = implementationContext.WarningAction;
}
}
if (implementationContext.InformationAction != null)
{
if (command != null)
{
command.Parameters.Add("InformationAction", implementationContext.InformationAction);
}
else
{
implementationContext.PSActivityEnvironment.Variables["InformationPreference"] = implementationContext.InformationAction;
}
}
}
static CommandInfo _ci;
static readonly object Syncroot = new object();
}
/// <summary>
/// Defines the context information available to scripts running within the
/// InlineScript activity. These are exposed through the $PSActivity automatic
/// variable.
/// </summary>
public class InlineScriptContext
{
/// <summary>
/// Creates a new InlineScriptContext
/// </summary>
/// <param name="current">The InlineScript activity being invoked</param>
public InlineScriptContext(InlineScript current)
{
this.current = current;
this.variables = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
this.current = null;
}
/// <summary>
/// Gets the current InlineScript activity being invoked.
/// </summary>
//public InlineScript Current
//{
// get { return current; }
//}
private InlineScript current;
/// <summary>
/// Gets the current variables and arguments that are in-scope for
/// the current activity within its context in the workflow.
/// </summary>
public Dictionary<string, object> Variables
{
get { return variables; }
}
private Dictionary<string, object> variables;
}
/// <summary>
/// Suspends the current workflow.
/// </summary>
public class Suspend : NativeActivity
{
/// <summary>
/// Optional field used for resuming the workflow for a specific label.
/// </summary>
public string Label { get; set; }
/// <summary>
/// Returns true if the activity can induce an idle.
/// </summary>
protected override bool CanInduceIdle { get { return true; } }
/// <summary>
/// Invokes the activity
/// </summary>
/// <param name="context">The activity context.</param>
/// <returns>True if the given argument is set.</returns>
protected override void Execute(NativeActivityContext context)
{
string bookmarkname = string.IsNullOrEmpty(this.Label) ?
PSActivity.PSSuspendBookmarkPrefix :
PSActivity.PSSuspendBookmarkPrefix + this.Label + "_";
bookmarkname += Guid.NewGuid().ToString().Replace("-", "_");
context.CreateBookmark(bookmarkname, BookmarkResumed);
}
private void BookmarkResumed(NativeActivityContext context, Bookmark bookmark, object value)
{
}
}
}

View file

@ -1,35 +0,0 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
#if _NOTARMBUILD_
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Interaction logic for InlineScriptDesigner.xaml
/// </summary>
public partial class InlineScriptDesigner
{
/// <summary>
/// Create the designer instance
/// </summary>
public InlineScriptDesigner()
{
InitializeComponent();
}
}
}
#endif

View file

@ -1,170 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\Invoke-CimMethod command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class InvokeCimMethod : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public InvokeCimMethod()
{
this.DisplayName = "Invoke-CimMethod";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\Invoke-CimMethod"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand); } }
// Arguments
/// <summary>
/// Provides access to the ClassName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> ClassName { get; set; }
/// <summary>
/// Provides access to the CimClass parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimClass> CimClass { get; set; }
/// <summary>
/// Provides access to the Query parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Query { get; set; }
/// <summary>
/// Provides access to the QueryDialect parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> QueryDialect { get; set; }
/// <summary>
/// Provides access to the InputObject parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimInstance> InputObject { get; set; }
/// <summary>
/// Provides access to the Arguments parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Collections.IDictionary> Arguments { get; set; }
/// <summary>
/// Provides access to the MethodName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> MethodName { get; set; }
/// <summary>
/// Provides access to the Namespace parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Namespace { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Script module contents for this activity
/// </summary>
protected override string PSDefiningModule { get { return null; } }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(ClassName.Expression != null)
{
targetCommand.AddParameter("ClassName", ClassName.Get(context));
}
if(CimClass.Expression != null)
{
targetCommand.AddParameter("CimClass", CimClass.Get(context));
}
if(Query.Expression != null)
{
targetCommand.AddParameter("Query", Query.Get(context));
}
if(QueryDialect.Expression != null)
{
targetCommand.AddParameter("QueryDialect", QueryDialect.Get(context));
}
if (InputObject.Expression != null)
{
targetCommand.AddParameter("InputObject", InputObject.Get(context));
}
if(Arguments.Expression != null)
{
targetCommand.AddParameter("Arguments", Arguments.Get(context));
}
if(MethodName.Expression != null)
{
targetCommand.AddParameter("MethodName", MethodName.Get(context));
}
if(Namespace.Expression != null)
{
targetCommand.AddParameter("Namespace", Namespace.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if (ResourceUri != null)
{
targetCommand.AddParameter("ResourceUri", ResourceUri.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,41 +0,0 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
using System;
using System.Activities;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Language;
using System.ComponentModel;
using System.Text;
using System.Reflection;
namespace Microsoft.PowerShell.Activities.Internal
{
/// <summary>
/// Determines whether an argument to a PSActivity activity
/// has been set.
/// </summary>
[SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes", Justification = "Needed Internal use only")]
public class IsArgumentSet : CodeActivity<bool>
{
/// <summary>
/// The argument to investigate.
/// </summary>
[DefaultValue(null)]
public Argument Argument { get; set; }
/// <summary>
/// Invokes the activity
/// </summary>
/// <param name="context">The activity context.</param>
/// <returns>True if the given argument is set.</returns>
protected override bool Execute(CodeActivityContext context)
{
return Argument != null && Argument.Expression != null;
}
}
}

View file

@ -1,163 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\New-CimInstance command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class NewCimInstance : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public NewCimInstance()
{
this.DisplayName = "New-CimInstance";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\New-CimInstance"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.NewCimInstanceCommand); } }
// Arguments
/// <summary>
/// Provides access to the ClassName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> ClassName { get; set; }
/// <summary>
/// Provides access to the Key parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String[]> Key { get; set; }
/// <summary>
/// Provides access to the CimClass parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimClass> CimClass { get; set; }
/// <summary>
/// Provides access to the Property parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Collections.IDictionary> Property { get; set; }
/// <summary>
/// Provides access to the Namespace parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Namespace { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Provides access to the ClientOnly parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> ClientOnly { get; set; }
/// <summary>
/// Script module contents for this activity`n/// </summary>
protected override string PSDefiningModule { get { return null; } }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(ClassName.Expression != null)
{
targetCommand.AddParameter("ClassName", ClassName.Get(context));
}
if(Key.Expression != null)
{
targetCommand.AddParameter("Key", Key.Get(context));
}
if(CimClass.Expression != null)
{
targetCommand.AddParameter("CimClass", CimClass.Get(context));
}
if(Property.Expression != null)
{
targetCommand.AddParameter("Property", Property.Get(context));
}
if(Namespace.Expression != null)
{
targetCommand.AddParameter("Namespace", Namespace.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if (ResourceUri != null)
{
targetCommand.AddParameter("ResourceUri", ResourceUri.Get(context));
}
if (ClientOnly.Expression != null)
{
// Retrieve our host overrides
var hostValues = context.GetExtension<HostParameterDefaults>();
string[] computerName = null;
if (hostValues != null)
{
Dictionary<string, object> incomingArguments = hostValues.Parameters;
if (incomingArguments.ContainsKey("PSComputerName"))
{
computerName = incomingArguments["PSComputerName"] as string[];
}
}
if (computerName == null)
{
targetCommand.AddParameter("ClientOnly", ClientOnly.Get(context));
}
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,148 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\New-CimSession command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class NewCimSession : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public NewCimSession()
{
this.DisplayName = "New-CimSession";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\New-CimSession"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.NewCimSessionCommand); } }
// Arguments
/// <summary>
/// Provides access to the Authentication parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.Options.PasswordAuthenticationMechanism> Authentication { get; set; }
/// <summary>
/// Provides access to the Credential parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.PSCredential> Credential { get; set; }
/// <summary>
/// Provides access to the CertificateThumbprint parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> CertificateThumbprint { get; set; }
/// <summary>
/// Provides access to the Name parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Name { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Provides access to the Port parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> Port { get; set; }
/// <summary>
/// Provides access to the SessionOption parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.Options.CimSessionOptions> SessionOption { get; set; }
/// <summary>
/// Script module contents for this activity`n/// </summary>
protected override string PSDefiningModule { get { return "CimCmdlets"; } }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if (GetIsComputerNameSpecified(context))
{
targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
}
if(Authentication.Expression != null)
{
targetCommand.AddParameter("Authentication", Authentication.Get(context));
}
if(Credential.Expression != null)
{
targetCommand.AddParameter("Credential", Credential.Get(context));
}
if(CertificateThumbprint.Expression != null)
{
targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context));
}
if(Name.Expression != null)
{
targetCommand.AddParameter("Name", Name.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if(Port.Expression != null)
{
targetCommand.AddParameter("Port", Port.Get(context));
}
if(SessionOption.Expression != null)
{
targetCommand.AddParameter("SessionOption", SessionOption.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,286 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\New-CimSessionOption command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class NewCimSessionOption : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public NewCimSessionOption()
{
this.DisplayName = "New-CimSessionOption";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\New-CimSessionOption"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.NewCimSessionOptionCommand); } }
// Arguments
/// <summary>
/// Provides access to the NoEncryption parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> NoEncryption { get; set; }
/// <summary>
/// Provides access to the CertificateCACheck parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> CertificateCACheck { get; set; }
/// <summary>
/// Provides access to the CertificateCNCheck parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> CertificateCNCheck { get; set; }
/// <summary>
/// Provides access to the CertRevocationCheck parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> CertRevocationCheck { get; set; }
/// <summary>
/// Provides access to the EncodePortInServicePrincipalName parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> EncodePortInServicePrincipalName { get; set; }
/// <summary>
/// Provides access to the Encoding parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.Options.PacketEncoding> Encoding { get; set; }
/// <summary>
/// Provides access to the HttpPrefix parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Uri> HttpPrefix { get; set; }
/// <summary>
/// Provides access to the MaxEnvelopeSizeKB parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> MaxEnvelopeSizeKB { get; set; }
/// <summary>
/// Provides access to the ProxyAuthentication parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.Options.PasswordAuthenticationMechanism> ProxyAuthentication { get; set; }
/// <summary>
/// Provides access to the ProxyCertificateThumbprint parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> ProxyCertificateThumbprint { get; set; }
/// <summary>
/// Provides access to the ProxyCredential parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.PSCredential> ProxyCredential { get; set; }
/// <summary>
/// Provides access to the ProxyType parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.Options.ProxyType> ProxyType { get; set; }
/// <summary>
/// Provides access to the UseSsl parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> UseSsl { get; set; }
/// <summary>
/// Provides access to the Impersonation parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.Options.ImpersonationType> Impersonation { get; set; }
/// <summary>
/// Provides access to the PacketIntegrity parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> PacketIntegrity { get; set; }
/// <summary>
/// Provides access to the PacketPrivacy parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> PacketPrivacy { get; set; }
/// <summary>
/// Provides access to the Protocol parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimCmdlets.ProtocolType> Protocol { get; set; }
/// <summary>
/// Provides access to the UICulture parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Globalization.CultureInfo> UICulture { get; set; }
/// <summary>
/// Provides access to the Culture parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Globalization.CultureInfo> Culture { get; set; }
/// <summary>
/// Script module contents for this activity`n/// </summary>
protected override string PSDefiningModule { get { return null; } }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(NoEncryption.Expression != null)
{
targetCommand.AddParameter("NoEncryption", NoEncryption.Get(context));
}
if(CertificateCACheck.Expression != null)
{
targetCommand.AddParameter("CertificateCACheck", CertificateCACheck.Get(context));
}
if(CertificateCNCheck.Expression != null)
{
targetCommand.AddParameter("CertificateCNCheck", CertificateCNCheck.Get(context));
}
if(CertRevocationCheck.Expression != null)
{
targetCommand.AddParameter("CertRevocationCheck", CertRevocationCheck.Get(context));
}
if(EncodePortInServicePrincipalName.Expression != null)
{
targetCommand.AddParameter("EncodePortInServicePrincipalName", EncodePortInServicePrincipalName.Get(context));
}
if(Encoding.Expression != null)
{
targetCommand.AddParameter("Encoding", Encoding.Get(context));
}
if(HttpPrefix.Expression != null)
{
targetCommand.AddParameter("HttpPrefix", HttpPrefix.Get(context));
}
if(MaxEnvelopeSizeKB.Expression != null)
{
targetCommand.AddParameter("MaxEnvelopeSizeKB", MaxEnvelopeSizeKB.Get(context));
}
if(ProxyAuthentication.Expression != null)
{
targetCommand.AddParameter("ProxyAuthentication", ProxyAuthentication.Get(context));
}
if(ProxyCertificateThumbprint.Expression != null)
{
targetCommand.AddParameter("ProxyCertificateThumbprint", ProxyCertificateThumbprint.Get(context));
}
if(ProxyCredential.Expression != null)
{
targetCommand.AddParameter("ProxyCredential", ProxyCredential.Get(context));
}
if(ProxyType.Expression != null)
{
targetCommand.AddParameter("ProxyType", ProxyType.Get(context));
}
if(UseSsl.Expression != null)
{
targetCommand.AddParameter("UseSsl", UseSsl.Get(context));
}
if(Impersonation.Expression != null)
{
targetCommand.AddParameter("Impersonation", Impersonation.Get(context));
}
if(PacketIntegrity.Expression != null)
{
targetCommand.AddParameter("PacketIntegrity", PacketIntegrity.Get(context));
}
if(PacketPrivacy.Expression != null)
{
targetCommand.AddParameter("PacketPrivacy", PacketPrivacy.Get(context));
}
if(Protocol.Expression != null)
{
targetCommand.AddParameter("Protocol", Protocol.Get(context));
}
if(UICulture.Expression != null)
{
targetCommand.AddParameter("UICulture", UICulture.Get(context));
}
if(Culture.Expression != null)
{
targetCommand.AddParameter("Culture", Culture.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,43 +0,0 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
using System;
using System.Activities;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Language;
using System.ComponentModel;
using System.Text;
using System.Reflection;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Persist the current workflow. Also defines the persistence point where suspend-job is getting suspended.
/// </summary>
public class PSPersist : NativeActivity
{
/// <summary>
/// Returns true if the activity can induce an idle.
/// </summary>
protected override bool CanInduceIdle { get { return true; } }
/// <summary>
/// Invokes the activity
/// </summary>
/// <param name="context">The activity context.</param>
protected override void Execute(NativeActivityContext context)
{
string bookmarkname = PSActivity.PSPersistBookmarkPrefix + Guid.NewGuid().ToString().Replace("-", "_");
context.CreateBookmark(bookmarkname, BookmarkResumed);
}
private void BookmarkResumed(NativeActivityContext context, Bookmark bookmark, object value)
{
}
}
}

View file

@ -1,296 +0,0 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
using System;
using System.Activities;
using System.Activities.Validation;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime;
using System.Activities.Statements;
using System.Management.Automation;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// The implementation of pipeline activity.
/// This similar concept which we have in PowerShell today like Get-Process | Stop-Process.
/// Pipeline activity will make sure the piped execution of its child activities.
/// </summary>
#if _NOTARMBUILD_
[Designer (typeof (PipelineDesigner))]
#endif
public sealed class Pipeline : PipelineEnabledActivity
{
/// <summary>
/// Tracks the number of current child activity in the collection.
/// </summary>
private Variable<int> lastIndexHint;
private bool inputValidationFailed;
private bool resultValidationFailed;
/// <summary>
/// Maintain intermediate outflow of data from child activity.
/// </summary>
private Variable<PSDataCollection<PSObject>> OutputStream;
/// <summary>
/// Maintain intermediate inflow of data into child activity.
/// </summary>
private Variable<PSDataCollection<PSObject>> InputStream;
/// <summary>
/// Get activities.
/// </summary>
[RequiredArgument]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage",
"CA2227:CollectionPropertiesShouldBeReadOnly",
Justification = "This is needs to support assignment via workflow.")]
public Collection<PipelineEnabledActivity> Activities { get; set; }
/// <summary>
/// Default constructor
/// </summary>
public Pipeline()
: base()
{
this.lastIndexHint = new Variable<int>();
this.Activities = new Collection<PipelineEnabledActivity>();
this.inputValidationFailed = false;
this.resultValidationFailed = false;
}
/// <summary>
/// Validate the required number of activities of pipeline activity.
/// Setup the cachemetadata with variables and activities.
/// </summary>
/// <param name="metadata"></param>
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
int count = 0;
if (this.Activities != null)
{
count = this.Activities.Count;
}
if (count == 0)
{
metadata.AddValidationError(new ValidationError(ActivityResources.NoChildPipeline, true));
return;
}
//BUGBUG: As written, the following checks cause error in scenarios where they should not.
// They are left in for the time being but disabled until we verify that there are no
// scenarios where we need to check for two variables being assigned.
#if false
if (Input != null && Input.Expression != null && this.Activities[0].Input != null && this.Activities[0].Input.Expression != null)
{
metadata.AddValidationError(new ValidationError(ActivityResources.DuplicateInputDefinedInPipeline, true));
this.inputValidationFailed = true;
return;
}
if (Result != null && Result.Expression != null && this.Activities[count - 1].Result != null && this.Activities[count - 1].Result.Expression != null)
{
metadata.AddValidationError(new ValidationError(ActivityResources.DuplicateResultDefinedInPipeline, true));
this.resultValidationFailed = true;
return;
}
#endif
// Adding variables into the CacheMetadata of pipeline activity.
metadata.AddImplementationVariable(this.lastIndexHint);
// We use a GUID here to make this name hard to guess. It's not a security issue,
// it just prevents code from accidentally taking a dependency on it.
this.OutputStream = new Variable<PSDataCollection<PSObject>>(Guid.NewGuid().ToString().Replace("-","_"));
this.InputStream = new Variable<PSDataCollection<PSObject>>(Guid.NewGuid().ToString().Replace("-","_"));
metadata.AddVariable(this.OutputStream);
metadata.AddVariable(this.InputStream);
bool appendOutput = false;
if ((this.AppendOutput != null) && (this.AppendOutput.Value))
{
appendOutput = true;
}
// Adding activities into the CacheMetadata of pipeline activity.
if (count == 1)
{
if (Input != null && Input.Expression != null)
{
this.Activities[0].Input = this.Input;
}
if (Result != null && Result.Expression != null)
{
this.Activities[0].Result = this.Result;
}
if (appendOutput)
{
this.Activities[0].AppendOutput = true;
}
metadata.AddChild(this.Activities[0]);
}
else
{
if (Input != null && Input.Expression != null)
{
this.Activities[0].Input = this.Input;
}
// Connecting child activities with temporary input and out streams.
this.Activities[0].Result = this.OutputStream;
metadata.AddChild(this.Activities[0]);
for (int i = 1; i < (count - 1); i++)
{
this.Activities[i].Input = this.InputStream;
this.Activities[i].Result = this.OutputStream;
metadata.AddChild(this.Activities[i]);
}
if (Result != null && Result.Expression != null)
{
this.Activities[count - 1].Result = this.Result;
}
if (appendOutput)
{
this.Activities[count - 1].AppendOutput = true;
}
this.Activities[count - 1].Input = this.InputStream;
metadata.AddChild(this.Activities[count - 1]);
}
}
/// <summary>
/// Executes the first child activity
/// </summary>
/// <param name="executionContext">The execution context of pipeline activity.</param>
protected override void Execute(NativeActivityContext executionContext)
{
int count = 0;
if (this.Activities != null)
{
count = this.Activities.Count;
}
if (count == 0)
{
throw new ArgumentException(ActivityResources.NoChildPipeline);
}
if (this.inputValidationFailed && Input != null && Input.Expression != null && this.Activities[0].Input != null && this.Activities[0].Input.Expression != null)
{
throw new ArgumentException(ActivityResources.DuplicateInputDefinedInPipeline);
}
if (this.resultValidationFailed && Result != null && Result.Expression != null && this.Activities[count - 1].Result != null && this.Activities[count - 1].Result.Expression != null)
{
throw new ArgumentException(ActivityResources.DuplicateResultDefinedInPipeline);
}
//Executing the first child activity.
PipelineEnabledActivity firstChild = this.Activities[0];
executionContext.ScheduleActivity(firstChild, new CompletionCallback(InternalExecute));
}
/// <summary>
/// Get results from previous activity and schedule the execution of next activity.
/// </summary>
/// <param name="executionContext">The execution context of pipeline activity.</param>
/// <param name="completedInstance">The activity instance of completed child activity.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
private void InternalExecute(NativeActivityContext executionContext, ActivityInstance completedInstance)
{
int completedInstanceIndex;
// Reading the value of pipeline activity variables from the context.
completedInstanceIndex = this.lastIndexHint.Get(executionContext);
PSDataCollection<PSObject> outValue = this.GetData(executionContext, this.OutputStream);
PSDataCollection<PSObject> inValue = this.GetData(executionContext, this.InputStream);
// Re-checking the index of the the child activity, which has just completed its execution.
if (completedInstanceIndex >= this.Activities.Count || this.Activities[completedInstanceIndex] != completedInstance.Activity)
{
completedInstanceIndex = this.Activities.IndexOf((PSActivity) completedInstance.Activity);
}
// Calculating next child activity.
int nextChildIndex = completedInstanceIndex + 1;
// Checking for pipeline activity completion.
if (nextChildIndex == this.Activities.Count)
{
if (inValue != null) inValue.Dispose();
if (outValue != null) outValue.Dispose();
return;
}
// Setting up the environment for next child activity to run.
if (outValue != null) outValue.Complete();
if (inValue != null) inValue.Dispose();
inValue = outValue;
outValue = new PSDataCollection<PSObject>();
// The pipeline is complete if there is no input
// PS > function foo { $input | Write-Output "Hello" }
// PS > foo
// PS >
if ((inValue == null) || (inValue.Count == 0))
{
if (outValue != null) outValue.Dispose();
return;
}
this.SetData(executionContext, this.OutputStream, outValue);
this.SetData(executionContext, this.InputStream, inValue);
// Executing the next child activity.
PipelineEnabledActivity nextChild = this.Activities[nextChildIndex];
executionContext.ScheduleActivity(nextChild, new CompletionCallback(InternalExecute));
this.lastIndexHint.Set(executionContext, nextChildIndex);
}
/// <summary>
/// Get the data from the pipeline variable.
/// </summary>
/// <param name="context">The activity context.</param>
/// <param name="variable">The variable which value to get.</param>
/// <returns>Returns the value of the variable.</returns>
private PSDataCollection<PSObject> GetData(ActivityContext context, Variable<PSDataCollection<PSObject>> variable)
{
PropertyDescriptor prop = context.DataContext.GetProperties()[variable.Name];
return (PSDataCollection<PSObject>)prop.GetValue(context.DataContext);
}
/// <summary>
/// Set the data to the pipeline variable.
/// </summary>
/// <param name="context">The activity context.</param>
/// <param name="variable">The variable which needs to set.</param>
/// <param name="value">The value for the variable.</param>
private void SetData(ActivityContext context, Variable<PSDataCollection<PSObject>> variable, PSDataCollection<PSObject> value)
{
PropertyDescriptor prop = context.DataContext.GetProperties()[variable.Name];
prop.SetValue(context.DataContext, value);
}
}
}

View file

@ -1,23 +0,0 @@
//
// Copyright (C) Microsoft. All rights reserved.
//

#if _NOTARMBUILD_
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Interaction logic for PipelineDesigner.xaml
/// </summary>
public partial class PipelineDesigner
{
/// <summary>
/// Default Constructor.
/// </summary>
public PipelineDesigner()
{
InitializeComponent();
}
}
}
#endif

View file

@ -1,564 +0,0 @@
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Globalization;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Activities;
using System.Diagnostics;
using System.Management.Automation;
using System.Management.Automation.Language;
using System.Management.Automation.Runspaces;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Evaluate the Powershell expression and return the value of type T.
/// </summary>
public sealed class PowerShellValue<T> : NativeActivity<T>
{
/// <summary>
/// The PowerShell expression, which will be evaluated and retuned a type of T value.
/// </summary>
[RequiredArgument]
public string Expression { get; set; }
/// <summary>
/// Determines whether to connect the input stream for this activity.
/// </summary>
[DefaultValue(false)]
public bool UseDefaultInput
{
get;
set;
}
/// <summary>
/// Validates the syntax of the script text for this activity.
/// </summary>
/// <param name="metadata">Activity metadata for this activity</param>
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
base.CacheMetadata(metadata);
if (!string.IsNullOrWhiteSpace(Expression))
{
var errors = new Collection<PSParseError>();
PSParser.Tokenize(Expression, out errors);
if (errors != null && errors.Count > 0)
{
string compositeErrorString = "";
foreach (var e in errors)
{
// Format and add each error message...
compositeErrorString += string.Format(CultureInfo.InvariantCulture,
"[{0}, {1}]: {2}\n", e.Token.StartLine, e.Token.StartColumn, e.Message);
}
metadata.AddValidationError(compositeErrorString);
}
}
}
/// <summary>
/// Get the scriptblock for this activity, caching it once it's compiled.
/// </summary>
private ScriptBlock ExpressionScriptBlock
{
get
{
if (_expressionScriptBlock == null)
{
lock (syncroot)
{
if (_expressionScriptBlock == null)
{
// The guard check for a null expression string is done in Execute() instead
// of in this property. It's also done in the validation check for CacheMetadata
string updatedExpression = Expression;
// Hack to make sure the $input *does* get unrolled...
if (string.Equals("$input", Expression.Trim(), StringComparison.OrdinalIgnoreCase))
{
updatedExpression = "$(" + updatedExpression + "\n)";
}
else
{
Token[] tokens;
ParseError[] errors;
ScriptBlockAst exprAst = Parser.ParseInput(updatedExpression, out tokens, out errors);
if (errors.Length > 0)
{
throw new ParseException(errors);
}
if (exprAst.BeginBlock == null && exprAst.ProcessBlock == null && exprAst.EndBlock != null)
{
var statements = exprAst.EndBlock.Statements;
if (statements != null && statements.Count == 1)
{
PipelineAst pipeline = statements[0] as PipelineAst;
if (pipeline != null && pipeline.GetPureExpression() != null)
{
// It is very difficult to get equivalent expression semantics in workflow because the engine
// APIs get in the way necessitating a lot of fiddling with the actual expression as well as post-processing
// the result of the expression.
// We wrap a pure expression in an array so that PowerShell's loop unrolling doesn't impact our
// ability to return collections. We also add a trap/break so that terminating errors in expressions
// are turned into exceptions for the PowerShell object. The trap and closing ')' go on their own line
// for the XAML designer case where the expression might have a trailing '#' making the rest of the
// line into a comment.
updatedExpression = ",(" + updatedExpression + "\n); trap { break }";
}
}
}
}
_expressionScriptBlock = ScriptBlock.Create(updatedExpression);
}
}
}
return _expressionScriptBlock;
}
}
ScriptBlock _expressionScriptBlock;
/// <summary>
/// Check to see if the expression only uses elements of the restricted language
/// as well as only using the allowed commands and variables.
/// </summary>
/// <param name="allowedCommands">
/// List of command names to allow in the expression
/// </param>
/// <param name="allowedVariables">
/// List of variable names to allow in the expression. If the collection contains a single
/// element "*", all variables will be allowed including environment variables
/// functions, etc.
/// </param>
/// <param name="allowEnvironmentVariables">
/// If true, environment variables are allowed even if the allowedVariables list is empty.
/// </param>
public void ValidateExpressionConstraints(IEnumerable<string> allowedCommands, IEnumerable<string> allowedVariables, bool allowEnvironmentVariables)
{
ExpressionScriptBlock.CheckRestrictedLanguage(allowedCommands, allowedVariables, allowEnvironmentVariables);
}
/// <summary>
/// Execution of PowerShell value activity.
/// PowerShell expression will be evaluated using PowerShell runspace and the value of Type T will be returned.
/// </summary>
/// <param name="context"></param>
protected override void Execute(NativeActivityContext context)
{
Token[] tokens;
ParseError[] errors;
ScriptBlockAst exprAst = Parser.ParseInput(Expression, out tokens, out errors);
bool hasErrorActionPreference = false;
bool hasWarningPreference = false;
bool hasInformationPreference = false;
// Custom activity participant tracker for updating debugger with current variables and sequence stop points.
// Regex looks for debugger sequence points like: Expression="'3:5:WFFunc1'".
// We specifically disallow TimeSpan values that look like sequence points: Expression="'00:00:01'".
bool isDebugSequencePoint = (!string.IsNullOrEmpty(Expression) && (System.Text.RegularExpressions.Regex.IsMatch(Expression, @"^'\d+:\d+:\S+'$")) &&
(typeof(T) != typeof(System.TimeSpan)));
var dataProperties = context.DataContext.GetProperties();
if (isDebugSequencePoint || (dataProperties.Count > 0))
{
System.Activities.Tracking.CustomTrackingRecord customRecord = new System.Activities.Tracking.CustomTrackingRecord("PSWorkflowCustomUpdateDebugVariablesTrackingRecord");
foreach (System.ComponentModel.PropertyDescriptor property in dataProperties)
{
if (String.Equals(property.Name, "ParameterDefaults", StringComparison.OrdinalIgnoreCase)) { continue; }
Object value = property.GetValue(context.DataContext);
if (value != null)
{
object tempValue = value;
PSDataCollection<PSObject> collectionObject = value as PSDataCollection<PSObject>;
if (collectionObject != null && collectionObject.Count == 1)
{
tempValue = collectionObject[0];
}
customRecord.Data.Add(property.Name, tempValue);
}
}
if (isDebugSequencePoint)
{
customRecord.Data.Add("DebugSequencePoint", Expression);
}
context.Track(customRecord);
}
if (tokens != null)
{
foreach(Token token in tokens)
{
VariableToken variable = token as VariableToken;
if (variable != null)
{
if (variable.Name.Equals("ErrorActionPreference", StringComparison.OrdinalIgnoreCase))
{
hasErrorActionPreference = true;
}
else if (variable.Name.Equals("WarningPreference", StringComparison.OrdinalIgnoreCase))
{
hasWarningPreference = true;
}
else if (variable.Name.Equals("InformationPreference", StringComparison.OrdinalIgnoreCase))
{
hasInformationPreference = true;
}
}
}
}
if (string.IsNullOrEmpty(Expression))
{
throw new ArgumentException(ActivityResources.NullArgumentExpression);
}
if (_ci == null)
{
lock (syncroot)
{
// Invoke using the CommandInfo for Invoke-Command directly, rather than going through
// command discovery (which is very slow).
if (_ci == null)
{
_ci = new CmdletInfo("Invoke-Command", typeof(Microsoft.PowerShell.Commands.InvokeCommandCommand));
}
}
}
Collection<PSObject> returnedvalue;
Runspace runspace = null;
bool borrowedRunspace = false;
PSWorkflowHost workflowHost = null;
if (typeof(ScriptBlock).IsAssignableFrom(typeof(T)))
{
Result.Set(context, ScriptBlock.Create(Expression));
return;
}
else if (typeof(ScriptBlock[]).IsAssignableFrom(typeof(T)))
{
Result.Set(context, new ScriptBlock[] { ScriptBlock.Create(Expression) });
return;
}
PropertyDescriptorCollection col = context.DataContext.GetProperties();
HostParameterDefaults hostValues = context.GetExtension<HostParameterDefaults>();
// Borrow a runspace from the host if we're not trying to create a ScriptBlock.
// If we are trying to create one, we need to keep it around so that it can be
// invoked multiple times.
if (hostValues != null)
{
workflowHost = hostValues.Runtime;
try
{
runspace = workflowHost.UnboundedLocalRunspaceProvider.GetRunspace(null, 0, 0);
borrowedRunspace = true;
}
catch (Exception)
{
// it is fine to catch generic exception here
// if the local runspace provider does not give us
// a runspace we will create one locally (fallback)
}
}
if (runspace == null)
{
// Not running with the PowerShell workflow host so directly create the runspace...
runspace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault2());
runspace.Open();
}
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
try
{
ps.Runspace = runspace;
// Subscribe to DataAdding on the error stream so that we can add position tracking information
if (hostValues != null)
{
HostSettingCommandMetadata sourceCommandMetadata = hostValues.HostCommandMetadata;
CommandMetadataTable.TryAdd(ps.InstanceId, sourceCommandMetadata);
ps.Streams.Error.DataAdding += HandleErrorDataAdding;
}
// First, set the variables from the host defaults
if ((hostValues != null) && (hostValues.Parameters != null))
{
if (hostValues.Parameters.ContainsKey("PSCurrentDirectory"))
{
string path = hostValues.Parameters["PSCurrentDirectory"] as string;
if (path != null)
{
ps.Runspace.SessionStateProxy.Path.SetLocation(path);
}
}
foreach (string hostDefault in hostValues.Parameters.Keys)
{
string mappedHostDefault = hostDefault;
if (hostDefault.Equals("ErrorAction", StringComparison.OrdinalIgnoreCase))
{
if (hasErrorActionPreference)
{
mappedHostDefault = "ErrorActionPreference";
}
else
{
continue;
}
}
else if (hostDefault.Equals("WarningAction", StringComparison.OrdinalIgnoreCase))
{
if (hasWarningPreference)
{
mappedHostDefault = "WarningPreference";
}
else
{
continue;
}
}
else if (hostDefault.Equals("InformationAction", StringComparison.OrdinalIgnoreCase))
{
if (hasInformationPreference)
{
mappedHostDefault = "InformationPreference";
}
else
{
continue;
}
}
object propertyValue = hostValues.Parameters[hostDefault];
if (propertyValue != null)
{
ps.Runspace.SessionStateProxy.PSVariable.Set(mappedHostDefault, propertyValue);
}
}
}
// Then, set the variables from the workflow
foreach (PropertyDescriptor p in col)
{
string name = p.Name;
object value = p.GetValue(context.DataContext);
if (value != null)
{
object tempValue = value;
PSDataCollection<PSObject> collectionObject = value as PSDataCollection<PSObject>;
if (collectionObject != null && collectionObject.Count == 1)
{
tempValue = collectionObject[0];
}
ps.Runspace.SessionStateProxy.PSVariable.Set(name, tempValue);
}
}
ps.AddCommand(_ci).AddParameter("NoNewScope").AddParameter("ScriptBlock", ExpressionScriptBlock);
// If this needs to consume input, take it from the host stream.
PSDataCollection<PSObject> inputStream = null;
if (UseDefaultInput)
{
// Retrieve our host overrides
hostValues = context.GetExtension<HostParameterDefaults>();
if (hostValues != null)
{
Dictionary<string, object> incomingArguments = hostValues.Parameters;
if (incomingArguments.ContainsKey("Input"))
{
inputStream = incomingArguments["Input"] as PSDataCollection<PSObject>;
}
}
}
// Now invoke the pipeline
try
{
if (inputStream != null)
{
returnedvalue = ps.Invoke(inputStream);
inputStream.Clear();
}
else
{
returnedvalue = ps.Invoke();
}
}
catch (CmdletInvocationException cie)
{
if (cie.ErrorRecord != null && cie.ErrorRecord.Exception != null)
{
throw cie.InnerException;
}
else
{
throw;
}
}
}
finally
{
if (hostValues != null)
{
ps.Streams.Error.DataAdding -= HandleErrorDataAdding;
HostSettingCommandMetadata removedValue;
CommandMetadataTable.TryRemove(ps.InstanceId, out removedValue);
}
if (borrowedRunspace)
{
workflowHost.UnboundedLocalRunspaceProvider.ReleaseRunspace(runspace);
}
else
{
// This will be disposed when the command is done with it.
runspace.Dispose();
runspace = null;
}
}
if (ps.Streams.Error != null && ps.Streams.Error.Count > 0)
{
PSDataCollection<ErrorRecord> errorStream = null;
// Retrieve our host overrides
hostValues = context.GetExtension<HostParameterDefaults>();
if (hostValues != null)
{
Dictionary<string, object> incomingArguments = hostValues.Parameters;
if (incomingArguments.ContainsKey("PSError"))
{
errorStream = incomingArguments["PSError"] as PSDataCollection<ErrorRecord>;
}
}
if (errorStream != null && errorStream.IsOpen)
{
foreach (ErrorRecord record in ps.Streams.Error)
{
errorStream.Add(record);
}
}
}
T valueToReturn = default(T);
if (returnedvalue != null && returnedvalue.Count > 0)
{
try
{
if (returnedvalue.Count == 1)
{
if (returnedvalue[0] != null)
{
Object result = returnedvalue[0];
Object baseObject = ((PSObject)result).BaseObject;
if (! (baseObject is PSCustomObject))
{
result = baseObject;
}
// Try regular PowerShell conversion
valueToReturn = LanguagePrimitives.ConvertTo<T>( result );
}
}
else
{
valueToReturn = LanguagePrimitives.ConvertTo<T>(returnedvalue);
}
}
catch (PSInvalidCastException)
{
// Handle the special case of emitting a PSDataCollection - use its array constructor.
// This special case is why we aren't using PowerShell.Invoke<T>
if (typeof(T) == typeof(PSDataCollection<PSObject>))
{
Object tempValueToReturn = new PSDataCollection<PSObject>(
new List<PSObject> { LanguagePrimitives.ConvertTo<PSObject>(returnedvalue[0]) });
valueToReturn = (T)tempValueToReturn;
}
else
{
throw;
}
}
Result.Set(context, valueToReturn);
}
}
}
private static void HandleErrorDataAdding(object sender, DataAddingEventArgs e)
{
HostSettingCommandMetadata commandMetadata;
CommandMetadataTable.TryGetValue(e.PowerShellInstanceId, out commandMetadata);
if (commandMetadata != null)
{
PowerShellInvocation_ErrorAdding(sender, e, commandMetadata);
}
}
private static readonly ConcurrentDictionary<Guid, HostSettingCommandMetadata> CommandMetadataTable =
new ConcurrentDictionary<Guid, HostSettingCommandMetadata>();
private static void PowerShellInvocation_ErrorAdding(object sender, DataAddingEventArgs e, HostSettingCommandMetadata commandMetadata)
{
ErrorRecord errorRecord = e.ItemAdded as ErrorRecord;
if (errorRecord != null)
{
if (commandMetadata != null)
{
ScriptPosition scriptStart = new ScriptPosition(
commandMetadata.CommandName,
commandMetadata.StartLineNumber,
commandMetadata.StartColumnNumber,
null);
ScriptPosition scriptEnd = new ScriptPosition(
commandMetadata.CommandName,
commandMetadata.EndLineNumber,
commandMetadata.EndColumnNumber,
null);
ScriptExtent extent = new ScriptExtent(scriptStart, scriptEnd);
if (errorRecord.InvocationInfo != null)
{
errorRecord.InvocationInfo.DisplayScriptPosition = extent;
}
}
}
}
static CommandInfo _ci;
static object syncroot = new object();
}
}

View file

@ -1,120 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\Remove-CimInstance command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class RemoveCimInstance : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public RemoveCimInstance()
{
this.DisplayName = "Remove-CimInstance";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\Remove-CimInstance"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.RemoveCimInstanceCommand); } }
/// <summary>
/// Provides access to the Namespace parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Namespace { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Provides access to the InputObject parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimInstance> InputObject { get; set; }
/// <summary>
/// Provides access to the Query parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Query { get; set; }
/// <summary>
/// Provides access to the QueryDialect parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> QueryDialect { get; set; }
/// <summary>
/// Script module contents for this activity`n/// </summary>
protected override string PSDefiningModule { get { return null; } }
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(Namespace.Expression != null)
{
targetCommand.AddParameter("Namespace", Namespace.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if (InputObject.Expression != null)
{
targetCommand.AddParameter("InputObject", InputObject.Get(context));
}
if(Query.Expression != null)
{
targetCommand.AddParameter("Query", Query.Get(context));
}
if(QueryDialect.Expression != null)
{
targetCommand.AddParameter("QueryDialect", QueryDialect.Get(context));
}
if (ResourceUri != null)
{
targetCommand.AddParameter("ResourceUri", ResourceUri.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,148 +0,0 @@
using Microsoft.PowerShell.Activities;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
namespace cimcmdlets.Activities
{
/// <summary>
/// Activity to invoke the CimCmdlets\Set-CimInstance command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class SetCimInstance : GenericCimCmdletActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public SetCimInstance()
{
this.DisplayName = "Set-CimInstance";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName { get { return "CimCmdlets\\Set-CimInstance"; } }
/// <summary>
/// The .NET type implementing the cmdlet to invoke.
/// </summary>
public override System.Type TypeImplementingCmdlet { get { return typeof(Microsoft.Management.Infrastructure.CimCmdlets.SetCimInstanceCommand); } }
/// <summary>
/// Provides access to the Namespace parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Namespace { get; set; }
/// <summary>
/// Provides access to the OperationTimeoutSec parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.UInt32> OperationTimeoutSec { get; set; }
/// <summary>
/// Provides access to the InputObject parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<Microsoft.Management.Infrastructure.CimInstance> InputObject { get; set; }
/// <summary>
/// Provides access to the Query parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Query { get; set; }
/// <summary>
/// Provides access to the QueryDialect parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> QueryDialect { get; set; }
/// <summary>
/// Provides access to the Property parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Collections.IDictionary> Property { get; set; }
/// <summary>
/// Provides access to the PassThru parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> PassThru { get; set; }
/// <summary>
/// Module defining this command
/// Script module contents for this activity
/// </summary>
protected override string PSDefiningModule { get { return "CimCmdlets"; } }
// Additional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(Namespace.Expression != null)
{
targetCommand.AddParameter("Namespace", Namespace.Get(context));
}
if(OperationTimeoutSec.Expression != null)
{
targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
}
if (InputObject.Expression != null)
{
targetCommand.AddParameter("InputObject", InputObject.Get(context));
}
if(Query.Expression != null)
{
targetCommand.AddParameter("Query", Query.Get(context));
}
if(QueryDialect.Expression != null)
{
targetCommand.AddParameter("QueryDialect", QueryDialect.Get(context));
}
if(Property.Expression != null)
{
targetCommand.AddParameter("Property", Property.Get(context));
}
if(PassThru.Expression != null)
{
targetCommand.AddParameter("PassThru", PassThru.Get(context));
}
if (ResourceUri != null)
{
targetCommand.AddParameter("ResourceUri", ResourceUri.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
}
}

View file

@ -1,602 +0,0 @@
using System;
using System.Reflection;
using System.Activities;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Management.Automation;
using System.Management.Automation.Remoting;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Tracing;
using System.ComponentModel;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Activity to set a host value in a Workflow.
/// </summary>
public sealed class SetPSWorkflowData : NativeActivity
{
/// <summary>
/// The variable to set, if not included in the PSWorkflowRuntimeVariable enum.
/// </summary>
[DefaultValue(null)]
public InArgument<string> OtherVariableName
{
get;
set;
}
/// <summary>
///
/// </summary>
[DefaultValue(null)]
public InArgument<Object> Value
{
get;
set;
}
/// <summary>
/// Defines the remoting behavior to use when invoking this activity.
/// </summary>
[ConnectivityCategory]
[DefaultValue(RemotingBehavior.PowerShell)]
public InArgument<RemotingBehavior> PSRemotingBehavior { get; set; }
/// <summary>
/// Defines the number of retries that the activity will make to connect to a remote
/// machine when it encounters an error. The default is to not retry.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<uint?> PSConnectionRetryCount
{
get;
set;
}
/// <summary>
/// Defines the delay, in seconds, between connection retry attempts.
/// The default is one second.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<uint?> PSConnectionRetryIntervalSec
{
get;
set;
}
/// <summary>
/// The Input stream for the activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<PSDataCollection<PSObject>> Input
{
get;
set;
}
/// <summary>
/// Determines whether to connect the input stream for this activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(false)]
public bool UseDefaultInput
{
get;
set;
}
/// <summary>
/// The output stream from the activity
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InOutArgument<PSDataCollection<PSObject>> Result
{
get;
set;
}
/// <summary>
/// Determines whether to append output to Result.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public bool? AppendOutput
{
get;
set;
}
/// <summary>
/// The Error stream / collection for the activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InOutArgument<PSDataCollection<ErrorRecord>> PSError
{
get;
set;
}
/// <summary>
/// The Progress stream / collection for the activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InOutArgument<PSDataCollection<ProgressRecord>> PSProgress
{
get;
set;
}
/// <summary>
/// The Verbose stream / collection for the activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InOutArgument<PSDataCollection<VerboseRecord>> PSVerbose
{
get;
set;
}
/// <summary>
/// The Debug stream / collection for the activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InOutArgument<PSDataCollection<DebugRecord>> PSDebug
{
get;
set;
}
/// <summary>
/// The Warning stream / collection for the activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InOutArgument<PSDataCollection<WarningRecord>> PSWarning
{
get;
set;
}
/// <summary>
/// The Information stream / collection for the activity.
/// </summary>
[InputAndOutputCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InOutArgument<PSDataCollection<InformationRecord>> PSInformation
{
get;
set;
}
/// <summary>
/// The computer name to invoke this activity on.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
public InArgument<string[]> PSComputerName
{
get;
set;
}
/// <summary>
/// Defines the credential to use in the remote connection.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
public InArgument<PSCredential> PSCredential
{
get;
set;
}
/// <summary>
/// Forces the activity to return non-serialized objects. Resulting objects
/// have functional methods and properties (as opposed to serialized versions
/// of them), but will not survive persistence when the Workflow crashes or is
/// persisted.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<bool?> PSDisableSerialization
{
get;
set;
}
/// <summary>
/// Forces the activity to not call the persist functionality, which will be responsible for
/// persisting the workflow state onto the disk.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<bool?> PSPersist
{
get;
set;
}
/// <summary>
/// Determines whether to merge error data to the output stream
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<bool?> MergeErrorToOutput
{
get;
set;
}
/// <summary>
/// Defines the maximum amount of time, in seconds, that this activity may run.
/// The default is unlimited.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<uint?> PSActionRunningTimeoutSec
{
get;
set;
}
/// <summary>
/// Defines the maximum amount of time that the workflow engine should wait for a bookmark
/// to be resumed.
/// The default is unlimited.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<uint?> PSBookmarkTimeoutSec
{
get;
set;
}
/// <summary>
/// This the list of module names (or paths) that are required to run this Activity successfully.
/// The default is null.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<string[]> PSRequiredModules
{
get;
set;
}
/// <summary>
/// Defines the number of retries that the activity will make when it encounters
/// an error during execution of its action. The default is to not retry.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<uint?> PSActionRetryCount
{
get;
set;
}
/// <summary>
/// Defines the delay, in seconds, between action retry attempts.
/// The default is one second.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<uint?> PSActionRetryIntervalSec
{
get;
set;
}
/// <summary>
/// The port to use in a remote connection attempt. The default is:
/// HTTP: 5985, HTTPS: 5986.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<uint?> PSPort { get; set; }
/// <summary>
/// Determines whether to use SSL in the connection attempt. The default is false.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<bool?> PSUseSsl { get; set; }
/// <summary>
/// Determines whether to allow redirection by the remote computer. The default is false.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<bool?> PSAllowRedirection { get; set; }
/// <summary>
/// Defines the remote application name to connect to. The default is "wsman".
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
public InArgument<string> PSApplicationName { get; set; }
/// <summary>
/// Defines the remote configuration name to connect to. The default is "Microsoft.PowerShell".
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
public InArgument<string> PSConfigurationName { get; set; }
/// <summary>
/// Defines the fully-qualified remote URI to connect to. When specified, the PSComputerName,
/// PSApplicationName, PSConfigurationName, and PSPort are not used.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
public InArgument<string[]> PSConnectionUri { get; set; }
/// <summary>
/// Defines the authentication type to be used in the remote connection.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<AuthenticationMechanism?> PSAuthentication { get; set; }
/// <summary>
/// Defines the certificate thumbprint to be used in the remote connection.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
public InArgument<string> PSCertificateThumbprint { get; set; }
/// <summary>
/// Defines any session options to be used in the remote connection.
/// </summary>
[ConnectivityCategory]
[DefaultValue(null)]
public InArgument<PSSessionOption> PSSessionOption { get; set; }
/// <summary>
/// Execute the logic for this activity...
/// </summary>
/// <param name="context"></param>
protected override void Execute(NativeActivityContext context)
{
// Retrieve our host overrides
HostParameterDefaults hostValues = context.GetExtension<HostParameterDefaults>();
SetHostValuesByVariableName(context, hostValues);
SetHostValuesByProperty(context, hostValues);
}
private void SetHostValuesByProperty(NativeActivityContext context, HostParameterDefaults hostValues)
{
Type currentType = this.GetType();
// Populate any of our parameters into the host defaults.
foreach (PropertyInfo field in currentType.GetProperties())
{
// See if it's an argument
if (typeof(Argument).IsAssignableFrom(field.PropertyType))
{
// Skip the ones that are specific to this activity
if (String.Equals("VariableToSet", field.Name, StringComparison.OrdinalIgnoreCase) ||
String.Equals("OtherVariableName", field.Name, StringComparison.OrdinalIgnoreCase) ||
String.Equals("Value", field.Name, StringComparison.OrdinalIgnoreCase))
{
continue;
}
// Handle Bookmark timeouts, but don't set them as a host default.
if (String.Equals("PSBookmarkTimeoutSec", field.Name, StringComparison.OrdinalIgnoreCase))
{
// See if this is trying to change the bookmark timeout
if (PSBookmarkTimeoutSec.Get(context).HasValue)
{
SafelySetResumeBookmarkTimeout(TimeSpan.FromSeconds(PSBookmarkTimeoutSec.Get(context).Value));
}
else
{
SafelySetResumeBookmarkTimeout(TimeSpan.FromSeconds(0));
}
continue;
}
// Get the argument
Argument currentArgument = (Argument)field.GetValue(this, null);
if (currentArgument.Expression != null)
{
if (currentArgument.Get(context) == null)
{
hostValues.Parameters.Remove(field.Name);
}
else
{
hostValues.Parameters[field.Name] = currentArgument.Get(context);
}
}
}
}
}
private void SetHostValuesByVariableName(NativeActivityContext context, HostParameterDefaults hostValues)
{
// Set the Command / host metadata
string variableName = null;
if (OtherVariableName.Get(context) != null)
{
if (OtherVariableName.Expression != null)
{
string value = OtherVariableName.Get(context);
if (!string.IsNullOrWhiteSpace(value))
{
variableName = value;
}
}
if (String.Equals(variableName, "Position", StringComparison.OrdinalIgnoreCase))
{
HostSettingCommandMetadata metadata = hostValues.HostCommandMetadata;
// The position should come in as line:column:command
string positionMessage = (string)Value.Get(context);
string[] positionElements = positionMessage.Split(new char[] { ':' }, 3);
string line = positionElements[0].Trim();
string column = positionElements[1].Trim();
string commandName = positionElements[2].Trim();
if (!String.IsNullOrEmpty(line))
{
metadata.StartLineNumber = Int32.Parse(line, CultureInfo.InvariantCulture);
}
if (!String.IsNullOrEmpty(column))
{
metadata.StartColumnNumber = Int32.Parse(line, CultureInfo.InvariantCulture);
}
if (!String.IsNullOrEmpty(commandName))
{
metadata.CommandName = commandName;
}
}
else
{
if (Value.Get(context) == null)
{
hostValues.Parameters.Remove(variableName);
}
else
{
hostValues.Parameters[variableName] = Value.Get(context);
}
}
}
}
/// <summary>
/// Internal reflection call to set the ResumeBookmarkTimeout property, which
/// controls how much time Workflow allows an activity to run while a bookmark is
/// being resumed. The workflow default is 30 seconds, which can be exceeded
/// on heavily loaded systems especially on parallel workflows.
/// There is not a public property for this value, so the implementation below is
/// the one recommended by the workflow team.
/// </summary>
/// <param name="timeout">How long to wait.</param>
private static void SafelySetResumeBookmarkTimeout(TimeSpan timeout)
{
Type activityDefaults = Type.GetType("System.Activities.ActivityDefaults, System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
if (activityDefaults != null)
{
FieldInfo resumeBookmarkTimeout = activityDefaults.GetField("ResumeBookmarkTimeout");
if (resumeBookmarkTimeout != null)
{
// This is an attempt to reset the workflow default.
if (timeout.TotalSeconds == 0)
{
// First see if it's been explicitly set. If so, don't reset it.
TimeSpan currentTimeout = (TimeSpan)resumeBookmarkTimeout.GetValue(null);
if (currentTimeout.TotalSeconds == 30)
{
resumeBookmarkTimeout.SetValue(null, TimeSpan.MaxValue);
}
}
else
{
// They've specified a value. Use it.
resumeBookmarkTimeout.SetValue(null, timeout);
}
}
else
{
System.Diagnostics.Debug.Fail("Could not find ResumeBookmarkTimeout property");
}
}
else
{
System.Diagnostics.Debug.Fail("Could not find ResumeBookmarkTimeout type");
}
}
}
}

View file

@ -1,130 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.Activities;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Markup;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Implements the equivalent of the ParallelForeach activity, but supports throttling
/// as well. Taken from the Workflow SDK: http://www.microsoft.com/en-us/download/details.aspx?id=21459
/// </summary>
/// <typeparam name="T"></typeparam>
[ContentProperty("Body")]
public sealed class ThrottledParallelForEach<T> : NativeActivity
{
Variable<bool> hasCompleted;
Variable<IEnumerator<T>> valueEnumerator;
CompletionCallback onBodyComplete;
/// <summary>
/// Creates a new instance of the ThrottledParallelForeach activity
/// </summary>
public ThrottledParallelForEach()
: base()
{
}
/// <summary>
/// Gets or sets the actions to be invoked in parallel
/// </summary>
[Browsable(false)]
[DefaultValue(null)]
public ActivityAction<T> Body { get; set; }
/// <summary>
/// Gets or sets the number of activities that may be scheduled simultaneously
/// </summary>
public InArgument<int> ThrottleLimit { get; set; }
/// <summary>
/// Gets or sets the values to be iterated over
/// </summary>
[RequiredArgument]
[DefaultValue(null)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<IEnumerable<T>> Values { get; set; }
/// <summary>
/// Store implementation variables
/// </summary>
/// <param name="metadata"></param>
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
// add the arguments to the argument collection
metadata.AddArgument(new RuntimeArgument("Values", typeof(IEnumerable<T>), ArgumentDirection.In, true));
metadata.AddArgument(new RuntimeArgument("ThrottleLimit", typeof(int), ArgumentDirection.In));
// initialize the hasCompleted and valueEnumerator and add it to the list of private variables
this.hasCompleted = new Variable<bool>();
metadata.AddImplementationVariable(this.hasCompleted);
this.valueEnumerator = new Variable<IEnumerator<T>>();
metadata.AddImplementationVariable(this.valueEnumerator);
// add the body to the delegates collection
metadata.AddDelegate(this.Body);
}
/// <summary>
/// Invoke the activity's actions
/// </summary>
/// <param name="context"></param>
protected override void Execute(NativeActivityContext context)
{
// get the list of value to iterate through
IEnumerable<T> values = this.Values.Get(context);
if (values == null)
{
throw new ApplicationException("ParallelForEach requires a non null Values collection");
}
// get the enumerator
this.valueEnumerator.Set(context, values.GetEnumerator());
// initialize the values for creating the execution window (max and runningCount)
int max = this.ThrottleLimit.Get(context);
if (max < 1) max = int.MaxValue;
int runningCount = 0;
// initialize the value of the completion variable
this.hasCompleted.Set(context, false);
// cache the completion callback
onBodyComplete = new CompletionCallback(OnBodyComplete);
// iterate while there are items available and we didn't exceed the throttle factor
while (runningCount < max && valueEnumerator.Get(context).MoveNext())
{
// increase the running instances counter
runningCount++;
if (this.Body != null)
{
context.ScheduleAction(this.Body, valueEnumerator.Get(context).Current, onBodyComplete);
}
}
}
void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance)
{
if (!this.hasCompleted.Get(context))
{
// get the next child and schedule it!
IEnumerator<T> enumerator = this.valueEnumerator.Get(context);
if (this.valueEnumerator.Get(context).MoveNext())
{
context.ScheduleAction(this.Body, this.valueEnumerator.Get(context).Current, onBodyComplete);
}
}
}
}
}

View file

@ -1,242 +0,0 @@
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
#pragma warning disable 1634, 1691
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Activities;
using System.Management;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Tracing;
using System.IO;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Globalization;
namespace Microsoft.PowerShell.Activities
{
/// <summary>
/// Workflow activity wrapping the Get-Wmiobject cmdlet
/// </summary>
public sealed class GetWmiObject : WmiActivity
{
/// <summary>
/// Sets the default display name of the activity
/// </summary>
public GetWmiObject()
{
this.DisplayName = "Get-WmiObject";
}
/// <summary>
/// Specifies the name of a WMI class. When this parameter is used, the cmdlet
/// retrieves instances of the WMI class.
/// </summary>summary>
[BehaviorCategory]
[DefaultValue(null)]
[OverloadGroup("Class")]
public InArgument<string> Class { get; set; }
/// <summary>
/// Specifies the WMI class property or set of properties to retrieve.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
public InArgument<string[]> Property { get; set; }
/// <summary>
/// Specifies a Where clause to use as a filter. Uses the syntax of the WMI Query Language (WQL).
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[OverloadGroup("Class")]
public InArgument<string> Filter { get; set; }
/// <summary>
/// Specifies a WMI Query Language (WQL) statement to run. Event queries are not supported by this parameter.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[OverloadGroup("Query")]
public InArgument<string> Query { get; set; }
/// <summary>
/// Indicates whether the objects that are returned from WMI should contain amended
/// information. Typically, amended information is localizable information, such as object
/// and property descriptions, that is attached to the WMI object.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
public bool Amended { get; set; }
/// <summary>
/// Specifies whether direct access to the WMI provider is requested for the specified
/// class without any regard to its base class or to its derived classes.
///</summary>
[BehaviorCategory]
[DefaultValue(null)]
public bool DirectRead { get; set; }
/// <summary>
/// Execute the logic for the activity
/// </summary>
/// <param name="context">The native activity context to use in this activity</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell command;
command = GetWmiCommandCore(context, "Get-WmiObject");
if (Class.Get(context) != null)
{
command.AddParameter("Class", Class.Get(context));
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Class", Class.Get(context)));
}
if (Property.Get(context) != null)
{
command.AddParameter("Property", Property.Get(context));
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Property", Property.Get(context)));
}
if (Filter.Get(context) != null)
{
command.AddParameter("Filter", Filter.Get(context));
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Filter", Filter.Get(context)));
}
if (Amended)
{
command.AddParameter("Amended", Amended);
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Amended", Amended));
}
if (DirectRead)
{
command.AddParameter("DirectRead", DirectRead);
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "DirectRead", DirectRead));
}
if (Query.Get(context) != null)
{
command.AddParameter("Query", Query.Get(context));
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Query", Query.Get(context)));
}
return new ActivityImplementationContext() { PowerShellInstance = command };
}
}
/// <summary>
/// Wraps the Invoke-WmiMethod cmdlet
/// </summary>
public sealed class InvokeWmiMethod : WmiActivity
{
/// <summary>
/// Sets the default display name of the activity
/// </summary>
public InvokeWmiMethod()
{
this.DisplayName = "Invoke-WmiMethod";
}
/// <summary>
/// A WMI path specification which should be of the form "Win32_Printer.DeviceID='TestPrinter'"
/// this will select instances of objects on which to call the method.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[OverloadGroup("path")]
public InArgument<string> Path { get; set; }
/// <summary>
/// The name of the WMI class to use for when static methods.
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
[OverloadGroup("class")]
public InArgument<string> Class { get; set; }
/// <summary>
/// THe name of the instance or static method to call
/// </summary>
[BehaviorCategory]
[DefaultValue(null)]
public InArgument<string> Name { get; set; }
/// <summary>
/// The collection of arguments to use when calling the method
/// </summary>
[BehaviorCategory]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is forced by the interaction of PowerShell and Workflow.")]
public InArgument<PSDataCollection<PSObject>> ArgumentList { get; set; }
/// <summary>
/// Implements the logic of this activity
/// </summary>
/// <param name="context">The activity context to refer to</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell command;
command = GetWmiCommandCore(context, "Invoke-WmiMethod");
if (!String.IsNullOrEmpty(Path.Get(context)))
{
command.AddParameter("Path", Path.Get(context));
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Path", Path.Get(context)));
}
if (!String.IsNullOrEmpty(Class.Get(context)))
{
command.AddParameter("Class", Class.Get(context));
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Class", Class.Get(context)));
}
if (!String.IsNullOrEmpty(Name.Get(context)))
{
command.AddParameter("Name", Name.Get(context));
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture,
"PowerShell activity ID={0}: Setting parameter {1} to {2}.",
context.ActivityInstanceId, "Name", Name.Get(context)));
}
if (ArgumentList.Get(context) != null)
{
Collection<PSObject> argCollection = ArgumentList.Get(context).ReadAll();
if (argCollection.Count > 0)
{
command.AddParameter("ArgumentList", argCollection);
Tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture,
"PowerShell activity ID={0}: Setting parameter {1} to '{2}'.",
context.ActivityInstanceId, "ArgumentList", string.Join("','", argCollection)));
}
}
return new ActivityImplementationContext() { PowerShellInstance = command };
}
}
}

View file

@ -1,25 +0,0 @@
using System.Reflection;
using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Diagnostics.CodeAnalysis;
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersionAttribute("3.0.0.0")]
[assembly: System.Resources.NeutralResourcesLanguage("en")]
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VSTS.ActivityTests,PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.PowerShell.Utility.Activities,PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.PowerShell.Management.Activities,PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: AssemblyConfiguration("")]
[assembly: ReliabilityContractAttribute(Consistency.MayCorruptAppDomain, Cer.MayFail)]
[assembly: AssemblyTitle("Microsoft.PowerShell.Activities")]
[assembly: AssemblyDescription("Microsoft.PowerShell.Activities")]
[module: SuppressMessage("Microsoft.Design", "CA1014:MarkAssembliesWithClsCompliant")]
[module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope="resource", Target="ActivityResources.resources", MessageId="InlineScript")]
[module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope="resource", Target="ActivityResources.resources", MessageId="inlinescript")]
[module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope="resource", Target="ActivityResources.resources", MessageId="foreach")]

View file

@ -1,38 +0,0 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<sap:ActivityDesigner
x:Class="Microsoft.PowerShell.Activities.InlineScriptDesigner"
Collapsible="True"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:conv="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
xmlns:sap="clr-namespace:System.Activities.Presentation"
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="128" d:DesignWidth="463">
<sap:ActivityDesigner.Resources>
<DataTemplate x:Key="Collapsed">
<StackPanel>
<TextBlock>This is the collapsed view</TextBlock>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="Expanded">
<TextBox x:Uid="TextBox_1" Text="{Binding Path=ModelItem.Command, Mode=TwoWay}"
TextWrapping="WrapWithOverflow" AcceptsReturn="True" MinLines="4"
Background="{x:Null}" Margin="3" DockPanel.Dock="Bottom" Height="97" Width="488" />
</DataTemplate>
<Style x:Key="ExpandOrCollapsedStyle" TargetType="{x:Type ContentPresenter}">
<Setter Property="ContentTemplate" Value="{DynamicResource Collapsed}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=ShowExpanded}" Value="true">
<Setter Property="ContentTemplate" Value="{DynamicResource Expanded}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</sap:ActivityDesigner.Resources>
<DockPanel x:Uid="DockPanel_1" LastChildFill="True">
<ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}" />
</DockPanel>
</sap:ActivityDesigner>

View file

@ -1,37 +0,0 @@
<swd:ActivityDesigner x:Class="Microsoft.PowerShell.Activities.PipelineDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:swd="clr-namespace:System.Activities.Presentation">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="40*"/>
</Grid.RowDefinitions>
<swd:WorkflowItemsPresenter Items="{Binding Path=ModelItem.Activities}"
HintText="Insert Activities Here" >
<swd:WorkflowItemsPresenter.SpacerTemplate>
<DataTemplate>
<DockPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5">
<Polygon
Points="25,12 35,25 45,12 25,12"
Stroke="DarkBlue"
StrokeThickness="2">
<Polygon.Fill>
<SolidColorBrush Color="LightBlue" Opacity="0.4"/>
</Polygon.Fill>
</Polygon>
</DockPanel>
</DataTemplate>
</swd:WorkflowItemsPresenter.SpacerTemplate>
<swd:WorkflowItemsPresenter.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" />
</ItemsPanelTemplate>
</swd:WorkflowItemsPresenter.ItemsPanel>
</swd:WorkflowItemsPresenter>
</Grid>
</swd:ActivityDesigner>

View file

@ -1,561 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="https://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ActivityNameConflict" xml:space="preserve">
<value>Cannot generate activity. The name '{0}' is reserved.</value>
</data>
<data name="ActivityNameNotFound" xml:space="preserve">
<value>Cannot generate activity. The command name '{0}' could not be found in the default runspace. Use the GenerateFromCommandInfo method to generate activities for non-default commands.</value>
<comment>GenerateFromCommandInfo should not be localized. It is the name of a method.</comment>
</data>
<data name="ActivityParameterGroup" xml:space="preserve">
<value>Activity-Specific Parameters</value>
</data>
<data name="CannotSpecifyBothCommandAndCommandName" xml:space="preserve">
<value>'Command' is mutually exclusive with 'CommandName'. Either specify 'CommandName' (optionally with 'Parameters'), or 'Command'.</value>
<comment>Command, CommandName and Parameters should not be localized. These are parameters.</comment>
</data>
<data name="CannotSupplyUriAndComputername" xml:space="preserve">
<value>Cannot supply both connection URI and computer name.</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Xml_cmdletsOverObjectsXsd" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\..\src\cimSupport\cmdletization\xml\cmdlets-over-objects.xsd;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<comment>{Locked}</comment>
</data>
<data name="EnumWriter_InvalidEnumName" xml:space="preserve">
<value>The value of the EnumName attribute does not translate to a valid C# identifier: {0}. Verify the EnumName attribute in Cmdlet Definition XML, and then try again.</value>
<comment>{StrContains="EnumName"}</comment>
</data>
<data name="EnumWriter_InvalidValueName" xml:space="preserve">
<value>The value of the Name attribute is not a valid C# identifier: {0}. Verify the Name attribute in Cmdlet Definition XML and try again.</value>
<comment>{StrContains="Enum"} {StrContains="Value"} {StrContains="Name"}</comment>
</data>
<data name="CommandNameRequired" xml:space="preserve">
<value>A command name is required.</value>
</data>
<data name="ComputerNameNotValid" xml:space="preserve">
<value>The computer name {0} is not valid. If you are trying to supply a Uri, use the Uri parameter.</value>
</data>
<data name="ConnectivityGroup" xml:space="preserve">
<value>Connectivity</value>
</data>
<data name="DependModuleImportFailed" xml:space="preserve">
<value>Windows PowerShell Workflow cannot continue running the activity because an error occurred while importing dependent module(s) '{0}' specified for activity '{1}'. To fix this problem, make sure that the module exists on the computer. If it is not required, remove references to the module from the activity.</value>
</data>
<data name="DuplicateInputDefinedInPipeline" xml:space="preserve">
<value>Input is defined in Pipeline variable and in the first child activity. Input should be defined only at one place.</value>
</data>
<data name="DuplicateResultDefinedInPipeline" xml:space="preserve">
<value>Result is defined in Pipeline variable and in the last child activity. Result should be defined at one place.</value>
</data>
<data name="ImportLocalizedDataWithEmptyEmptyorNullBaseDirectory" xml:space="preserve">
<value>Cannot have an empty BaseDirectory for importing localized data. Please specify a valid BaseDirectory and run the command again.</value>
<comment>BaseDirectory should not be localized. This is a parameter.</comment>
</data>
<data name="InputAndOutputGroup" xml:space="preserve">
<value>Input and Output</value>
</data>
<data name="InputRequired" xml:space="preserve">
<value>The input parameter is required.</value>
</data>
<data name="LocalAndRemoteNodesCannotBeTogetherForRestartComputerActivity" xml:space="preserve">
<value>Restart-Computer activity cannot be run because both localhost and managed nodes are provided in the ComputerName parameter. For this scenario please run Restart-Computer activity for managed nodes followed by another Restart-Computer activity for localhost.</value>
<comment>Restart-Computer and ComputerName should not be localized. These are a command and parameter.</comment>
</data>
<data name="NoChildPipeline" xml:space="preserve">
<value>Pipeline activity works with at least one child activity.</value>
</data>
<data name="NullArgumentExpression" xml:space="preserve">
<value>The following argument can not be null or empty: Expression</value>
</data>
<data name="NullReturnedAfterExpressionEvaluation" xml:space="preserve">
<value>The result of Windows PowerShell expression evaluation is null or nothing</value>
</data>
<data name="ProgressPositionMessage" xml:space="preserve">
<value> {0} line:{1} char:{2}</value>
</data>
<data name="RestartComputerWithWaitNotAllowed" xml:space="preserve">
<value>Parameter 'Wait' cannot be used for Restart-Computer activity when the localhost is being restarted.</value>
<comment>Wait and Restart-Computer should not be localized. These are a parameter and command.</comment>
</data>
<data name="RunningTimeExceeded" xml:space="preserve">
<value>The activity has exceeded the specified maximum running time of {0} seconds.</value>
</data>
<data name="ActivityNameConflict1" xml:space="preserve">
<value>Cannot generate activity. The name '{0}' is reserved.</value>
</data>
<data name="ActivityNameNotFound1" xml:space="preserve">
<value>Cannot generate activity. The command name '{0}' could not be found in the default runspace. Use the GenerateFromCommandInfo method to generate activities for non-default commands.</value>
<comment>GenerateFromCommandInfo should not be localized. It is the name of a method.</comment>
</data>
<data name="AmbiguousCommand" xml:space="preserve">
<value>The command name '{0}' is ambiguous and cannot be processed. To use this command, specify a module qualified name such as: 'Microsoft.PowerShell.Management\Get-Process'.</value>
<comment>Microsoft.PowerShell.Management\Get-Process should not be localized. It is the qualified command name.</comment>
</data>
<data name="AssignmentNotSupported" xml:space="preserve">
<value>This type of assignment is not supported. Only variable names (i.e.: $variable) may be used as the target of an assignment statement.</value>
</data>
<data name="AttributedExpressionNotSupported" xml:space="preserve">
<value>Attributed expression (i.e.: [Parameter()]$x) should be used only when declaring parameters for the script workflow.</value>
<comment>Parameter() should not be localized. This is syntax.</comment>
</data>
<data name="BeginProcessNotSupported" xml:space="preserve">
<value>Begin, Process, and End statements are not supported in a Windows PowerShell Workflow.</value>
<comment>Begin, Process, and End should not be localized. These are syntax.</comment>
</data>
<data name="BreakContinueNotSupported" xml:space="preserve">
<value>Break and Continue statements are not supported in a Windows PowerShell Workflow. Instead, use an 'if' statement to control loop execution.</value>
<comment>Break and Continue and 'if' should not be localized. These are syntax.</comment>
</data>
<data name="CannotAssignStartSleepToVariable" xml:space="preserve">
<value>Cannot assign Start-Sleep to a variable. Start-Sleep generates no output.</value>
<comment>Start-Sleep should not be localized. This is a command name.</comment>
</data>
<data name="CannotMergeErrorToOutput" xml:space="preserve">
<value>Cannot redirect the error stream to the output stream. The target activity '{0}' does not contain the property 'MergeErrorToOutput'.</value>
<comment>MergeErrorToOutput should not be localized. It is a property.</comment>
</data>
<data name="CannotProcessMoreThanOneScriptBlock" xml:space="preserve">
<value>Cannot process more than one script block.</value>
</data>
<data name="CannotRedirectErrorStreamForNewObject" xml:space="preserve">
<value>Cannot redirect error stream for the New-Object activity.</value>
<comment>New-Object should not be localized. This is a command name.</comment>
</data>
<data name="CannotRedirectErrorStreamForStartSleep" xml:space="preserve">
<value>Cannot redirect error stream for the delay activity. Please remove the stream redirection from this activity and try again.</value>
</data>
<data name="ActivityDoesNotContainResultProperty" xml:space="preserve">
<value>Cannot assign the output of the '{1}' activity. It does not contain the 'Result' property. If this is a workflow that calls another workflow, implement a Result property as a [ref] parameter.</value>
<comment>Result should not be localized. It is the name of a property.</comment>
</data>
<data name="CannotSpecifyBothCommandAndCommandName1" xml:space="preserve">
<value>'Command' is mutually exclusive with 'CommandName'. Either specify 'CommandName' (optionally with 'Parameters'), or 'Command'.</value>
<comment>Command, CommandName and Parameters should not be localized. These are parameters.</comment>
</data>
<data name="CannotSpecifyResultArgument" xml:space="preserve">
<value>Assigning values to the Result argument is not supported. To store the output of a command, assign it to a variable. For example: $output = Get-Process.</value>
<comment>$output = Get-Process should not be localized. This is syntax and command name. Result should not be localized. It is a parameter.</comment>
</data>
<data name="CannotStoreResultsInUnsupportedElement" xml:space="preserve">
<value>Cannot store the results of this type of expression into a variable. Only the results of commands, pipelines, constant expressions, foreach statements, parallel and sequence statements can be stored in variables.</value>
</data>
<data name="CannotStoreResultsInVariable" xml:space="preserve">
<value>Cannot store results in the variable '{0}'. Results are already being collected in the variable '{1}'.</value>
</data>
<data name="CannotUseDataCollectingVariable" xml:space="preserve">
<value>The variable with name '{0}' is defined to store results from a parallel or sequence block. Therefore, it cannot be reused inside such blocks.</value>
</data>
<data name="CommandActivityExcluded" xml:space="preserve">
<value>Cannot call the '{0}' command. Other commands from this module have been packaged as workflow activities, but this command was specifically excluded. This is likely because the command requires an interactive Windows PowerShell session, or has behavior not suited for workflows. To run this command anyway, place it within an inline-script (InlineScript {{ {0} }}) where it will be invoked in isolation.</value>
<comment>InlineScript should not be localized. This is syntax.</comment>
</data>
<data name="CommandNameRequired1" xml:space="preserve">
<value>A command name is required.</value>
</data>
<data name="CommonParameterNotSupported" xml:space="preserve">
<value>Could not find a parameter named '{0}' for the '{1}' command. Windows PowerShell common parameters such as WhatIf and OutVariable are not supported.</value>
<comment>WhatIf and OutVariable should not be localized. These are parameter names.</comment>
</data>
<data name="ComputerNameNotValid1" xml:space="preserve">
<value>The computer name {0} is not valid. If you are trying to supply a Uri, use the Uri parameter.</value>
</data>
<data name="ConditionsCannotHaveSideEffects" xml:space="preserve">
<value>In a Windows PowerShell Workflow, loop conditions that modify variables are not supported. To change a variable, place the modification statement in the loop body itself.</value>
</data>
<data name="CouldNotFindParameterName" xml:space="preserve">
<value>Could not find a parameter named '{0}'. Supported parameters are: {1}.</value>
</data>
<data name="CouldNotFindParameterNameNested" xml:space="preserve">
<value>Could not find a parameter named '{0}'. Workflow-common parameters such as PSComputerName are not supported in nested workflows that already have nested workflows.</value>
<comment>PSComputerName should not be localized. This is a parameter.</comment>
</data>
<data name="CouldNotFindParameterNameShadowedActivity" xml:space="preserve">
<value>Could not find a parameter named '{0}'. Note that this activity has the same name as a Windows PowerShell cmdlet, but different parameters. Supported parameters are: {1}.</value>
</data>
<data name="CouldNotLoadRequiredAssembly" xml:space="preserve">
<value>Could not load assembly '{0}' specified in the list of required assemblies.</value>
</data>
<data name="AlternateInvocationNotSupported" xml:space="preserve">
<value>Dot-sourcing (. &lt;command&gt;) and the invocation operator (&amp; &lt;command&gt;) are not supported in a Windows PowerShell Workflow. Wrap this command invocation into an inlinescript { } instead.</value>
</data>
<data name="DuplicateInputDefinedInPipeline1" xml:space="preserve">
<value>Input is defined in the Pipeline activity and in the first child activity. Input should be defined in only one place.</value>
</data>
<data name="DuplicateResultDefinedInPipeline1" xml:space="preserve">
<value>The result is defined in the Pipeline variable, and in the last child activity. The result should be defined in only one place.</value>
</data>
<data name="DynamicParametersNotSupported" xml:space="preserve">
<value>Dynamic parameters are not supported in a Windows PowerShell Workflow.</value>
</data>
<data name="EnumWriter_InvalidEnumName1" xml:space="preserve">
<value>The value of the EnumName attribute doesn't translate to a valid C# identifier: {0}. Verify the EnumName attribute in Cmdlet Definition XML and try again.</value>
<comment>{StrContains="EnumName"}</comment>
</data>
<data name="EnumWriter_InvalidValueName1" xml:space="preserve">
<value>The value of the Name attribute is not a valid C# identifier: {0}. Verify the Name attribute in Cmdlet Definition XML and try again.</value>
<comment>{StrContains="Enum"} {StrContains="Value"} {StrContains="Name"}</comment>
</data>
<data name="EnvironmentVariableAssignmentNotSupported" xml:space="preserve">
<value>In a Windows PowerShell Workflow, assignment to environment variables is not supported.</value>
</data>
<data name="ImportLocalizedDataWithEmptyEmptyorNullBaseDirectory1" xml:space="preserve">
<value>Cannot have an empty BaseDirectory for importing localized data. Please specify a valid BaseDirectory and run the command again.</value>
<comment>BaseDirectory should not be localized. This is a parameter.</comment>
</data>
<data name="InlineScriptSyntax" xml:space="preserve">
<value>In a Windows PowerShell Workflow, the syntax for the InlineScript activity is "InlineScript { &lt;commands&gt; }".</value>
<comment>InlineScript should not be localized. This is syntax.</comment>
</data>
<data name="InputRequired1" xml:space="preserve">
<value>The input parameter is required.</value>
</data>
<data name="InvalidMemberName" xml:space="preserve">
<value>{0} is not a valid parameter or variable name. Names must start with a letter, and contain only letters, digits, '-', and '_'.</value>
</data>
<data name="InvalidScopePrefixInWorkflow" xml:space="preserve">
<value>A variable scope prefix that is not valid was detected. The only valid scope prefix in the script workflow is "$WORKFLOW:".</value>
<comment>$WORKFLOW should not be localized. This is syntax.</comment>
</data>
<data name="InvokeExpressionSyntax" xml:space="preserve">
<value>In a Windows PowerShell Workflow, the syntax for Invoke-Expression is: "Invoke-Expression -Language XAML -Command &lt;string&gt;".</value>
<comment>Invoke-Expression -Language XAML -Command should not be localized. This is syntax.</comment>
</data>
<data name="LocalAndRemoteNodesCannotBeTogetherForRestartComputerActivity1" xml:space="preserve">
<value>The Restart-Computer activity cannot run because both localhost and remote computers are provided in the ComputerName parameter. For this scenario, run the Restart-Computer activity for remote computers first, followed by another Restart-Computer activity for localhost.</value>
<comment>Restart-Computer and ComputerName should not be localized. These are a command and parameter.</comment>
</data>
<data name="LoopLabelNotSupported" xml:space="preserve">
<value>Loop labels are not supported in a Windows PowerShell Workflow.</value>
</data>
<data name="MethodInvocationNotSupported" xml:space="preserve">
<value>Method invocation is not supported in a Windows PowerShell Workflow. To use .NET scripting, place your commands in an inline script: InlineScript { &lt;commands&gt; }.</value>
</data>
<data name="MustUseXamlLanguage" xml:space="preserve">
<value>Invoke-Expression must use "-Language XAML" in a Windows PowerShell Workflow.</value>
<comment>Invoke-Expression and -Language XAML should not be localized. These are syntax.</comment>
</data>
<data name="NewObjectCouldNotFindType" xml:space="preserve">
<value>Could not find type {0}. Load the type(s) and try again.</value>
</data>
<data name="NewObjectSyntax" xml:space="preserve">
<value>In a Windows PowerShell Workflow, the syntax for New-Object is: "New-Object -TypeName &lt;TypeName&gt;".</value>
<comment>New-Object and -TypeName &lt;TypeName&gt; should not be localized. This is syntax.</comment>
</data>
<data name="NoChildPipeline1" xml:space="preserve">
<value>A pipeline activity must have at least one child activity.</value>
</data>
<data name="NullArgumentExpression1" xml:space="preserve">
<value>The following argument cannot be null or empty: Expression</value>
</data>
<data name="NullReturnedAfterExpressionEvaluation1" xml:space="preserve">
<value>The result of Windows PowerShell expression evaluation is null or nothing.</value>
</data>
<data name="OnlyOneRequiresStatement" xml:space="preserve">
<value>You can provide only one #requires statement per script.</value>
</data>
<data name="OnlySimpleVariableReferencesSupportedInUnary" xml:space="preserve">
<value>Only simple variable references (i.e.: $x) and number constants are supported in a unary expression.</value>
</data>
<data name="OnlySupportErrorStreamRedirection" xml:space="preserve">
<value>Only the merging redirection from the error stream to the output stream is supported.</value>
</data>
<data name="OperatorRequiresVariable" xml:space="preserve">
<value>Unary operators '++' and '--' work only on variables in the script workflow.</value>
</data>
<data name="ParallelSequenceScriptBlockSyntax" xml:space="preserve">
<value>The syntax of a {0} script block is '{0} { &lt;commands&gt; }'.</value>
</data>
<data name="ParameterValidationNotSupportedOnNestedWorkflows" xml:space="preserve">
<value>Advanced parameter validation is not supported on nested workflows.</value>
</data>
<data name="PositionalParametersNotSupported" xml:space="preserve">
<value>Positional parameters are not supported in a Windows PowerShell Workflow. To invoke this command, use explicit parameter names with all values. For example: "Command -Parameter &lt;value&gt;".</value>
</data>
<data name="RestartComputerWithWaitNotAllowed1" xml:space="preserve">
<value>Parameter 'Wait' cannot be used for Restart-Computer activity when the localhost is being restarted.</value>
<comment>Wait and Restart-Computer should not be localized. These are a parameter and command.</comment>
</data>
<data name="ScriptBlockInvocationNotSupported" xml:space="preserve">
<value>Script block invocation is not supported in a Windows PowerShell Workflow. To run a set of commands in a similar way as the script block invocation, place your commands in an inline script: InlineScript { &lt;commands&gt; }.</value>
<comment>InlineScript should not be localized. This is syntax.</comment>
</data>
<data name="StartSleepSyntax" xml:space="preserve">
<value>In a Windows PowerShell Workflow, the syntax for Start-Sleep is: "Start-Sleep -Seconds &lt;int&gt;" or "Start-Sleep -Milliseconds &lt;int&gt;".</value>
<comment>Start-Sleep, -Seconds and -Milliseconds should not be localized. These are a command and parameter names.</comment>
</data>
<data name="SubExpressionNotSupported" xml:space="preserve">
<value>Sub expression (i.e.: $($x)) should only be used as the parameter value in a Windows PowerShell Workflow. To use .NET scripting, place your commands in an inline script: InlineScript { &lt;commands&gt; }.</value>
<comment>InlineScript should not be localized. This is syntax.</comment>
</data>
<data name="SwitchCaseSensitive" xml:space="preserve">
<value>Case-insensitive switch statements are not supported in a Windows PowerShell Workflow. Supply the -CaseSensitive flag, and ensure that case clauses are written appropriately. To write a case-insensitive case statement, first convert the input to either uppercase or lowercase, and update the case clauses to match.</value>
</data>
<data name="SwitchClauseMustBeOfSameType" xml:space="preserve">
<value>Switch clauses must all be of the same type in a Windows PowerShell Workflow, or the condition expression must be strongly typed.</value>
</data>
<data name="SwitchFlagNotSupported" xml:space="preserve">
<value>In a Windows PowerShell Workflow, the switch statement supports only the 'CaseSensitive' flag.</value>
<comment>CaseSensitive should not be localized, this is a flag.</comment>
</data>
<data name="SwitchOnlySupportsConstantExpression" xml:space="preserve">
<value>Only constant expressions are supported as switch clauses in a Windows PowerShell Workflow.</value>
</data>
<data name="TrapNotSupported" xml:space="preserve">
<value>Trap statements are not supported in a Windows PowerShell Workflow. Instead, use try, catch, or finally.</value>
</data>
<data name="TypeFromDynamicAssembly" xml:space="preserve">
<value>Cannot create workflow. It depends on the type, '{0}', which was generated dynamically.</value>
</data>
<data name="VariableAlreadyDefined" xml:space="preserve">
<value>Cannot define variable. A variable with name '{0}' has already been defined. To reference a variable from the top-level scope of this workflow, use the syntax: '$WORKFLOW:{0}'.</value>
<comment>$WORKFLOW should not be localized. This is syntax.</comment>
</data>
<data name="CheckpointWorkflowSyntax" xml:space="preserve">
<value>The Checkpoint-Workflow command accepts no parameters.</value>
<comment>Checkpoint-Workflow should not be localized. This is a command name.</comment>
</data>
<data name="SuspendWorkflowSyntax" xml:space="preserve">
<value>The Suspend-Workflow command accepts only one optional parameter, the syntax for Suspend-Workflow is: "Suspend-Workflow [-Label &lt;string&gt;]".</value>
<comment>Suspend-Workflow should not be localized. This is a command name.</comment>
</data>
<data name="AmbiguousPropertiesFound" xml:space="preserve">
<value>Ambiguous properties are found for the property name '{0}'.</value>
</data>
<data name="GenericParameterTypeNotFound" xml:space="preserve">
<value>The generic parameter type '{0}' for the parameter '{1}' cannot be resolved.</value>
</data>
<data name="MissingValueForParameter" xml:space="preserve">
<value>The value for the parameter '{0}' is not specified. To invoke this command, use explicit parameter names with all values. For example: "Command -Parameter &lt;value&gt;".</value>
</data>
<data name="AmbiguousParameter" xml:space="preserve">
<value>The parameter cannot be processed because the parameter name '{0}' is ambiguous. Possible matches include: {1}.</value>
</data>
<data name="DataSectionNotSupported" xml:space="preserve">
<value>Data sections are not supported in a Windows PowerShell Workflow.</value>
</data>
<data name="ReasonRequiredInThrowStatement" xml:space="preserve">
<value>The throw statement requires a reason.</value>
</data>
<data name="SwitchEnumerationNotSupported" xml:space="preserve">
<value>In a Windows PowerShell Workflow, switch statements support only expressions that return a single element.</value>
</data>
<data name="ConditionsCannotInvokeActivities" xml:space="preserve">
<value>In a Windows PowerShell Workflow, loop conditions that invoke activities are not supported. Conditions can use only variable references, and Windows PowerShell language elements that interact with those variables.</value>
</data>
<data name="ThrowStatementCannotInvokeActivities" xml:space="preserve">
<value>In a Windows PowerShell Workflow, throw statements that invoke activities (other than New-Object) are not supported. Throw statements can use only strings, variable references, and Windows PowerShell language elements.</value>
<comment>New-Object should not be localized. This is a command name.</comment>
</data>
<data name="MustSupplyVariableReferenceForInOutArgument" xml:space="preserve">
<value>Parameter '{0}' is defined as an InOutArgument or OutArgument and can accept only variable references.</value>
<comment>InOutArgument and OutArgument should not be localized.</comment>
</data>
<data name="CannotUseWorkflowPrefixInInlineScript" xml:space="preserve">
<value>The scope prefix "$WORKFLOW:" cannot be used in an InlineScript activity. To reference a workflow variable in an InlineScript activity, use the prefix "$USING:" instead. Workflow variables cannot be modified from an InlineScript activity. To change a workflow variable, assign the output of the InlineScript activity to that variable.</value>
<comment>$USING and $WORKFLOW and InlineScript should not be localized. These are syntax.</comment>
</data>
<data name="ActivityNotSupportedInPipeline" xml:space="preserve">
<value>The '{0}' activity is not supported in a workflow pipeline.</value>
</data>
<data name="CommandHandledByKeyword" xml:space="preserve">
<value>The '{0}' command is handled by the built-in '{1}' keyword. Use the built-in keyword instead.</value>
</data>
<data name="OnlySimpleParameterDefaultsSupported" xml:space="preserve">
<value>In a Windows PowerShell Workflow, parameter defaults may only be simple value types (such as integers) and strings. In addition, the type of the default value must match the type of the parameter.</value>
</data>
<data name="NewObjectMustBeAssigned" xml:space="preserve">
<value>The output of the New-Object cmdlet must be assigned to a variable.</value>
<comment>New-Object should not be localized. This is a command.</comment>
</data>
<data name="CommandNotFound" xml:space="preserve">
<value>Cannot find the '{0}' command. If this command is defined as a workflow, ensure it is defined before the workflow that calls it. If it is a command intended to run directly within Windows PowerShell (or is not available on this system), place it in an InlineScript: 'InlineScript {{ {0} }}'</value>
<comment>InlineScript should not be localized. This is syntax.</comment>
</data>
<data name="VariableNameReserved" xml:space="preserve">
<value>The value of the variable '{0}' can only be changed using the Set-PSWorkflowData activity.</value>
<comment>Set-PSWorkflowData should not be localized. This is a command name.</comment>
</data>
<data name="VariableNameReadOnly" xml:space="preserve">
<value>The variable '{0}' is read-only.</value>
</data>
<data name="CannotLaunchFormat" xml:space="preserve">
<value>Cannot start "{0}". Interactive console applications are not supported in a Windows PowerShell Workflow. To run the application, use the Start-Process cmdlet.</value>
</data>
<data name="DuplicateParametersNotAllowed" xml:space="preserve">
<value>Cannot bind parameter because parameter '{0}' is specified more than once. To provide multiple values to parameters that can accept multiple values, use the array syntax. For example, "-parameter value1,value2,value3".</value>
</data>
<data name="InvalidRootWorkflowName" xml:space="preserve">
<value>rootWorkflowName '{0}' is invalid. Make sure it exists in the context.</value>
</data>
<data name="RemotingHandledByPSComputerName" xml:space="preserve">
<value>Could not find a parameter named 'ComputerName'. Remote connectivity in this command is handled by the 'PSComputerName' parameter.</value>
</data>
<data name="WorkflowScopeOnlyValidInParallelOrSequenceBlock" xml:space="preserve">
<value>Cannot define variable. Scope names are only valid in a parallel or sequence block. Within a parallel or sequence block, the only valid scope name is 'workflow'.</value>
</data>
<data name="PropertyDoesNotSupportPowerShellLanguage" xml:space="preserve">
<value>The '{0}' property does not support elements from the Windows PowerShell language such as parentheses and variables. To use this value, enclose it in a single-quoted string.</value>
</data>
<data name="InvalidCmdletBindingAttribute" xml:space="preserve">
<value>In a Windows PowerShell Workflow, the CmdletBinding attribute only supports the following values: "DefaultParameterSetName, ConfirmImpact, HelpUri, PositionalBinding".</value>
</data>
<data name="FunctionRedefinitionNotAllowed" xml:space="preserve">
<value>The function or workflow '{0}' cannot be redefined.</value>
</data>
<data name="SessionStateEntryNotSupported" xml:space="preserve">
<value>The session state entry type '{0}' is not supported.</value>
</data>
<data name="RecursiveWorkflowNotSupported" xml:space="preserve">
<value>A workflow cannot use recursion.</value>
</data>
<data name="VariableNotSupportedInWorkflow" xml:space="preserve">
<value>The variable '{0}' cannot be used in a script workflow.</value>
</data>
<data name="InlineXamlNotSupported" xml:space="preserve">
<value>Cannot create workflow. Inline XAML is not supported in this language mode.</value>
</data>
<data name="GenericPropertyTypeNotResolved" xml:space="preserve">
<value>The generic type '{0}' cannot be resolved for the parameter '{1}'.</value>
</data>
<data name="EntirePipelineMustUseForeachSequence" xml:space="preserve">
<value>Cannot define pipeline. Once a pipeline uses the Sequence parameter of the Foreach-Object or Where-Object cmdlets, all remaining commands must also be either the Foreach-Object or Where-Object cmdlet with the Sequence parameter.</value>
<comment>Sequence, Foreach-Object, and Where-Object should not be localized. They are command and parameter names.</comment>
</data>
<data name="InvalidForeachSequenceParameter" xml:space="preserve">
<value>Cannot call command. When used with the 'Sequence' parameter, the Foreach-Object cmdlet supports only the 'PipelineVariable', 'Begin', 'Sequence', and 'End' parameters.</value>
<comment>Sequence, PipelineVariable, Begin, End, and Foreach-Object should not be localized. These are a parameter and command.</comment>
</data>
<data name="InvalidForeachSequencePipelinePosition" xml:space="preserve">
<value>Cannot create pipeline. The Foreach-Object cmdlet with the -Sequence parameter cannot be used as the first element of a pipeline.</value>
<comment>Foreach-Object should not be localized, or -Sequence. They are cmdlet and parameter names.</comment>
</data>
<data name="CannotNestIterativePipeline" xml:space="preserve">
<value>Cannot define pipeline. An iterative pipeline may not be nested within another iterative pipeline.</value>
</data>
<data name="InvalidWhereSequenceParameter" xml:space="preserve">
<value>Cannot call command. When used with the 'Sequence' parameter, the Where-Object cmdlet supports only the 'PipelineVariable' and 'Sequence' parameters.</value>
<comment>Sequence, PipelineVariable, and Where-Object should not be localized. These are a parameters and command.</comment>
</data>
<data name="InvalidWhereSequencePipelinePosition" xml:space="preserve">
<value>Cannot create pipeline. The Where-Object cmdlet with the -Sequence parameter cannot be used as the first element of a pipeline.</value>
<comment>Sequence and Where-Object should not be localized. These are a parameters and command.</comment>
</data>
</root>