Итак, я получил этот скрипт, он должен изменить цвет категории в office365, от powershell .............................. ...................................
Сценарий:
$messages = Import-Csv -Path c:\temp\messageid.csv
Connect-EXRMailbox -Mailbox "email@domain.com"
ForEach ($message in $messages){
$MessageId = $message.MessageId
$MailboxName = $message.MailboxName
$Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId
Set-EXRItemCategory MailboxName $MailboxName -Item $Item -Categories @("Green")
}
Код ошибки:
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Get-EXRAccessToken : No Access Token for MailboxName
At line:31 char:32
+ ... $AccessToken = Get-EXRAccessToken -MailboxName $MailboxName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-EXRAccessToken
Get-EndPoint : Cannot bind argument to parameter 'AccessToken' because it is null.
At line:38 char:47
+ $EndPoint = Get-EndPoint -AccessToken $AccessToken -Segment " ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-EndPoint], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-EndPoint
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Get-EXRAccessToken : No Access Token for MailboxName
At line:24 char:20
+ ... $AccessToken = Get-EXRAccessToken -MailboxName $MailboxName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-EXRAccessToken
Invoke-RestPatch : Cannot bind argument to parameter 'AccessToken' because it is null.
At line:32 char:92
+ ... $RequestURL -HttpClient $HttpClient -AccessToken $AccessToken -Mailbo ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-RestPatch], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Invoke-RestPatch
Мой CSV-файл:
"MessageId","MailboxName"
"<HE1P192MB018554247E4F4A81D830F19DD1820@HE1P192MB0185.EURP192.PROD.OUTLOOK.COM>","email@domaion.com"
Итак, мой вопрос. Это мой код, в котором есть ошибка, или это инструмент Exch-Rest?
Надеюсь, кто-нибудь знает, как это исправить.
Хорошего дня!