Kelly Garcia
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:
2nd function:
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
}
} )
2nd function:
$Migrate.Add_Click({
[System.Windows.MessageBox]::Show("$m")
})
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.