Error: AADSTS65001: The user or administrator has not consented to use the application with ID ‘xxx’ named ‘SharePoint Online Client Extensibility Web Application Principal’

My genius co-worker helped me solve a tricky problem in Azure today.

PROBLEM:
Error: AADSTS65001: The user or administrator has not consented to use the application with ID ‘xxx’ named ‘SharePoint Online Client Extensibility Web Application Principal’. Send an interactive authorization request for this user and resource. Trace ID: dc1a52d3-6dfd-4a7e-9730-f9d347aa7600 Correlation ID: e48dce00-b9b1-4328-a13b-bd21bedb3f5a Timestamp: 2019-01-16 18:55:28Z

SOLUTION:
https://login.microsoftonline.com/common/oauth2/authorize?client_id=xxx&response_type=code&prompt=admin_consent

 

#spfx #sharepointonline #azure

PowerShell Multi-Threading!!!1

http://www.codeproject.com/Tips/895840/Multi-Threaded-PowerShell-Cookbook

This guy gives a great overview of PowerShell multi-threading. It is step by step and chunked into nice sized pieces.  Thanks!

 

cls
# create an array and add it to session state
$arrayList = New-Object System.Collections.ArrayList
$arrayList.AddRange(('a','b','c','d','e'))
 
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
$sessionstate.Variables.Add(
    (New-Object System.Management.Automation.Runspaces.SessionStateVariableEntry
	('arrayList', $arrayList, $null))
)
 
$runspacepool = [runspacefactory]::CreateRunspacePool(1, 2, $sessionstate, $Host)
$runspacepool.Open()
 
$ps1 =
::Create() $ps1.RunspacePool = $runspacepool $ps1.AddScript({ for ($i = 1; $i -le 15; $i++) { $letter = Get-Random -InputObject (97..122) | % {[char]$_} # a random lowercase letter $null = $arrayList.Add($letter) start-sleep -s 1 } }) > $null # on the first thread start a process that adds values to $arrayList every second $handle1 = $ps1.BeginInvoke() # now on the second thread, output the value of $arrayList every 1.5 seconds $ps2 =
::Create() $ps2.RunspacePool = $runspacepool $ps2.AddScript({ Write-Host "ArrayList contents is " foreach ($i in $arrayList) { Write-Host $i -NoNewline Write-Host " " -NoNewline } Write-Host "" }) > $null 1..10 | % { $handle2 = $ps2.BeginInvoke() if ($handle2.AsyncWaitHandle.WaitOne()) { $ps2.EndInvoke($handle2) } start-sleep -s 1.5 }

Show Required Fields in Custom SharePoint Page Layout

http://www.mavention.com/blog/showing-required-fields-when-editing-a-page-sharepoint-2013

This guy had a great solution for getting and displaying required fields on a SharePoint custom page.  Thanks!

showRequiredFields = function() {
    var context = new SP.ClientContext();
    var list = context.get_web().get_lists().getById(_spPageContextInfo.pageListId);
    var item = list.getItemById(_spPageContextInfo.pageItemId);
    fieldCollection = item.get_contentType().get_fields();

    context.load(fieldCollection);
    context.executeQueryAsync(Function.createDelegate(this, success), Function.createDelegate(this, failed));

    function success() {
        var occurences = 0;
        var fe = fieldCollection.getEnumerator();
        while (fe.moveNext()) {
            var field = fe.get_current();
            var xmlSchemaString = field.get_schemaXml();
            var fieldXml = $.parseXML(xmlSchemaString);
            var fieldElement = fieldXml.getElementsByTagName('Field')[0];

            var required = fieldElement.getAttribute('Required');
            if (required != null && fieldElement.getAttribute('Required').toLowerCase() === 'true') {
                var displayName = fieldElement.getAttribute('DisplayName');
                $("[title='" + displayName + "']").closest('tr').children('td.ms-formlabel').append(' *');
            }
        }

        if (occurences > 0) {
            $('#DeltaPlaceHolderMain').prepend('* = required'); } } function failed(sender, args) { console && console.log('failed. Message:' + args.get_message()); } }

Force Reset SharePoint Index / SharePoint Index Reset Timeout – SOLVED

Reference: http://jcaspadmin.blogspot.com/2014/05/sharepoint-2013-content-index-reset.html

  1. Stop the Windows SharePoint Services Timer service (Found in Windows Services)
  2. Navigate to the cache folder
  3. In Windows Server 2008, the configuration cache is in the following location:
  4. Drive:\ProgramData\Microsoft\SharePoint\Config
  5. Locate the folder that has the file “Cache.ini”
  6. Back up the Cache.ini file.
  7. Delete all the XML configuration files in the GUID folder. Do this so that you can verify that the GUID folder is replaced by new XML configuration files when the cache is rebuilt.
  8. Note When you empty the configuration cache in the GUID folder, make sure that you do not delete the GUID folder and the Cache.ini file that is located in the GUID folder.
  9. Double-click the Cache.ini file.
  10. Select the entire contents of the Cache.ini file and delete it, replacing all the text with the number ’1′. Save the file and close
  11. Start the Windows SharePoint Services Timer service
  12. Note The file system cache is re-created after you perform this procedure. Make sure that you perform this procedure on all servers in the server farm.
  13. Make sure that the Cache.ini file in the GUID folder now contains its previous value. For example, make sure that the value of the Cache.ini file is not 1.

Convert IEnumerable to CSV with an extension method

Found this useful tidbit for converting IEnumerable<T> to a CSV…

From the article:
” I started writing it, but then decided to Google with Bing, and found a decent direction to start with at Mike Hadlow’s blog. He didn’t include all the code in the post, but it saved me some typing, so thanks Mike!

namespace FooFoo
{
public static class LinqToCSV
{
public static string ToCsv<T>(this IEnumerable<T> items)
where T : class
{
var csvBuilder = new StringBuilder();
var properties = typeof(T).GetProperties();
foreach (T item in items)
{
string line = string.Join(“,”,properties.Select(p => p.GetValue(item, null).ToCsvValue()).ToArray());
csvBuilder.AppendLine(line);
}
return csvBuilder.ToString();
}

private static string ToCsvValue<T>(this T item)
{
if(item == null) return “\”\””;

if (item is string)
{
return string.Format(“\”{0}\””, item.ToString().Replace(“\””, “\\\””));
}
double dummy;
if (double.TryParse(item.ToString(), out dummy))
{
return string.Format(“{0}”, item);
}
return string.Format(“\”{0}\””, item);
}
}
}

Thanks Hansleman!
http://www.hanselman.com/blog/?date=2010-02-04

 

 

VS2013 Find in Files not showing any files / search results

Recently, VS2013 started omitting the file names in the search results when I did a “Find in Files”

The output was similar to:

Find all “Phone”, Subfolders, Find Results 1, Entire Solution, “*.*”
… where are my file names?? …
Matching lines: 637    Matching files: 84    Total files searched: 821

The following post fixed it:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/40c9ad4a-8cee-4f3f-b420-c7cc0463942a/visual-studio-2012-find-in-files-not-displaying-files?forum=vsx

The Default value in this registry entry was not there (it was just an empty string).

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID\{73B7DC00-F498-4ABD-AB79-D07AFD52F395}\InProcServer32]
@=”C:\\Program Files (x86)\\Common Files\\microsoft shared\\MSEnv\\TextMgrP.dll
“ThreadingModel”=”Both”

 

Thanks interwebs!