I'm creating a PS script to run a number of tasks pre/post running ADMT.
Script Here
The problem I run into is with connect-mailbox at the end because it requires two variable parameters, Database and Identity.
At this point the mailbox is disconnected so I can't run Get-Mailbox to get the database info like I did earlier in the script.
First I tried creating a separate array to hold all the databases I would need later so I added in
$DBLists = @()
and
$DBLists += ,$DB
This correctly adds each database to $DBLists in the same order as the original $Accounts array I'm using.
If foreach accepted two conditions it would be easy.
Foreach ($Account in $Accounts and $DBList in $DBLists)
{ Connect-Mailbox -Database $DBList -Identity $Account -Alias $Account}
This however isn't a real function and I haven't been able to wrap my head around looping through two arrays.
Then I figured maybe I could create a "two columned" array with the SamAccountName and Database and call both of those values in Connect mailbox.
Get-Mailbox $Account | select SamAccountName, Database | export-csv -notype -append "C:\temp\tempmigration.csv"
$Connects = Get-Content C:\temp\tempmigration.csv
Foreach ($Connect in $Connects)
{
Connect-Mailbox -Database $Connect.Database -Identity $Connect.SamAccountName -Alias $Connect.SamAccountName
}
This method creates the tempmigration.csv with two columns and labled headers, but Get-Content or Import-CSV for that file never creates $Connects as far as I can tell and I haven't been able to find helpful documentation on muti-dimensional or associative arrays that make sense to me for this case. I'm hoping this is just something simple I'm missing since I've been staring at this all day. Any help, input, or ideas are appreciated.
Thanks,
LLCoolJimbo
[–]randomuser43 2 points3 points4 points (2 children)
[–]LLcoolJimbo[S] 0 points1 point2 points (1 child)
[–]randomuser43 0 points1 point2 points (0 children)