Giter VIP home page Giter VIP logo

pnp-powershell's Introduction

PnP PowerShell

PnP-PowerShell Repository - ARCHIVED Important: PnP-PowerShell has been retired and archived. Move to the new PnP PowerShell module available at https://github.com/pnp/powershell. We will only maintain that version going forward.

Summary

This solution contains a library of PowerShell commands that allows you to perform complex provisioning and artifact management actions towards SharePoint. The commands use a combination of CSOM and REST behind the scenes, and can work against both SharePoint Online as SharePoint On-Premises.

PnP PowerShell RoadMap

I've found a bug, where do I need to log an issue or create a PR

Only PnP.PowerShell is actively maintained.

Given that the cross-platform PnP PowerShell is our future going forward create issues and PRs in the new https://github.com/pnp/powershell repository.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

pnp-powershell's People

Contributors

afsandeberg avatar artokai avatar casselc avatar crossan007 avatar erwinvanhunen avatar fowl2 avatar gautamdsheth avatar geraintjames avatar get-itips avatar heinrich-ulbricht avatar j0rtit avatar jackpoz avatar jansenbe avatar jensotto avatar kilasuit avatar koenzomers avatar laskewitz avatar modery avatar mrpullen avatar nschonni avatar paolopia avatar pieter-veenstra avatar pkbullock avatar sharepointradi avatar skaggej avatar stevebeauge avatar thechriskent avatar toddklindt avatar vesajuvonen avatar wobba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pnp-powershell's Issues

Add-SPOListItem doesn't accept users

I have created a field of UserMulti type that is associated with a list. I've tried several formats for adding a user to the field but none seem to work:

domain\login
email
username
full name

Is there another format I should be using?

Thanks.

Problem with Get-SPOWeb

After connecting to a site collection,
I am getting the following error: when I run get-spoweb |fl

get-spoweb : The pipeline has been stopped.
At line:1 char:1

  • get-spoweb |fl
  • - CategoryInfo          : WriteError: (:) [Get-SPOWeb], PipelineStoppedException
    - FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.GetWeb
    
    

fl : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
At line:1 char:13

  • get-spoweb |fl
  •         ~~
    
    • CategoryInfo : NotSpecified: (:) [Format-List], CollectionNotInitializedException
    • FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.FormatListCommand

Any idea why? what am i doing wrong? it works fine for get-spoweb | ft, but fails with the full list. I want to see all of properties for the web object.

New-SPOTermGroup (v16) broken

If you connect to an O365 tenant with an appropriately permissioned account and try to create a new term group ala:

Add-SPOTaxonomyField -GroupName "Test01"

the term group is created, however it looks like there is something wrong with the object returned.

format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. + CategoryInfo : NotSpecified: (:) [format-default], CollectionNotInitializedException + FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.FormatDefa ultCommand

Other term group related commands are also not working, but I'm guessing this is the root cause. It looks to me as if the collection returned is throwing an error.

Powershell Module Path environment variable is set wrong

When installing the powershell cmdlets by using the msi, the PSModulePath is erroneously added to the (old?) wrong location. Which does not make the module available to powershell.

It is set to: "C:\Program Files (x86)\OfficeDevPnP" and should be set to
"C:\Program Files (x86)\OfficeDevPnP.PowerShell.Commands"

Growing field default values SPOProvisioningTemplate

Hi,
Im creating a provisioning template doin multiple iterations of
Get-/Apply-SPOProvisioningTemplate

In each iteration on the same target site the SiteFields Field Default value is growing by one more item:
image

No error but mean...

Thanks
Roman

Connect-SPOnline with ADFS - on-premises

Get an error message that the endpoint does not use ADFS for authentication.
When I take a look at fiddler there are 3 more roundtrips to SharePoint before the location header gives the correct ADFS location
1: /_trust/ -> location is /_layouts/15/authenticate.asxp
2: /_layouts/15/authenticate.aspx -> location is /_login/autosignin.aspx (This is a custom login page for SharePoint)
3: /_login/autosignin.aspx -> location is /_trust/default.aspx
4: /_trust/default.aspx?trust= -> location is the ADFS url.

The current code does only 1 try and fails
SPOnlineConnectionHelper.cs lines 254 - 280

Issue also posted on pnp/PnP#1118

Modules not recognized after install

Hi,

