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

PowerShell

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

PowerShell – Install Module (Verbose Debug)

By setting the system variable $debugPreference = “Continue” we are able to see file level detail when installing PowerShell modules.  This can be helpful to gain an understanding of the dependency and files contained with a module.   Cool trick I didn’t know about until today.

Cheers! 

shades_smile

Code

Screenshots

image

image

image

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