I am trying to change linkedmasteraccounts for around 200 users. I tried to script it, script below but it seems to fail. I am new at this and would appreciate any advice on how to get the script below to work. Thanks in advance.
Testscript.ps1
DEL "C:\xxxxxxxx\password2.txt"
$my_secure_password_string = convertto-securestring "XXXXXXX" -asplaintext -force
$my_encrypted_string = convertfrom-securestring $my_secure_password_string -key (1..16)
$my_encrypted_string > "C:\XXXXXXX\password.txt"
$password = convertto-securestring (get-content C:\XXXXXXXXt\password.txt) -key (1..16)
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "Domain\admin",$password
$MigrationUsers = import-csv C:\xxxxxxxt\test.csv
foreach ($alias in $MigrationUsers)
{get-mailbox $alias.migrationusers |
set-mailbox $mbx.alias -LinkedDomainController "dc.domain.com" -LinkedMasterAccount "domain.net\" + $mbx.alias -LinkedCredential $credentials
}