I installed the PnPPowerShellCommands16.msi however, once installed, none of my normal modules loaded.

I had a look a my env variables and noted the following for PSModulePath:

User:
C:\Users<'myusername'>\AppData\Local\Apps\OfficeDevPnP.PowerShell.Commands

System
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules;
C:\Program Files\Intel;
C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;
C:\Program Files (x86)\SharePoint Online Management Shell;
C:\Program Files\SharePoint Online Management Shell\

I then uninstalled and the same shows as follows:

User:

  • no entries

System:
C:\Users<'myusername'>\Documents\WindowsPowerShell\Modules;
C:\Program Files\WindowsPowerShell\Modules;
C:\Windows\system32\WindowsPowerShell\v1.0\Modules;
C:\Program Files\Intel;
C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;
C:\Program Files (x86)\SharePoint Online Management Shell;
C:\Program Files\SharePoint Online Management Shell\

Note, the top two items were missing when PnP... was installed.

Is this a known problem? Please let me know if you need any other details.

Thanks

John

Error on New-SPOWeb

Hi,

I tried to use New-SPOWeb. The subsite is created but unfortunately the script breaks with an error message:
format-default : The collection has not been initialized. It has not been requested or the request has not been
executed. It may need to be explicitly requested.
+ CategoryInfo : NotSpecified: (:) [format-default], CollectionNotInitializedException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Comma
nds.FormatDefaultCommand

I tried to catch this exception with no luck. What can I do?

Thanks
Roman

Add-SPOFile with Checkout option does not update existing files

Updating an existing file with Add-SPOFile command and the Checkout option does not work if the library has the Require Checkout -option set. The cmdLet does not even try to checkout the existing file before updating it.

The file exists -check before the actual checkout fails because the necessary property (Exists) is not loaded through CSOM.

I'll submit a pull request to fix this issue.

Add-SPONavigation failes for URL with same address as Site URL

This week something strange happened.

When I add a node on a site and the node url starts with the same as the site url, the command fail.
Example:
On a site with the url: https://mytenant.sharepoint.com/sites/sales,
I run: Add-SPONavigationNode -Url 'https://mytenant.sharepoint.com/sites/sales' -Location TopNavigationBar -Title 'Sales'

Nothing happens and there are no error messages.

If I do this on the rootsite, I get some errors, and no site realted to the root site is added.
All urls starting with https://mytenant.sharepoint.com, will fail.

The error message for the site /sites/sales is:
Add-SPONavigationNode : Cannot open "/sites/sales": no such file or folder.
CategoryInfo : WriteError: (:) [Add-SPONavigationNode], ServerException
+ FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.AddNavigationNode

Managed Metadata fields ApplySPOProvisioningTemplate

Hi

I have an issue which I hope you can help with. Basically I cannot get MM fields to display in views if I use XML to deploy a list. The steps I followed are:

  1. Create a subsite
  2. Create the list I want based on a Content Type in the Site Collection
  3. Export the subsite using the PowerShell command GetSPOProvisioningTemplate
  4. Take just the ListInstance I want and add an existing template which is based on a publishing site
  5. Create a new sub site
  6. Apply the template to the new subsite

The list is present and I can create items including adding MM data. However in the view I cannot see the values stored in the MM fields.

Please let me know if you need any further information.

Thanks

Export-SPOTaxonomy and Debugging PNP PowerShell

I have been trying to make the export taxonomy work for me using the following:

Connect-SPOnline -Url https://mydemo1.sharepoint.com -Credentials (Get-Credential)

Export-SPOTaxonomy -TermSetId 1e193f11-eb5f-4f76-8747-ddbb8902cd2b -TermStoreName "Site Navigation"

but this keeps resulting in the following error:

Export-SPOTaxonomy : Specified argument was out of the range of valid values.
Parameter name: index

Then when I corrected the term store name:

Export-SPOTaxonomy -TermSetId fd829cd1-8970-448f-9152-93c1fbb5eaf3 -TermStoreName "Taxonomy_hrn/SoS5OfY1gQN3xJiX6g=="

I got

Export-SPOTaxonomy : Cannot invoke method or retrieve property from null object. Object returned by the following call stack
is null. "GetTermSet
GetByName
TermStores
Microsoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession
"
At line:1 char:1

  • Export-SPOTaxonomy -TermSetId fd829cd1-8970-448f-9152-93c1fbb5eaf3 -TermStoreNam ...
  • - CategoryInfo          : WriteError: (:) [Export-SPOTaxonomy], ServerException
    - FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.ExportTaxonomy
    
    

