PowerShell Multi-Threading!!!1


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


# create an array and add it to session state
$arrayList = New-Object System.Collections.ArrayList
$sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
    (New-Object System.Management.Automation.Runspaces.SessionStateVariableEntry
	('arrayList', $arrayList, $null))
$runspacepool = [runspacefactory]::CreateRunspacePool(1, 2, $sessionstate, $Host)
$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


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.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());
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!



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:

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

@=”C:\\Program Files (x86)\\Common Files\\microsoft shared\\MSEnv\\TextMgrP.dll


Thanks interwebs!

Top 10 SharePoint 2013 Features Cheat Sheet

REPOST: From SharePoint Pro

http://sharepointpromag.com/sharepoint-2013/top-10-sharepoint-2013-features-cheat-sheet .

Top 10 SharePoint 2013 Features Cheat Sheet

1. Authentication

  • OAuth support. This web authorization protocol means that a user or web app can request authorization to get temporary access to specific network resources.
  • Default claims-based authentication for new web apps. A new Windows PowerShell cmdlet, Convert-SPWebApplication, helps you migrate from Windows classic-mode authentication to claims-based authentication.
  • Distributed Cache Service for login tokens. A dedicated cache helps avoid the need for additional configuration and makes for less memory utilization in the web front-ends.
  • Enhanced logging.

2. Business Connectivity Services (BCS)

  • OData support. With this web protocol, you can now connect to an external data source.
  • Event listener. This includes an event subscriber, enabling SharePoint users and custom code to receive notifications of events that occur in the external system.
  • Support for apps for SharePoint. Lets you add self-contained apps for SharePoint that don’t make any changes to the underlying code on the computer running SharePoint Server, enhancing safety and easing installation and removal.
  • External list enhancements. Users can now filter, sort, or export external lists that display content from BCS content types; performance improvements reduce the load on SharePoint farm database servers.

3. eDiscovery

  • SharePoint eDiscovery Center. Site template creates a new portal for managing holds and cases, including abilities to search, place holds, and export content.
  • Improvements to in-place holds. Includes site-level preservation, Exchange mailbox preservation, ability to set permissions for users to access original versions of preserved content.
  • eDiscovery export. Ability to export the results of an eDiscovery search for later import into a review tool.
  • Enterprise-wide eDiscovery. Ability to manage eDiscovery across multiple SharePoint farms, Exchange servers, and file shares.

4. Mobile

  • Optimized viewing across different mobile platforms.
  • One site, multiple renderings. Ability to render a single published SharePoint site in multiple designs to accommodate different devices.
  • Push notifications. Works for Windows Phones.
  • Geolocation field type. For mobile app development.
  • Ability to view business intelligence content.
  • Office Web Apps. Ability to view Word, Excel, and PowerPoint documents.

5. Records Management


Site-level retention policies. Ability to create and manage retention policies in SharePoint Server 2013 that apply to SharePoint sites and any associated Exchange Server 2013 team mailboxes.

6. Business Intelligence

  • In-Memory BI Engine (IMBI) or Vertipaq engine. Near instant analysis of millions of rows.
  • Power View Add-in for Excel. Visualize and interact with modeled data via visualizations, animations, and smart querying.
  • PivotChart reports. Create them without having to include a PivotTable report on the same page.
  • Ability to explore and analyze data in Excel Services reports. For reports that use SQL Server Analysis Services data or PowerPivot data models.
  • View and display items in PivotChart and PivotTable reports. Support for users in Excel Services to view and change display of items in Excel Services-published PivotChart reports and PivotTable reports.
  • Calculate measures and members. Support for Excel-created calculated measures and members in Excel Services.
  • Timeline controls. Improved Excel Services timeline controls.
  • Dashboard migration. PerformancePoint Services dashboard migration.
  • PerformancePoint Services filters. Enhanced PerformancePoint Services filter UI and filter search.
  • Cleaner BI Center.
  • Support for Analysis Services Effective User.
  • PerformancePoint support on Apple iPad.
  • Visio Services Maximum Cache Size.
  • Updated Visio Health Analyzer rules.
  • Windows PowerShell cmdlets. Updated PowerShell cmdlets for Visio.
  • Visio commenting. Ability to add comments to a Visio drawing on the web in full page rendering mode.

