powershell - Error when converting to EWSId on Exchange 2013 works ok on Exchange 2010 -
hello when run following piece of code.
$service.impersonateduserid = new-object microsoft.exchange.webservices.data.impersonateduserid([microsoft.exchange.webservices.data.connectingidtype]::smtpaddress, $mailboxname)
function convertid{
param (
$owaid = "$( throw 'owaid mandatory parameter' )"
)
process{
$aiitem = new-object microsoft.exchange.webservices.data.alternateid
$aiitem.mailbox = $mailboxname
$aiitem.uniqueid = $owaid
$aiitem.format = [microsoft.exchange.webservices.data.idformat]::owaid
$convertedid = $service.convertid($aiitem, [microsoft.exchange.webservices.data.idformat]::ewsid)
return $convertedid.uniqueid
}
}
get folder id ems , bind folder in ews
get-mailboxfolderstatistics $mailboxname | foreach-object {
$folderid = new-object microsoft.exchange.webservices.data.folderid((convertid $_.folderid)) $ewsfolder = [microsoft.exchange.webservices.data.folder]::bind($service,$folderid) $ewsfolder
}
i receive following error. should method different exchange 2013.
foreach-object : exception calling "convertid" "2" argument(s): "data corrupt." @ d:\scripts\save scripts\get-foldeidsr.ps1:89 char:44 + get-mailboxfolderstatistics $mailboxname | foreach-object { + ~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (:) [foreach-object], methodinvocationexception + fullyqualifiederrorid : serviceresponseexception,microsoft.powershell.commands.foreachobjectcommand
you need urlencode folderid ems may have illegal characters eg
add-type -assemblyname system.web $urlencodedid = [system.web.httputility]::urlencode($_.folderid.tostring()) $folderid= new-object microsoft.exchange.webservices.data.folderid((convertid $urlencodedid)) $ewsfolder = [microsoft.exchange.webservices.data.folder]::bind($service,$folderid)
Comments
Post a Comment