Then when I corrected the guid to point to a termset it all worked and I got my export:

Export-SPOTaxonomy -TermSetId dda17137-1adf-43e4-bf3b-ce7be1fc943e -TermStoreName "Taxonomy_hrn/SoS5OfY1gQN3xJiX6g=="

Then now my issue:

Is there a way to debug these commands in Visual studio stepping through will help me understand what each command expects. I've tried setting break points and attaching to the PowerShell commands but this doesn't seem to be working. I've tried both Visual Studio 2013 and 2015.

New-SPOWeb and ServerRelativeUrl

When running New-SPOWeb a web object is returned where ServerRelativeUrl is not set. Get-SPOSubWebs does set ServerRelativeUrl. So to create a new web I'm running something like this:

            $web = Get-SPOSubWebs -Recurse | where {$_.Url -eq $fullWebUrl}
            if ($web -eq $null)
            {
                $web = New-SPOWeb -Url $weburl -Title $sitetitle -Template $sitetemplate -Web $parentweb

                $web = Get-SPOSubWebs -Recurse | where {$_.Url -eq $fullWebUrl}
            } 

Should the New-SPOWeb set the ServerRelativeUrl of the web?

AddSPOListItem and Get-SPOContext

Hi having an issue with some code

Connect-SPOnline -url https://tenant.sharepoint.com/sites/Development -Credentials tenantCreds
$csv = Import-Csv C:\CSVs\ReportNumbers.csv
Get-SPOContext


foreach ($item in $csv)
    {
    $num = $item.EmployeeNumber
    Add-SPOListItem -List Tabs -Values @{"Title" = $num;}
    }

I get an error
format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

 + CategoryInfo          : NotSpecified: (:) [format-default], CollectionNotInitializedException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.FormatDefaultCommand

The code I have here isn't the exact piece that I orringally got the error with but it does replicate.
The reason I have the Get-SPOContext is that im using a foreach statement in which it downloads each item, extracts data from an InfoPath xml file, then adds to a SharePoint list.

I had to have the Get-SPO Context within the foreach as it would not load the file

          # Get the list item
            $spoItem = Get-SPOListItem -List ICP -Query "<View><Query><Where><Eq><FieldRef Name='Employee_x0020_Name' /><Value Type='Text'>$uName</Value></Eq></Where></Query><ViewFields><FieldRef Name='Employee_x0020_Name' /></ViewFields></View>"            
            $ctx = Get-SPOContext

            # get the file and properties
            $file=$spoItem.File
            $ctx.Load($file);            
            Execute-SPOQuery
            $spoItem.Name

[Apply-SPOProvisioningTemplate] Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, ..'

I've just had following error message, by trying to apply an existing template file, with cmdlet in subject:

  • Apply-SPOProvisioningTemplate: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
    At C:\Scripts\ApplyTemplate.ps1:17 char:1
  • Apply-SPOProvisioningTemplate -Path $tempFile *

However everything seems applied correctly. I'm wondering if this error can be ignored, or what is the source of this error

Importing Workflows

Exporting SharePoint designer workflows seems to be working. Importing workflows however gives me:

Apply-SPOProvisioningTemplate : Value cannot be null.
Parameter name: input

Is this a known issue or am I doing something wrong?

Enable-SPOFeature / Disable-SPOFeature not working as documented.

Hi,

After installing and activating a WSP through the GUI I tried disabling and enabling features as follows but noted that the results are not as expected:

PS C:\Development> Get-SPOFeature -scope site | ? {$_.DefinitionId -eq "45e2ca68-6010-4ca0-b78d-42ca13eec587"}


DefinitionId       : 45e2ca68-6010-4ca0-b78d-42ca13eec587
DisplayName        : Intranet_.Intranet.Core
Context            : Microsoft.SharePoint.Client.ClientContext
Tag                : 
Path               : Microsoft.SharePoint.Client.ObjectPathIdentity
ObjectVersion      : 
ServerObjectIsNull : False
TypedObject        : Microsoft.SharePoint.Client.Feature

After trying to disable it, I was expecting not to see it again.

