Kelly Garcia
asked on
Convert Variable to Array
HI All,
I have this variable in my powershell script:
I then have this code that I run to execute migration of mailboxes:
problem is when there is only one item in $m the new-moverequest fails.
I therefore believe I need to convert the $m to an array, how do I do this?
I have this variable in my powershell script:
$global:m = $mailboxtomigrate.displayname
I then have this code that I run to execute migration of mailboxes:
$a=$mailboxtomigrate.totalitemsize | select @{label='Size' ; expression={ ($_.split('(')[1].split(' ')[0].replace(',',''))/1024/1024/1024 }} | select-object -expand Size
for ($d=0; $d -lt $a.length; $d++) {
New-MoveRequest -Identity $m[$d] -TargetDatabase $TargetDatabase -WhatIf
}
problem is when there is only one item in $m the new-moverequest fails.
I therefore believe I need to convert the $m to an array, how do I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The code works, but the results are not displaying:
instead the results are displaying on the powershell screen
$OutputBox.Text += New-MoveRequest -Identity $m[$d] -TargetDatabase $TargetDatabase -WhatIf *>&1
$OutputBox.Text += "`r`n"
instead the results are displaying on the powershell screen
You'll still get the WhatIf text on the screen. Can't redirect that one.
ASKER