Skip to content

Instantly share code, notes, and snippets.

function TestRegex {
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true,Position=0)]
[string]$Line,
[Parameter(mandatory=$true,Position=1)]
[regex]$Regex
)
VERBOSE: Loading module from path 'C:\_strap\poweralto2\poweralto2.psm1'.
Add-Type : (0) : Source file 'C:\Windows\TEMP\e5ntpd5d.0.cs' could not be found
(1) : using System;
At C:\_strap\poweralto2\poweralto2.psm1:1 char:1
+ Add-Type -ReferencedAssemblies @(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (error CS2001: S...ld not be found:
CompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.
AddTypeCommand
Add-Type -ReferencedAssemblies @(
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml")).Location,
([System.Reflection.Assembly]::LoadWithPartialName("System.Web")).Location,
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")).Location
) -TypeDefinition @'
using System;
using System.Xml;
using System.Xml.Linq;
using System.Web;
using System.Text.RegularExpressions;
VERBOSE: Loading module from path 'C:\_strap\poweralto2\poweralto2.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\_strap\poweralto2\PowerAlto2.dll'.
VERBOSE: Loading module from path 'C:\_strap\poweralto2\PowerAlto2.psm1'.
Add-Type : (0) : Source file 'C:\Windows\TEMP\vl5ovzf4.0.cs' could not be found
(1) : using System.Text.RegularExpressions;
At C:\_strap\poweralto2\PowerAlto2.psm1:13 char:1
+ Add-Type -ReferencedAssemblies @(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (error CS2001: S...ld not be found:CompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
###############################################################################
## Custom Objects Create in C-Sharp
###############################################################################
$TargetDllPath = (Split-Path -parent $MyInvocation.MyCommand.Path) + "\PowerAlto2.dll"
$TestPath = (Split-Path -parent $MyInvocation.MyCommand.Path) + "\test.cs"
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml")).Location
([System.Reflection.Assembly]::LoadWithPartialName("PowerAlto2")).Location
###############################################################################