PS C:\Development> Disable-SPOFeature -Identity "45e2ca68-6010-4ca0-b78d-42ca13eec587" -force

PS C:\Development> Get-SPOFeature -scope site | ? {$_.DefinitionId -eq "45e2ca68-6010-4ca0-b78d-42ca13eec587"}


DefinitionId       : 45e2ca68-6010-4ca0-b78d-42ca13eec587
DisplayName        : .Intranet_.Intranet.Core
Context            : Microsoft.SharePoint.Client.ClientContext
Tag                : 
Path               : Microsoft.SharePoint.Client.ObjectPathIdentity
ObjectVersion      : 
ServerObjectIsNull : False
TypedObject        : Microsoft.SharePoint.Client.Feature

After disabling the feature through the GUI, Get-SPOFeature did not return anything. Now when I tried re-enabling it, I got the following error:

PS C:\Development> Enable-SPOFeature -Identity 45e2ca68-6010-4ca0-b78d-42ca13eec587 -scope site -Force
Enable-SPOFeature : Feature with Id '45e2ca68-6010-4ca0-b78d-42ca13eec587' is not installed in this farm, and cannot be added to this scope.
At line:1 char:1
+ Enable-SPOFeature -Identity 45e2ca68-6010-4ca0-b78d-42ca13eec587 -scope site -Fo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Enable-SPOFeature], ServerException
    + FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.Features.EnableFeature

Any thoughts?
Thanks,
-Haniel

SiteLogoUrl not found from web properties

I just tried setting web's SiteLogoUrl on on-premises Sharepoint 2013 (can't remember patch version) and I got that "SiteLogoUrl property not found". I tried this with Set-SPOSite cmdlet and also assigning to $web.SiteLogoUrl a value after which executing Execute-SPOQuery I got the error. The release which I'm using is the latest (october 2015 bits, I guess)

Issue with Add-SPOListItem

Hi,

I'm experiencing an issue trying to add items for a list. In the code below, I create a field, assign it to a new content type and then create a list with that content type as its default.

$field = Add-SPOField -DisplayName "My field" -InternalName "myfield" -Type Text -Group "My Group"
$pct = Get-SPOContentType -Identity "Item"
$ct = add-spocontenttype -name "My CT" -ParentContentType  $pct -Group "My group" 
Add-SPOFieldToContentType -field "My field" -ContentType "My CT"
new-spolist -title "My list" -url "mylist" -Template GenericList -EnableContentTypes

Add-SPOContentTypeToList -List "My list" -ContentType "My CT" -DefaultContentType

However, when I try add an item the following error comes up:

Add-SPOListItem -List "My list" -ContentType "My CT" -Values @{"Title"="my title"; "My field"="some data"}

