Hello,
I tried searching through the forums and Google, but could not find what I wanted, but if someone knows of a thread/article, please post!
Problem: In Powershell Studio 2012, I would like to set a global variable, so that it passes along the information from each button to the next.
Scenario: My first button would grab the user's information and then the second button will use that information to do other things
$buttonGetInfo_Click = { $UserInfo = Get-QADUser user $Firstname = UserInfo.Firstname $Lastname = UserInfo.Lastname } $buttonDoSomething_Click = { [System.Windows.Forms.MessageBox]::Show("$Firstname $Lastname")
}
What I've tried:
1. I think that it would all work if I rename each variable to $global:Firstname, $global:Lastname, etc... but that's a hassle
2. I tried putting
Set-Variable -Name Firstname -Scope Global
and also tried:
New-Variable -Name Firstname -Scope Global
Is there a way to do this so I don't have to type in "$global:..." each time?
Thanks!