0

Hi guys,

I have some C# code in my Powershell script and in that code I have a global variable.

How can I access my variable from the powershell code ?

$source = @'

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;



public partial class Form1 : Form
{
    Object nodes2 = new Object();
}
'@ 


$assemblies = ('System.Windows.Forms','System.Drawing','PresentationCore','WindowsBase','System.Xml')

try
{
    Add-Type -TypeDefinition $source -ReferencedAssemblies $assemblies -ErrorAction STOP

    (New-Object Form1).Showdialog() | Out-Null
}
catch
{
    Write-Warning "An error occurred attempting to add the .NET Framework class to the PowerShell session."
    Write-Warning "The error was: $($Error[0].Exception.Message)"
}

How can I access nodes2 from PS script ?

2
Contributors
1
Reply
22
Views
3 Years
Discussion Span
Last Post by BogdanCov
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.