Add-SPOListItem : Column 'aMy field' does not exist. It may have been deleted by another user.  /sites/deptest2/mylist
At line:1 char:1
+ Add-SPOListItem -List "My list" -ContentType "My CT" -Values @{"Title ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Add-SPOListItem], ServerException
    + FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.AddListItem

Thanks for your help.

Remove-SPOWebPart Documentation

Hi

The documentation for Remove-SPOWebPart is a little confusing there are 15 pairs of "Syntax" and "Parameters". I suspect there should only be one.

Here are some examples of the syntax for the MD file 👎
Remove-SPOWebPart -Title "Table of Contents" -ServerRelativePageUrl /Pages/Chickpeas.aspx

Remove-SPOWebPart -Identity "8a23981f-5d27-4904-b199-45a582101801" -ServerRelativePageUrl /Pages/Pulses.aspx

Regards

Nigel

Adapt the Cmdlets to be able to be released on the PowerShell Gallery

This is just a point for open discussion about the ability to publish the PnP modules to the PowerShell Gallery as well as from here as part of the monthly release cycle. I don't think that there will be much more work required to accomplish this but this would allow a single PowerShell Command to update the module after release vs the current possible Uninstall/Reinstall that can be required.

PowerShell 3.0 - DontShow parameters

I am not sure if this will actually classify as an issue, but I think it's worth bringing it up.
It seems that there are 8 commands that have obsolete parameters and are marked with the DontShow attribute.
However, this attribute is available only since PowerShell 4.0, so running the commands (such as New-SPOGroup) will fail in PowerShell 3.0. (btw, I am using the 15.0 version).

Should PowerShell 4.0 be a clear prerequisite stated also in the Readme ?

Set-SPOPropertyBagValue/Get-SPOPropertyBag not working?

I've ran a little test where I tried creating a property bag and then reading it:

Set-SPOPropertyBagValue -key SiteType -Value Practice

However, Get-SPOPropertyBag does not return the new property bag. Has anyone else faced this problem?

Thanks,
-Haniel

Progress bar on Apply-SPOProvisioningTemplate command

When running the Apply-SPOProvisioningTemplate command the progress bar doesn't disappear. This is a nice feature when things fail half way through during one of the steps. However when all steps completed successfully the progress bar should disappear ( like Write-Progress -Completed ).

This becomes mainly an issue when multiple sites are created using the Apply-SPOProvisioningTemplate command.

Get-SPOProvisioningTemplate command fails with an error

Hi,
I'm running Get-SPOProvisioningTemplate command against O365. After successfully connecting to the site using Connect-SPOnline, I ran the following command:
Get-SPOProvisioningTemplate -Out "c:/temp/template.xml"
Progress bar indicates that command is running, then the following error is displayed
error

SPOProvisioningTemplate and pages

I'm trying to copy my dev sites to test using the SPOProvisioningTemplate commands. So I'm running something like this:

if ($credentials -eq $null)
{
$credentials=(Get-Credential)
}

Connect-SPOnline -Url https://mytenant.sharepoint.com/sites/Dev -Credentials $credentials
Get-SPOProvisioningTemplate -Out E:\Projects\test.xml

Connect-SPOnline -Url https://mytenant.sharepoint.com/sites/Test -Credentials $credentials
Apply-SPOProvisioningTemplate -Path E:\Projects\test.xml

This all works great however I found quite a lot missing from my Test site. e.g. Pages and web parts on pages are not copied. Is this by design?

The pages are not in the export hence the import will not include the pages. Should I use Get-SPOFile/Add‑SPOPublishingPage/Add‑SPOWebPartToWebPartPage to create my pages?

Indexed=TRUE in SiteColumn Definition

When I set INDEXED to true in my Field definition in my template file then I am getting the following error:

Apply-SPOProvisioningTemplate : /Lists/RollingNews : Cannot complete this action.
Please try again.
At P:\TFS\Meggitt\Meggitt.Installer\Modules\Office365Module\Office365Module.psm1:179 char:13

  •         Apply-SPOProvisioningTemplate -Path $siteAssetTemplateXML -Web $web
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : WriteError: (:) [Apply-SPOProvisioningTemplate], ServerException
    • FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.Branding.ApplyProvisioningTemplate

WebClient REST Calls

Hello,

is is possible to integrate something like webclient to call any URL (e.g. REST) in SharePoint and use the current credentials/cookies (ADFS)?

Thanks.

Bernd

Set-SPOWebPartProperty, set Toolbar property on View web part.

Is it possible to set the toolbar property on a view with Set-SPOWebPartProperty?

I've tried this:

Set-SPOWebPartProperty -ServerRelativePageUrl /sites/dev-site/ListName/Forms/View Name.aspx -Identity 4f6edf75-3596-482b-b15e-7568293d27b6 -Key "Toolbar" -Value "None"

But I get error saying "File not found". I've also tried with the whole url to the view (with "View name.aspx") but it also says "File not found".

Lookup from Subweb to List in SiteCollection

I'm trying to create a universal provisioning template for a subsite. Is there any solution to provision a proper lookup to a list on a parent site collection?

When I manually add the Lookup Column from the parent site Collection it is working fine. Creating a provisioning template and apply it (to the same site) the connection to the List is broken and the lookup remains empty even if there are values on parent side.

Any suggestions?

Thanks
Roman

Add-SPOJavaScriptLink - Access Denied - User is Site Collection Admin

Hello,

Firstly thank you so much for putting this together!

I've been experimenting with the cmdlets and have had sucsess in creating a Web, uploading a file and setting a Webs logo

The cmdlet I'm most desperate to use however is Add-SPOJavaScriptLink. I have tried the following syntaxes but each one returns the error message at the bottom

I am a Site Collection admin for the Site in question and a Global Admin for the Office 365 tenancy

I would like to add the link at the Site Collection level but have also tried with -Scope set to Web

I couldn't see any prerequisites that I am missing.... can you point me in the correct direction?

Add-SPOJavaScriptLink -Key "ALjQuery" -URL "https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js" -Scope Site -Web "https://siteurl.sharepoint.com"

Add-SPOJavaScriptLink -Key "ALjQuery" -URL "~sitecollection/SiteAssets/jquery-1.9.0.min.js" -Scope Site

Add-SPOJavaScriptLink -Key "ALjQuery" -URL "/SiteAssets/jquery-1.9.0.min.js" -Scope Site

Add-SPOJavaScriptLink -Key "ALjQuery" -URL "SiteAssets/jquery-1.9.0.min.js" -Scope Site

Add-SPOJavaScriptLink -Key "ALjQuery" -URL "~sitecollection/SiteAssets/jquery-1.9.0.min.js" -Scope Site -Web "https://siteurl.sharepoint.com"

Add-SPOJavaScriptLink -Key "ALjQuery" -URL "https://siteurl.sharepoint.com/SiteAssets/jquery-1.9.0.min.js" -Scope Site -Web "https://siteurl.sharepoint.com"
Add-SPOJavaScriptLink : Access denied. You do not have permission to perform this action or access this resource.
At line:10 char:1
+ Add-SPOJavaScriptLink -Key "ALjQuery" -URL "~sitecollection/SiteAssets/jquery-1. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Add-SPOJavaScriptLink], ServerUnauthorizedAccessException
    + FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.AddJavaScriptLink

PowerShell commands do not work with SiteCollections which have spaces in their url

PowerShell commands do not work well with SiteCollections which have spaces in their url. Trying to issue commands to these sites will produce NullReference execptions.

Powershell script which reproduces the problem:

$username = "username"
$password = convertto-securestring "password" -asplaintext -force
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password
$url = "https://tenant.sharepoint.com/sites/site%20with%20space"
Connect-SPOnline –Url $url –Credentials $credentials
Get-SPOSubWebs |  foreach-object { write-host $_.Url }

This is because:

  • SPOnlineConnection constructor stores the url with spaces in Url property
  • InstantiateSPOnlineConnection creates the ClientContext using Uri.AbsoluteUri (which converts the spaces to "%20")
  • CurrentConnection.Url is compared to CurrentConnection.Context.Url when handling connecton caching.

I'll create a pull request which modifies the SPOnlineConnection constructor to use the Uri.AbsoluteUri too.

Exporting a blog site generates invalid template xml

When exporting a Blog site the following part is generated for the Categories list:

< pnp:ListInstance Title="Categories" Description="Use the Categories list to define the categories available for posts." DocumentTemplate="" TemplateType="303" Url="Lists/Categories" MinorVersionLimit="0" MaxVersionLimit="0" TemplateFeatureID="faf00902-6bab-4583-bd02-84db191801d8" EnableAttachments="false" EnableFolderCreation="false">
< pnp:ContentTypeBindings>
< pnp:ContentTypeBinding ContentTypeID="0x" Default="true" />
< /pnp:ContentTypeBindings>

The content type should be :
0x008DA85C755790C544A7B7FE91EF4D6AD5

Looking at the code in GetProvisioningTemplate.cs in the Core project it looks like the id of the parent is included on each list. For the Categories list this doesn't work and generates an invalid template.

List Instances Contain Base Content Types

I have been testing content types and list instances and finding this scenario difficult.

I create a site content type then a list. The list is configured to enable content types. I add my content type then remove the base content type. The provision list contains both the base content type AND my custom content type.

i.e. The provisioned list contains "Document" and "My Custom Document" content types even though my template only contains "My Custom Document" content type. I do not want the base "Document" content type included in the provisioned site. The same holds true for Lists where the "Item" Content type is included with my custom Content Type.

Install-SPOSolution returns error "Invalid Field Name"

Hi,

I'm trying to deploy a WSP to my Office 365 tenant. The manifest.xml file looks as follows:

<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="7da4b965-0514-4e14-ae87-a75618ab3e56" SharePointProductVersion="15.0">
  <Assemblies>
    <Assembly Location="Intranet.dll" DeploymentTarget="GlobalAssemblyCache" />
  </Assemblies>
  <FeatureManifests>
    <FeatureManifest Location="Intranet_.Intranet.Core\Feature.xml" />
    <FeatureManifest Location="Intranet_.Intranet.NewsSlider\Feature.xml" />
  </FeatureManifests>
</Solution>

When I enter the command Install-SPOSolution -PackageId 7da4b965-0514-4e14-ae87-a75618ab3e56 -SourceFilePath 'Intranet.wsp' it returns the following error:

Install-SPOSolution : Invalid field name. {33e33eca-7712-4f3d-ab83-6848789fc9b6}  /sites/deptest/_catalogs/design
At line:1 char:1
+ Install-SPOSolution -PackageId 7da4b965-0514-4e14-ae87-a75618ab3e56 -SourceFileP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Install-SPOSolution], ServerException
    + FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.InstallSolution

