Q. In a PowerShell workflow how can I load assemblies for certain actions?

Q. In a PowerShell workflow how can I load assemblies for certain actions?

Q. In a PowerShell workflow how can I load assemblies for certain actions?

 

A. In regular PowerShell assemblies can be loaded using Add-Type or [Reflection.Assembly]::LoadWithPartialName(<assembley>) however this is not legal in a PowerShell workflow. Instead you need to use a section of InlineScript and contain the assembly load and usage within it. For example:

 $NewPassword = InlineScript {
    Add-Type -AssemblyName System.Web
    [System.Web.Security.Membership]::GeneratePassword(16,2)

}

Note the code in the InlineScript outputs a value which I then save into a variable on the outside of the InlineScript section.

Here's more information and tips on using variables when using InlineScript can be found.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish