MailChimp does not accept an email ending in #usace.army.mil - email

When I do an http post to a list with an email ending in #usace.army.mil I get the error message back (that says the email is fake)
I know the email is not fake is there anyway to override this?
:
Invoke-RestMethod : {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid
Resource","status":400,"detail":"Fred.T.Tracy#usace.army.mil looks fake or invalid, please enter a real email address.","instance":""}
At line:69 char:29
+ ... $gist = Invoke-RestMethod -Method Post -Uri "$URL$endpoint" -Head ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Unfortunately the answer to your question is no, there in no way to override this.
Mailchimp support informed me that it does not allow addresses on the domain usace.army.mil to be added to its lists.
Your only recourse is to ask your subscriber to ask the admin on usace.army.mil to email compliance#mailchimp.com and ask that the block be lifted.
(p.s. to the original poster, please can I suggest that you remove the person's email address from your code snippet for privacy reasons.)

Related

Update user contact email addresses using Microsoft Graph

I am trying to update the phone numbers and email addresses to update an contact's email addresses and phone numbers, using the microsoft.graph module in powerShell.
Authentication is done via an app registration with the needed permissions.
Data to input is extracted from AAD and stored in the variable $AadUser
Trying to update the email address to username#domain.com I get the following:
Update-MgUserContact -ContactId $CurrentContact.Id -UserId $ContactManagementMailboxId -EmailAddresses #{$AadUser.Mail = $AadUser.DisplayName}
Update-MgUserContact : The annotation 'domain.com' was targeting the instance annotation 'username'. Only the 'odata.type' annotation is allowed to target an instance annotation.
At line:1 char:1
+ Update-MgUserContact -ContactId $CurrentContact.Id -UserId $ContactMa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ UserId = 424c...GraphContact1 }:<>f__AnonymousType38`3) [Update-MgUserContact_UpdateExpanded1], RestException`1
+ FullyQualifiedErrorId : RequestBodyRead,Microsoft.Graph.PowerShell.Cmdlets.UpdateMgUserContact_UpdateExpanded1
I am sure something is wrong with the hash table used to pass the email address, but I can't see what...
#{$AadUser.Mail = $AadUser.DisplayName}
Doesn't look correct it should be an object array where the object has two property name and address eg
Update-MgUserContact -ContactId $contact.Id -EmailAddresses #{name="Sue";address="sue#dom.com"}
in your example something like
-EmailAddresses #{name=$AadUser.DisplayName;address=$AadUser.Mail}
should work

Unable to retrieve list of products from Azure API Management through REST API

I'm having trouble retrieving the list of APIM Products from the REST API based on the "apiId" passed in. I tried using the IDENTIFIER value from the screenshot below:
However, I get the following error:
Invoke-RestMethod : {"error":{"code":"ResourceNotFound","message":"Api not found.","details":null}}
At D:\powershell scripts\testing\test_add_api2.ps1:77 char:5
+ Invoke-RestMethod -Method Get -Uri $url -Header #{ "Authorization ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-Rest
Method], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMet
hodCommand
I'm using the following path to retrieve the list of products:
https://{base url}/apis/{apiId}?api-version=2016-10-10
I've also verified that the access token is valid for 5 days out.
First, am I using the correct id for "apiId"? Second, has the path changed recently if I'm using the correct apiId?
After speaking with Microsoft support, I figured out the issue. It turns out there's two different documentations with "Product" in the title under the "Reference" section: (1) Api Products and (2) Products
I made the mistake of following the documentation under #1. #2 is the documentation you want to follow in order to get the list of products. According to that documentation, the path looks like this:
GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products?api-version=2016-10-10[&$filter&$top&$skip&expandGroups]
https://learn.microsoft.com/en-us/rest/api/apimanagement/products
I confirmed that this works. So in short, use documentation #2 for products, not #1. Not sure what #1 is used for, but #2 works.

Sharepoint error: Enable-SPFeature : The security validation for this page is invalid