Where does the 33e33eca-7712-4f3d-ab83-6848789fc9b6 come from? I'm able to deploy the WSP successfully via the UI.

How to get lower-level webs using Get-SPOSubwebs

Hi,

I'm trying to automate some deployments that involve creation and deletion of sites. Imagine the scenario below:

New-SPOWeb -title X -url x -template "STS#0"
New-SPOWeb -title Y -url y -web x -template "STS#0" 
New-SPOWeb -title Z -url z -web x/y -template "STS#0" 

So my site structure looks something like that:

https://tenant.sharepoint.com/sites/deptest/x
https://tenant.sharepoint.com/sites/deptest/x/y
https://tenant.sharepoint.com/sites/deptest/x/y/z

I want to delete x using Remove-SPOWeb -url x -Force but that gives the error: There was a problem deleting Web site "/sites/deptest/x". Sites that have subsites or certain apps can't be deleted. Please try again after deleting all subsites and removing the apps.

I tried writing a recursive function to delete to propagate through all the sub webs and delete them.

The real problem I'm having is that I'm not sure how to use Get-SPOSubWebs to get sub webs at lower levels (lower than 1st level children from site collection). My recursive function below always returns only https://tenant.sharepoint.com/sites/deptest/x. How do I use it to get to /x/y and /x/y/z?