7. Social Computing

  • New and updated policy settings. For the User Profile service application and My Sites in Central Administration.
  • Privacy and people. New privacy settings and updated people settings.
  • Microblogging. New microblogging ability on Newsfeed page in My Site.
  • My Sites. Improved My Sites saving, synchronization, sharing, and moving of content.
  • New site templates. Community Site and Community Portal. Community Site offers a forum-like experience. Community Portal is a page that surfaces SharePoint site collections and sites.

8. Web Content Management

  • Word to HTML. Ability to copy content from Word, paste it into a Web Part, and obtain an HTML-correct display.
  • Drag and drop. Ability to drag and drop menu items directly to a page.
  • Video upload. Improved video upload process.
  • Dynamic content. Ability to insert an iframe element to embed dynamic content from other sites.
  • Support for image renditions. Allows display of different-sized versions of an image on different pages.
  • Integrated translation service.
  • Language detection. Ability to redirect visitors to a site in an appropriate language based on the language setting of their web browser.
  • Cross-site publishing. When you make changes to content, those changes are displayed on all site collections that are reusing this content.
  • Catalog. Designate any library or list as a catalog. Enables content to be reused on publishing site collections.
  • Managed navigation. Ability to define and maintain navigation on a site by using term sets, in addition to site structure-based navigation.
  • Category pages. Page layouts that are used for displaying structured content such as catalog data.
  • User-friendly URLs.
  • New Web Part. Content Search Web Part displays crawled and indexed content.
  • Refiners and faceted navigation. Enables users to refine and narrow searches while browsing different pages.
  • New analytics processing component. Ability to analyze user actions for content managers. Ability to make recommendations and offer choices to users.
  • Branding changes. SharePoint Designer or Visual Studio knowledge no longer necessary. Can design a site by using HTML, CSS, and JavaScript, in tools such as Adobe Dreamweaver, Microsoft Expression Web, or other HTML editors.
  • Device-specific publishing. Ability to create channels that allow a single publishing site to be rendered in multiple ways on multiple devices.

9. Workflow

New SharePoint Designer 2013 workflow functionality includes the following:

  • Visual workflow. Develop workflow visually using Visio 2013 add-in.
  • No-code web service calls. New action enables no-code web service calls from within a workflow.
  • Task actions. New actions for creating a task and starting a task process
  • Coordination actions. New coordination actions between workflows built on SharePoint 2010 and SharePoint 2013
  • New dictionary type.
  • Stage, Loop, and App Step workflow building blocks.
  • New enterprise features in Workflow Manager.
  • New PowerShell cmdlets.  Cmdlets that manage workflow via Workflow Manager service.

10. Search

  • Search UI improvements.
  • Search result relevancy improvements.
  • Continuous crawl.
  • Improved flexibility of search schema.
  • New search architecture.

For more information on SharePoint 2013, see Asif Rehmani’s article ” Installing SharePoint 2013.”

Boot to VHD

boot to vhd — i always forget the commands!

thanks: http://www.johnpapa.net/bootoffmetal/

Shift+F10 in windows setup…

  1. I start by creating a new VHD on the metal where the OS will be installed. It allows me to choose a fixed size or expandable virtual disk file.The advantage of using fixed is that it will always consume X amount of space and be able to boot. Expandable VHDs take up much less space when not used, but they need to have room to expand when they are booted into. I generally use expandable.
    create vdisk file=c:\win7.vhd maximum=50000 type=expandable
  2. Now I select the VHD, attach to it, create a partition on it, and format it. Then I marked it as an active system drive and assigned it a drive letter.

    select vdisk file=c:\win7.vhd
    attach vdisk
    create part primary
    format fs=ntfs label=”Win7″ quick