When I try to deploy the project via PowerShell, PS proceed the "Enable-SPFeature" operation,
then it prints the error message below:
Enable-SPFeature : The security validation for this page is invalid.
Click Back in your Web browser, refresh the page, and try your
operation again.
At E:\Demo\DemoProject\DemoProject\scripts\utility.ps1:315 char:19
+ Enable-SPFeature <<<< -identity $id -url $url -confirm:$false
+ CategoryInfo : InvalidData: (Microsoft.Share...etEnableFeature:SPCmdletEnableFeature)
[Enable-SPFeature], SPException + FullyQualifiedErrorId :
Microsoft.SharePoint.PowerShell.SPCmdletEnableFeature
Can anyone provide a solution?
Whenever we update any list item, list or SPWeb instance you may get "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again". This is because of some security validation while updating the modification to the content database, so, in order to escape from that exception we have to make AllowUnsafeUpdates property of the SPWeb instance as true.
SPWeb oWeb = new SPWeb();
oWeb.AllowUnsafeUpdates = true;
AllowUnsafeUpdates property is used to Gets or sets a Boolean value that specifies whether to allow updates to the database as a result of a GET request or without requiring a security validation. SPSite class also has this property.

Powershell EWS SubscribetoPullNotifications for multiple mailboxes in a single session

My goal for this powershell script is to monitor a particular folder for all the mailboxes in Exchange Online (Office 365) and if an item is created, it will send that item as an email to another smtp address. I can achieve this for just one mailbox without any errors using impersonation.
However, I am trying to create a list of folderid array for each mailbox like:
foreach ($usermailbox in $mboxlist) {
$farray += Get-TargetF($usermailbox)
}
$farray contains objects of the type:
Microsoft.Exchange.WebServices.Data.FolderId($tfTargetFolder.Id)
I then look for events in:
$service.SubscribeToPullNotifications($farray,60,$null,[Microsoft.Exchange.WebServices.Data.EventType]::Created)
Note that Get-TargetF function gets the servername through autodiscover for each mailbox.
It also uses $service.FindFolders for finding the correct folder.
Running the script like I showed above results in an error for few mailboxes but not all (I had filtered out 5 mailboxes for testing).
New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.Exchange.WebServices.Data.FolderId.
At C:\Documents\mysc.ps1:63 char:22
+ $InboxId = new-object <<<< Microsoft.Exchange.WebServices.Data.FolderId($tfTargetFolder.Id)
+ CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand
And when I start listening to the events, I get this error:
Cannot find an overload for "SubscribeToPullNotifications" and the argument count: "4".
At C:\Documents\mysc.ps1:79 char:59
+ $pullSubscription = $service.SubscribeToPullNotifications <<<< ($farray,60,$null,[Microsoft.Exchange.WebServices.Data.EventType]::Created)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
I have also not figured out how to deal with the throttling issues with EWS on Exchange Online mentioned here. I suspect the subscription above will timeout after an hour by default.
What is the correct way to achieve this in a single pssession?
I think the only option you have here is to create separate Subscription for each mailbox and then loop through them one-by-one to call GetEvents to see if there are any new Create events.
As per my understanding, Specifying folder ids from different mailboxes cannot work since impersonation is more about making a call as some other user. If that other user doesn't have delegate privileges to the folder ids mentioned in request, it is bound to fail. May be you should try with Console app instead of Powershell first to quickly see on what really is working. That is to avoid any PS specific errors hindering the investigation of actual problem.
With Streaming Subscription approach, you could group mailboxes based on their server affinity as described here on MSDN. You should look at the trade-offs between Pull vs. Streaming before making the decision in that though.

PowerShell, is it possible to translate SID to ntaccount if you are not part of the domain?

I have this powershell code.
$securityidentifier = new-object security.principal.securityidentifier $sid
$user = ( $securityidentifier.translate( [security.principal.ntaccount] ) )
This code works only on a computer which is in the same domain as the user whose SID I would like to translate to ntaccount.
Is it possible to translate SID to ntaccount if you are not part of the domain, but you have domain username and password for that domain ?
Still the same error.
Exception calling "Translate" with "1" argument(s): "Some or all identity references could not be translated."
At C:\...\test.ps1:7 char:40
+ $user = ( $securityidentifier.translate <<<< ( [security.principal.ntaccount] ) )
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Since you are not in the domain, your machine has no idea who (which domain controller) it should ask to resolve this SID. It seems that there is no server parameter for the Translatename Method.
If you resort to WinApi it's possible: use the LookupAccountSid API (specify a domain controller for the lpSystemName parameter).
Have you tried say, mapping a drive to the domain controller, which would effectively cache the credentials for the domain user? That may then allow access to translate the SID. I haven't tried this before, but it's worth giving it a shot.