SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL
SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL

PowerShell

PWA Refresh – Clone Project Server to Lower Env (DEV)

Cloning a project server environment is not a simple procedure.   Wanted to share notes to help others.   Duplicating the SQL databases is a good start.   However, there are internal issues with duplicate GUID (same number already in use) that can create issues.

To resolve that hurdle I coded PowerShell which generates a new GUID and updates Site Collection (SPSite) via TSQL directly.   https://github.com/spjeff/spadmin/tree/master/SPContentDatabase-Replace-Site-GUIDs

With a fresh new GUID in place we can follow steps in SharePoint Central Admin, PowerShell, and PWA Settings to bring the new PWA database pairs (SharePoint Content + Project Plans) online for customers.   Word DOC included below with step-by-step detail.   Cheers! 

shades_smile

Download Checklist

PWA Refresh Procedure.DOC

Diagram

image

Context Diagram

References

FIXED – Cannot convert the JSON string … contains the duplicated keys ‘Id’ and ‘ID’

Recently I came across the error message below when download a SharePoint 2013 List item REST api call to PowerShell.  The cmdlet ConvertFrom-JSON does an excellent job.  However, it is case sensitive with property names.

The resolution I found was to first string replace (case sensitive) to rename one of the source property names.  Cheers! 

shades_smile

Screenshot – Before

ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the duplicated keys ‘Id’ and ‘ID’.

image

Screenshot – After

image

Code

cls

# Config
$web = "http://portal/sites/team"
$list = "Test"

# Digest
$urlView = "$web/_api/contextinfo"
$urlView
$req = Invoke-WebRequest $urlView -UseDefaultCredentials -UseBasicParsing -Method Post
[xml]$ctx = $req.Content
$digest = $ctx.GetContextWebInformation.FormDigestValue
$digest

# List Items
$urlItems = "$web/_api/web/lists/GetByTitle('$list')/getitems"
$json = "application/json; odata=verbose"
$headers = @{"Accept" = $json; "Content-Type" = $json; "X-RequestDigest" = $digest}
$body = '{"query":{}}'
$req = Invoke-WebRequest $urlItems -UseDefaultCredentials -UseBasicParsing -Method Post -Body $body -Headers $headers
$resp = $req.Content

### FIX - Case Sensitive Property Name Replacement ###
$resp = $resp.Replace("Id","Idd")

$json = $resp  | ConvertFrom-Json
$json

References

FIXED – stsadm upgrade command has been replaced by psconfig.exe

Recently I came across the error below when upgrading a SharePoint 2016 farm.   Expected product behavior and simply a case of training SharePoint Administrators to use PSCONFIG.EXE command line instead.  Cheers! 

shades_smile

Error Screenshot

image

New Command

References

VIDEO – PowerShell automated WebDeploy ZIP install

This video will demonstrate how to test, build, publish, and install WebDeploy ZIP packages.   The example walks through a simple WebAPI HTTP endpoint which echoes back the current date and time.   Fiddler is leveraged for HTTP testing.   Once tested succesful, we publish the project to ZIP for install on IIS hosted infrastructure.

PowerShell cmdlet Restore-WDPackage is used to extract ZIP content and create a permanent home for the API endpoint.

By automating with PowerShell we provide a fast consistent admin experience to ensure the API is always installed the same way for a reliable repeatable procedure.  Thanks for watching.

Cheers! 

shades_smile

Video

Code

Add-PSSnapin WDeploySnapin3.0
$package = "C:\temp\Hello\deploy\Hello.zip"
Restore-WDPackage $package -Parameters @{"IIS Web Application Name"="API/Hello"}

Screenshot

image

References

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