Hi everyone.
I have an error with New-MailboxExportRequest command trying to export some mailbox reading from csv file.
Its the script:
[cmdletbinding()]
Param()
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Snapin
. 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'
Connect-ExchangeServer -Auto
$csvfolder = "$home\desktop"
$csvName = 'Libro1.csv'
$csvdata = Import-Csv $(Join-Path $csvfolder $csvName) -Encoding UTF8
$date = ((Get-Date).AddMonths(-3)).ToShortDateString()
if ($csvdata) {
$tot = $csvdata.Count
$actual = 0
foreach($record in $csvdata){
$sede = $record.Sede
$fileP = "\\172.22.3.23\C$\testbackup\"+$sede+".pst"
$actual++
$perc = $actual * 100 / $tot
Write-Progress -Activity 'Generating Export Requests' -Status "Generando exportación de $($record.Cuenta)
($actual of $Tot)" -Percentcomplete $perc
New-MailboxExportRequest -Mailbox $record -ContentFilter "Received -lt '$date'" -FilePath $fileP
}
}
It says the following:
Cannot process argument transformation on parameter 'Mailbox'. Cannot convert value "@{Cuenta=comunicaciones.fmm; Sede=Sede23}" totype "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter". Error: "Cannot convert hashtable to an object of the
following type: Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter. Hashtable-to-Object conversion is not supported
in restricted language mode or a Data section."
+ CategoryInfo : InvalidData: (:) [New-MailboxExportRequest], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MailboxExportRequest
+ PSComputerName : prubmmcdpexc01.testbmm.com
Please, help me.
Regards