Kelly Garcia
asked on
store items in variable - Powershell
Hi All,
I have this line of code in my script:
the selected can be many. I need to store it in a variable so I can loop through it when I run the new-moverequest script.
so I need the display names to be stored as a string in the variable e.g. $mailboxtomigrate = "display name 1", "display name 2", "display name 3"
how do I do this?
is better if I out the results into an array? how do I do this?
thank you in advance
I have this line of code in my script:
if ($null -ne $ListView.SelectedItems) {
$ListView.ItemsSource = @($ListView.SelectedItems | Select-Object DisplayName, TotalItemSize, ItemCount, Database, TotalDeletedItemSize,DeletedItemCount, LastLoggedOnUserAccount, LastLogonTime, LastLogoffTime -OutVariable $mailboxtomigrate)
$m = $mailboxtomigrate | Out-String
[System.Windows.MessageBox]::Show("$m")
the selected can be many. I need to store it in a variable so I can loop through it when I run the new-moverequest script.
so I need the display names to be stored as a string in the variable e.g. $mailboxtomigrate = "display name 1", "display name 2", "display name 3"
how do I do this?
is better if I out the results into an array? how do I do this?
thank you in advance
I think this will never actually be null:
if ($null -ne $ListView.SelectedItems) {
On reflection, it might be better to make the comparison:if ($ListView.SelectedItems.Count -eq 0) {
How are you launching the code to migrate? I will continue to argue that you do not need to store these in another variable, they already are by virtue of having been selected. The GUI persists, and it's selections, persist until you change them or close it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
best solution
Open in new window