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 ?

where is the global variable? :/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.