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

Blog

STSADM CMD with email output

Waiting and watching STSADM run on the CMD line is an exercise in patience.  Lately I’ve been incorporating two techniques to email myself updates for the freedom to walk away from the keyboard.

A quick command line EXE project allows me to send email by giving parameters (number 0-5).   If 5 is blank, no big deal just send a plain email with subject and body.   If 5 exists then attempt to open that text file, read content, and send as email body.

That’s great, but … how does this help me?  Great question!!

1) Send email at key script milestones

The freedom to walk away and receive alerts as progress continues allows you to be stay confident and know progress is moving forward.  Just add “SendMail.exe” inline with your existing CMD files to send an email at that step in the process.

 

2) Send email with script outcome

The detailed knowledge of what return value came from the CMD when it finished is helpful.   Imagine running a site move (STSADM backup/delete/restore) and heading out for dinner.   It’s very nice to get an email showing “Operation completed successfully” three times. 

Smile

   Just use “SendMail.exe” with parameter 5 being the text file full path and name.

image

image

 

Unlock ASMX for easy manual invoke (developers)

For SharePoint development I like to use the .ASMX web services for reading data.  Out of the box default security prohibits manual remote HTTP queries.  A quick edit to “C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPIweb.config” for changing <protocols> from “remove” to “add” and then you’ll be able to manually Invoke.

The raw XML returned by a manual invoke is incredibly valuable for developers. 

Open-mouthed

Before (out of the box)

image

After (unlocked for development)

image

Always use CMD files

I rarely use absolutes but CMD files are amazing and you really should always use them.  For anything, no matter how small.

Why bother?  What’s in it for me?

  1. Easy to repeat
  2. Easy to test
  3. Can modify while running

The only cost is time.  It takes a little longer to build a CMD file and plan it out.  However, measure twice and cut once pays off with quality.  Let’s explore the benefits one at a time:

  1. Reusing a CMD file is very easy.  Search replace in Notepad++ can switch scope easily.  Also, input parameters like %1, %2, etc. can make the tool modular for using in a slightly different way quickly next time.
  2. Copy a CMD file to lower environments for practice is quick, easy, and helps mitigate risk.  Before you typo against production, try copying the file to a different server first.
  3. This is awesome and very little known!   While a CMD file is running (after you hit enter) you can still open Notepad.exe and modify the file.  Adding an extra line, commenting out with REM, or removing a line can all be done.  As long as CMD has not made it down to that line already you’re edits will be picked up as it steps down.   Great for real-time adjustments.

Thanks for reading! 

Open-mouthed
image

[Microsoft.Office.Server.UserProfiles.Privacy] enumeration ints

Oh yeah, time for fun stuff!  There are only maybe 50 people on the entire planet that care about this but here goes nothing…

The Privacy class has enumerations which are fine for C# IDE coding but if you ever run a direct TSQL select against the SSP database those become hard to read.  [UserMemberships.ItemSecurity] on the Shared Service Provider database stores these raw integer values if you ever need to query Membership data directly.  And here they are:

 

http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.membergroup.sourcereference.aspx

Contacts 2
Manager 8
NotSet  
Organization 4
Private 16
Public 1

image

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