developersfiles.meetup.com/17651662/pnppowershell-spug.pdfconnect-sposervice -url -credential...

52

Upload: others

Post on 24-May-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Ideal shell for

Windows

Consistency

across products

Automated

management

Object-oriented

shell

Interactive shell

Scripting language

Why PowerShell? What is PowerShell?

Console

ISE

PropertiesIsOn

Watts

BurntOut

MethodsTurnOn()

UnScrew()

ChangeStrength()

Get-SPWeb -Identity http://intranet.contoso.com

Get-SPFarm

Set-SPEnterpriseSearchCrawlTopology -Active

Get-Service | Where-Object {$_.Status -eq "Stopped"} | Format-List

Objects Objects

On-Premise

On-Premise

On-Line

http://www.microsoft.com/en-us/download/details.aspx?id=35588

Connect-SPOService

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

Developer

Patterns & Practices

• 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

[email protected]

@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

http://dev.office.com/patterns-and-practices

Developer

Patterns & Practices