Link to home
Start Free TrialLog in
Avatar of Kelly Garcia
Kelly GarciaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

global Variable - 2 functions in powershell

Hi All,

I have two functions one which sets a global variable and the other with calls the global variable. however the second function do not recognise the global variable, please help!

1st function:

$Window.FindName("SelectMailbox").Add_Click( {
    param (
        [Object]$Sender,

        [System.Windows.RoutedEventArgs]$EventArgs
    )

    $ListView = $Sender.FindName('MailboxesList')
    
    if ($null -ne $ListView.SelectedItems) {
        $ListView.ItemsSource = @($ListView.SelectedItems | Select-Object DisplayName, TotalItemSize, ItemCount, Database, TotalDeletedItemSize,DeletedItemCount, LastLoggedOnUserAccount, LastLogonTime, LastLogoffTime -OutVariable mailboxtomigrate)
		$m = $mailboxtomigrate | select DisplayName | Out-String
		Set-Variable -Name $m -Scope Global
		
    }
} )

Open in new window


2nd function:

$Migrate.Add_Click({


[System.Windows.MessageBox]::Show("$m")

})

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial