Please refer to the Introduction to PnP Core Component and OfficeDevPnP.Core for more details. I have created a console application and added SharePointPnPCoreOnline NuGet package for the SharePoint 2016 version.
Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.SharePoint.Client;
  7. using OfficeDevPnP.Core;
  8. namespace SP2016PnPCoreComponentDemo
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. // Input Parameters
  15. string siteUrl = "http://c7395723754/";
  16. string userName = "administrator";
  17. string password = "xxxxxxxxxx";
  18. string domain = "AD2012";
  19. string title = "PnP Demo Site";
  20. string description = "PnP Demo Site";
  21. string leafURL = "pnpdemosite";
  22. string template = "STS#0";
  23. int language = 1033;
  24. bool inheritPerm = true;
  25. bool inheritNavg = true;
  26. OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
  27. try
  28. {
  29. // Get the client context
  30. using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
  31. {
  32. // Create web
  33. Web web = ctx.Site.RootWeb.CreateWeb(title, leafURL, description, template, language, inheritPerm, inheritNavg);
  34. Console.WriteLine(web.Title + " -- created successfully!!!!");
  35. }
  36. }
  37. catch (Exception ex)
  38. {
  39. Console.WriteLine("Error Message: " + ex.Message);
  40. }
  41. }
  42. }
  43. }