Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.
Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.

January 2017

VIDEO – Online WebAPI Generator

I created an online service at https://spjeff.azurewebsites.net/ which generates a MVC WebAPI 2.2 project with the name you enter.   A custom ZIP file is generated server side with your custom name for the Project, Namespaces, Assembly, and sent to the browser for download.   Best practices are already enabled such as:

  • [CORS] decorator
  • [Authorize] decorator
  • Minimal packages and dependency
  • Zero MVC boilerplate
  • Lean mean API ready for dev & prod

From there double click SLN and begin coding.  Enjoy! 

shades_smile

 

Video

Online WebAPI Generator from Jeff Jones on Vimeo.

 

Screenshots

 

image

 

image

 

image

PowerShell – Cache AD User Lookup

Given a filter value, this PowerShell function will query Active Directory to find a matching user object and store results in a memory cache.  By default “samAccountName” is used for filter.  Optional field name can be provided to filter by any field such as Manager, Mail, or DN. 

Cheers!  

shades_smile

 

 

Source Code

https://github.com/spjeff/spadmin/blob/master/lookupADUser.ps1

 

# DataTable cache
$cacheUsers = New-Object System.Data.DataTable("users")
$cols = @("DistinguishedName","Enabled","extensionAttribute4","Manager","Name","Mail","SamAccountName")
foreach ($col in $cols) {
	$cacheUsers.Columns.Add($col) | Out-Null
}

# Find user by any field
Function lookupADUser ($login, $optFieldName) {
    # Filter 
    $dv = New-Object System.Data.DataView($cacheUsers)
    $filter = "SamAccountName = '$login'"
    if ($optFieldName) {
        $filter = $filter.Replace("SamAccountName", $optFieldName)
    }
    $dv.RowFilter = $filter
    # Return from cache
    if ($dv.Count -gt 0) {
        # Found
	    return $dv
    } else {
        # Insert
        $cmd = "SamAccountName -eq '$login'"
        if ($optFieldName) {
            $cmd = $cmd.Replace("SamAccountName", $optFieldName)
        }
        $sb = [Scriptblock]::Create($cmd)
        $user = Get-ADUser -Filter $sb -Properties extensionAttribute4,manager,enabled,Mail
        if ($user) {
            $row = $cacheUsers.NewRow()
	        foreach ($col in $cols) {
		        $row[$col] = $user.$col
	        }
	        $cacheUsers.Rows.Add($row) | Out-Null
	        return $dv
        } else {
            return $null
        }
    }
}

# Search by userID
$sb = {lookupADUser "userID"}
measure-command $sb |ft
# Search by Email
$sb = {lookupADUser "first_last@company.com" "Mail"}
measure-command $sb |ft
# Search by DN
$sb = {lookupADUser "CN=First Last,OU=Regular,OU=Accounts,DC=company,DC=com" "DistinguishedName"}
measure-command $sb |ft

 

Screenshot

2017-01-27_14-18-07

What’s in that patch? Jan 2017

NOTE – PDF format updated to include both SharePoint 2013 and 2016 notes.

 

Ever wondered what fixes are inside of a given CU?   Please see attached PDF with full detail. I wanted a new format for easy reading.   Show management and make the business case for why downtime should be taken to apply CUs.  Also posted at http://sharepointupdates.com/

If you found this helpful, please leave a comment.   

shades_smile_thumb_thumb_thumb_thumb[2]

 

Download

What’s in that patch – Jan 2017.PDF

Replace CE / SE Web Part Content PS1

Managing front end code (HTML/JS) embedded within Script and Content Editor Web Parts can be a hassle.   With multiple instances scattered across ASPX pages, web part galleries, and many sites quickly becomes untenable.

The below PowerShell script gives SharePoint admins a new way to search/replace the internal text of CEWP/SEWP web parts within a target site collection.    Updating a URL reference or DNS name can now be done across potentially hundreds  of WP in just a few minutes.

For example, a team site having 1 CEWP and 1 SEWP with the world “hello” can be quickly replaced with “hola” by running this script.

Cheers! 

shades_smile

 

Source Code

 

Screenshot – Before

1

 

3

 

Screenshot – After

5
6
7

 

8

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