Here's what I have so far:

Function RemoveWeb()
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory=$true)]
        [String]$URL,
        [Parameter(Mandatory=$false)]
        [String]$Web,
        [Parameter(Mandatory=$false)]
        [Switch]$Recurse
     )
       if ($Recurse.IsPresent)
        {
            $subwebs = Get-SPOSubWebs -web ???    

            foreach($sw in $subwebs)
            {
                RemoveWeb -URL $sw.Url -Web $Web -Recurse
            }
        }
        $rw = Remove-SPOWeb -Web $Web -Url $URL -Force
    }
}

Thanks for all the help

Update modules to allow MFA enabled accounts to authenticate with SPO

In testing some of the New AzureAD MFA functionality there was a requirement to test connecting to SPO sites.

Using the PowerShell modules this throws an error message as below

PSMessageDetails      : 
Exception             : Microsoft.SharePoint.Client.IdcrlException: The sign-in name or password does not match one in 
                        the Microsoft account system.
                           at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String securityXml, String 
                        serviceTarget, String servicePolicy)
                           at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String username, String 
                        password, String serviceTarget, String servicePolicy)
                           at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticatio
                        nCookie(Uri url, String username, SecureString password)
                           at Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, 
                        Boolean refresh)
                           at 
                        Microsoft.SharePoint.Client.ClientRuntimeContext.SetupRequestCredential(ClientRuntimeContext 
                        context, HttpWebRequest request)
                           at Microsoft.SharePoint.Client.SPWebRequestExecutor.GetRequestStream()
                           at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
                           at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
                           at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
                           at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRunt
                        imeContext clientContext, Int32 retryCount, Int32 delay)
                           at 
                        Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext 
                        clientContext, Int32 retryCount, Int32 delay)
                           at OfficeDevPnP.PowerShell.Commands.Base.SPOnlineConnectionHelper.InstantiateSPOnlineConnect
                        ion(Uri url, PSCredential credentials, PSHost host, Boolean currentCredentials, Int32 
                        minimalHealthScore, Int32 retryCount, Int32 retryWait, Int32 requestTimeout, Boolean 
                        skipAdminCheck)
                           at OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnline.ProcessRecord()
                           at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [Connect-SPOnline], IdcrlException
FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnlin
                        e
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

I may be wrong but I'm sure there was a sample for enabling authentication with MFA for the PnP.Core library at some point? Though I may be thinking of ADFS?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.