Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Exchange Management Shell Syntax - An empty pipe element is not allowed

$
0
0

Hello!

As part of an AD migration project, thousands of linked mailboxes need to be reassociated to their newly migrated AD accounts that are now in the same forest as the MEU hosting the mailbox. We'll be copying important attributes from the MEUs, disconnecting the mailboxes, reattaching them as user mailboxes, then stamping the newly migrated account with those important attributes. The first problem I'm running into is in regards to scripting and I'd greatly appreciate a little syntax help.

An input file is provided for the accounts being migrated. The idea is that I need to pass what look to be a few arrays to their own variables, then later in the script use them to set attributes on a different object. I also need to export the details of the data for each user just in case things go badly. When running the script below I get the error outlined below as well. On top of that - it looks like it's only taking the last entry in the input file into account when it exports the details.

"An empty pipe element is not allowed"  on line 18, character 4

$CurrentDate = Get-Date
$CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm-ss')

import-module activedirectory
$userarray = import-csv C:\users\me\desktop\input.csv
foreach ($user in $userarray) {
$mailbox = get-mailbox $user.emailaddress | select displayname,primarysmtpaddress,database,servername,samaccountname
$user = get-aduser $mailbox.samaccountname -properties proxyaddresses,memberof,managedobjects,extensionAttribute5
    $displayname = $mailbox.displayname
    $psmtp = $mailbox.primarysmtpaddress
    $database = $mailbox.database
    $server = $mailbox.servername
    $PA = $user.proxyaddresses
    $groups = $user.memberof
    $groupmanagement = $user.managedobjects
    $RU = $user.extensionattribute5 `
    |
	select @{n="DisplayName";e={[string]$displayname}},@{n="Primary SMTP";e={[string]$psmtp}},@{n="Database";e={[string]$database}},@{n="HomeServer";e={[string]$server}},@{n="Proxies";e={[string]$PA}},@{n="MemberOf";e={[string]$groups}},@{n="GroupsOwned";e={[string]$groupmanagement}},@{n="RUCode";e={[string]$RU}}
} `
| export-csv C:\temp\test_$currentdate.csv -notype


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>