Forum Discussion
Updated Guidance around Identity and SharePoint web service throttling
Hi Benjamin,
here's some additional context. If you are using user context (not from app), which would be typical setup with console or PowerShell scripts, adding UserAgent string based on the request would be sufficient. You can though only add that by yourself for the console scenario.
If you are using PowerShell or more specifically PnP PowerShell, UserAgent decoration is automatically taken care off. By default, PnP PowerShell uses the following format for the UserAgent - "NONISV|SharePointPnP|PnPCore/{PnP CSOM Core assemblyversion}". This default setting is also used in console application scenario if you are using PnP CSOM Core component. You can override the default setting by using SharePointPnPUserAgent key in app.config, if you prefer to do so.
You do not need to register used Company part anywhere beforehand to be able to us it and you can use the same UserAgent string in different tenants.
I have implemented this successfully for a C# project and am now looking at doing it for PowerShell. I have taken the example in the documentation and implemented it like this:
- Jan SteenbeekFeb 15, 2018Copper Contributor
I couldn't get your solution to work because Register-ObjectEvent is asynchronous. Checking with Fiddler shows the User-Agent string is not going over the wire.
This implementation works for me:
$ctx.add_ExecutingWebRequest({
param($Source, $EventArgs)
$request = $EventArgs.WebRequestExecutor.WebRequest
$request.UserAgent = "ISV|ItIsI|MyApp/1.0"
})