Developersfiles.meetup.com/17651662/PnPPowerShell-SPUG.pdfConnect-SPOService -Url -credential...
Transcript of Developersfiles.meetup.com/17651662/PnPPowerShell-SPUG.pdfConnect-SPOService -Url -credential...
Ideal shell for
Windows
Consistency
across products
Automated
management
Object-oriented
shell
Interactive shell
Scripting language
Why PowerShell? What is PowerShell?
Get-SPWeb -Identity http://intranet.contoso.com
Get-SPFarm
Set-SPEnterpriseSearchCrawlTopology -Active
http://www.microsoft.com/en-us/download/details.aspx?id=35588
Sample 1:
Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential [email protected]
Sample 2:
$username = [email protected]
$password = "password“
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist
$userName, $(convertto-securestring $Password -asplaintext -force)
Connect-SPOService -Url http://contoso-admin.sharepoint.com/ -Credential $cred
Disconnect-SPOService
• 20+ years of industry experience
• Both Dutch and Swedish nationality
• Living in Stockholm, Sweden
• MCSM, MCM, MCT, MCSE, MCSD, MCSA, MCPD, MCITP, MCTS certifications
• Knowit AB
@erwinvanhunen
se.linkedin.com/in/erwinvanhunen
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll'Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll'
$url = "https://erwinmcm.sharepoint.com/sites/h1"$creds = Get-Credential -Message "Enter Online Credential"
$O365Credential = new-object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName,$creds.Password)
$ctx = new-object Microsoft.SharePoint.Client.ClientContext($url)$ctx.Credentials = $O365Credential
$listCi = new-object Microsoft.SharePoint.Client.ListCreationInformation;$listCi.Title = "Demo List";$listCi.TemplateType = [Microsoft.SharePoint.Client.ListTemplateType]::GenericList;$listCi.Url = "lists/demo";$list = $ctx.Web.lists.Add($listCi);
# Add the field$fieldXml = "<Field Type=""Choice"" Name=""SPSLocation"" DisplayName=""Location"" ID=""{ba27f512-27bc-4d07-bdd4-2ee61bc5bcb4}"" Group=""Demo Group"" Required=""TRUE""><CHOICES><CHOICE>Stockholm</CHOICE><CHOICE>Helsinki</CHOICE><CHOICE>Oslo</CHOICE></CHOICES></Field>"
$field = $list.Fields.AddFieldAsXml($fieldXml, $true, [Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView);
$ctx.Load($list);$ctx.ExecuteQuery();
Connect-SPOnline -Url https://mammothmicro2015.sharepoint.com/sites/demo1 -Credentials IVANMCM
New-SPOList -Title "Demo list" -Template GenericList -Url lists/demo
Add-SPOField -List "Demo list" `-DisplayName "Location" `-InternalName "SPSLocation" `-Type Choice `-Group "Demo Group" `-AddToDefaultView `-Choices "Stockholm","Helsinki","Oslo"
Add-SPOContentTypeAdd-SPOContentTypeToListAdd-SPOCustomActionAdd-SPOEventReceiverAdd-SPOFieldAdd-SPOFieldFromXmlAdd-SPOFieldToContentTypeAdd-SPOFileAdd-SPOFolderAdd-SPOHtmlPublishingPageLayoutAdd-SPOJavascriptBlockAdd-SPOJavascriptLinkAdd-SPONavigationNodeAdd-SPOPublishingPageAdd-SPOPublishingPageLayoutAdd-SPOTaxonomyFieldAdd-SPOUserToGroupAdd-SPOWebPartToWebPartPageAdd-SPOWebPartToWikiPageAdd-SPOViewAdd-SPOWikiPageAdd-SPOWorkflowSubscriptionConnect-SPOnlineDisable-SPOFeatureDisconnect-SPOnlineEnable-SPOFeatureExecute-SPOQueryExport-SPOTaxonomyFind-SPOFile
Get-SPOAppInstanceGet-SPOAuthenticationRealmGet-SPOConfigurationGet-SPOContentTypeGet-SPOContextGet-SPOCustomActionGet-SPOEventReceiverGet-SPOFeatureGet-SPOFieldGet-SPOFileGet-SPOGroupGet-SPOHealthScoreGet-SPOHomePageGet-SPOIndexedPropertyKeysGet-SPOListGet-SPOListItemGet-SPOMasterPageGet-SPOPropertyBagGet-SPOSiteGet-SPOStoredCredentialGet-SPOSubWebsGet-SPOTaxonomyItemGet-SPOTaxonomySessionGet-SPOTenantSiteGet-SPOTimeZoneIdGet-SPOUserProfilePropertyGet-SPOWebGet-SPOWebPartGet-SPOWebPartProperty
Get-SPOWebTemplatesGet-SPOViewGet-SPOWikiPageContentGet-SPOWorkflowDefinitionGet-SPOWorkflowSubscriptionImport-SPOAppPackageImport-SPOTaxonomyInstall-SPOSolutionNew-SPOGroupNew-SPOListNew-SPOPersonalSiteNew-SPOTenantSiteNew-SPOUserNew-SPOWebRemove-SPOContentTypeRemove-SPOCustomActionRemove-SPOEventReceiverRemove-SPOFieldRemove-SPOJavaScriptLinkRemove-SPOListRemove-SPONavigationNodeRemove-SPOPropertyBagValueRemove-SPOTenantSiteRemove-SPOUserFromGroupRemove-SPOWebPartRemove-SPOViewRemove-SPOWikiPageRemove-SPOWorkflowDefinitionRemove-SPOWorkflowSubscription
Request-SPOReIndexWebResume-SPOWorkflowInstanceSend-SPOMailSet-SPOAppSideLoadingSet-SPOConfigurationSet-SPODefaultColumnValuesSet-SPODefaultContentTypeToListSet-SPOFileCheckedInSet-SPOFileCheckedOutSet-SPOGroupSet-SPOHomePageSet-SPOIndexedPropertiesSet-SPOListSet-SPOListPermissionSet-SPOMasterPageSet-SPOMinimalDownloadStrategySet-SPOPropertyBagValueSet-SPOTaxonomyFieldValueSet-SPOTenantSiteSet-SPOThemeSet-SPOWebSet-SPOWebPartPropertySet-SPOWikiPageContentStop-SPOWorkflowInstanceUninstall-SPOAppInstanceUninstall-SPOSolution
http://aka.ms/OfficeDevPnPCmdlets15
http://aka.ms/OfficeDevPnPCmdlets16
https://github.com/OfficeDev/PnP/blob/master/Binaries/PowerShell.Commands