Skip to content

Commit

Permalink
Merge branch 'dev' into SetList-Path
Browse files Browse the repository at this point in the history
  • Loading branch information
KoenZomers committed Sep 29, 2022
2 parents aa22df7 + e964ae9 commit b51e539
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 158 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `AlertTemplateName` paramter to `Add-PnPAlert` to allow configuring the Alert Template type name in the email. [#2362](https://github.com/pnp/powershell/pull/2362)
- Added `Get-PnPAzureADActivityReportDirectoryAudit` to retrieve the audit logs generated by Azure AD. [#2095](https://github.com/pnp/powershell/pull/2095)
- Added `-Path` option to `Set-PnPList` which allows the url of a list to be changed within the same site [#2381](https://github.com/pnp/powershell/pull/2381)
- Added `-Force` option to `Set-PnPListem` to force it to update a list item even without changing something. Can be useful in i.e. triggering a webhook. [#2396](https://github.com/pnp/powershell/pull/2396)
- Added `ImageUrl`, `PageImageAlignment`, `ImageHeight` and `ImageWidth` parameters to `Add-PnPPageTextPart` cmdlet so that users can add an inline image into a text webpart. [#2401](https://github.com/pnp/powershell/pull/2401)

### Changed
- Changed to no longer require `https://` to be prefixed when using `Connect-PnPOnline -Url tenant.sharepoint.com` [#2139](https://github.com/pnp/powershell/pull/2139)
Expand All @@ -36,9 +38,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Removed
- Marked `-Resource` parameter from `Get-PnPAccessToken` cmdlet as obsolete as it was not used anymore anyway. It will be removed in a future version. [#2182](https://github.com/pnp/powershell/pull/2182)
- Removed `-SystemUpdate` option from `Set-PnPListItem` as it has been deprecated two years ago. Use `-UpdateType SystemUpdate` instead [#2396](https://github.com/pnp/powershell/pull/2396)

### Fixed

- Fixed issue where passing in `-Connection` to `Disconnect-PnPOnline` would throw an exception [#2093](https://github.com/pnp/powershell/pull/2093)
- Fixed `Get-PnPSiteSearchQueryResults` throwing `Value cannot be null` exception [#2138](https://github.com/pnp/powershell/pull/2138)
- Fixed `New-PnPUPABulkImportJob` not returing the job Id [#2144](https://github.com/pnp/powershell/pull/2144)
Expand All @@ -54,7 +56,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed `Set-PnPTenant` cmdlet not working when `-Force` parameter is specified. [#2373](https://github.com/pnp/powershell/pull/2373)

### Contributors

- Marc Studer [Studermarc]
- Giacomo Pozzoni [jackpoz]
- Adam Wójcik [Adam-it]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PnP PowerShell

**PnP PowerShell** is a .NET Core 3.1 / .NET Framework 4.6.2 based PowerShell Module providing nearly 650 cmdlets that work with Microsoft 365 environments such as SharePoint Online, Microsoft Teams, Microsoft Project, Security & Compliance, Azure Active Directory, and more.
**PnP PowerShell** is a .NET Core 3.1 / .NET Framework 4.6.2 based PowerShell Module providing over 650 cmdlets that work with Microsoft 365 environments such as SharePoint Online, Microsoft Teams, Microsoft Project, Security & Compliance, Azure Active Directory, and more.

Last version | Last nightly version
-------------|---------------------
Expand Down
3 changes: 3 additions & 0 deletions build/Build-Nightly.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,7 @@ if ($runPublish -eq $true) {

# Write version back to version
Set-Content ./version.txt -Value $version -Force -NoNewline

# Generate predictor commands
../build/Generate-PredictorCommands.ps1 -Version $version
}
67 changes: 67 additions & 0 deletions build/Generate-PredictorCommands.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Param(
[Parameter(Mandatory = $true)]
[String]
$Version
)

try {

Write-Host "Generating PnP.PowerShell predictor commands for version $Version" -ForegroundColor Yellow

$json = @();

# get all files in the srcfiles folder
$files = Get-ChildItem -Path "..\documentation" -Filter "*.md" -Recurse;

# loop through each file
$files | ForEach-Object {

# get file name without extension
$baseName = $_.BaseName.ToLower();

# get the file data
$fileData = Get-Content $_.FullName -Raw;
# create a regex pattern to match the example code
$pattern = "(?s)(?<=### EXAMPLE .*``````powershell)(.*?)(?=``````)"

if($baseName -eq "connect-pnponline") {
$pattern = "(?s)(?<=### EXAMPLE .*``````)(.*?)(?=``````)";
}

$result = [regex]::Matches($fileData, $pattern);

$i = 1;
foreach ($item in $result) {

$value = $item.Value.Trim();

# replace \n with a semicolon
$value = $value.Replace("`n", " ; ");


# if the item value begins with the name of the file then add it to the json
if ($value.ToLower() -match "^$($baseName).*") {
$json += @{
"Command" = $value
"Rank" = $i
}
$i++;
}
}

}

# check if predictor folder exists in ..\resources folder
if (!(Test-Path -Path "..\resources\predictor")) {
# create the folder
New-Item -ItemType Directory -Path "..\resources\predictor" -Force;
}

# write the json to a file
$json | ConvertTo-Json -Depth 10 | Out-File -FilePath "..\resources\predictor\PnP.PowerShell.Suggestions.$($Version).json" -Encoding UTF8 -Force;
}
catch {
Write-Error $_.Exception.Message;
Write-Error "Error: Cannot generate predictor commands";
exit 1;
}
98 changes: 78 additions & 20 deletions documentation/Add-PnPPageTextPart.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ Adds a text element to a client-side page.

### Default
```powershell
Add-PnPPageTextPart [-Page] <PagePipeBind> -Text <String> [-Order <Int32>]
[-Connection <PnPConnection>] [<CommonParameters>]
Add-PnPPageTextPart -Page <PagePipeBind> -Text <String> [-Order <Int32>] [-ImageUrl <String>] [-PageImageAlignment <PageImageAlignment>] [-ImageWidth <Int32>] [-ImageHeight <Int32>] [-Connection <PnPConnection>]
```

### Positioned
```powershell
Add-PnPPageTextPart [-Page] <PagePipeBind> -Text <String> [-Order <Int32>] -Section <Int32>
-Column <Int32> [-Connection <PnPConnection>] [<CommonParameters>]
Add-PnPPageTextPart -Page <PagePipeBind> -Text <String> -Section <Int32> -Column <Int32> [-Order <Int32>] [-ImageUrl <String>]
[-PageImageAlignment <PageImageAlignment>] [-ImageWidth <Int32>] [-ImageHeight <Int32>] [-Connection <PnPConnection>]
```

## DESCRIPTION
Expand All @@ -38,6 +37,13 @@ Add-PnPPageTextPart -Page "MyPage" -Text "Hello World!"

Adds the text 'Hello World!' to the Page 'MyPage'

### EXAMPLE 2
```powershell
Add-PnPPageTextPart -Page "MyPage" -Text "Hello World!" -ImageUrl "/sites/contoso/SiteAssets/test.png"
```

Adds the text 'Hello World!' to the Page 'MyPage' with specified image as inline image.

## PARAMETERS

### -Column
Expand All @@ -54,20 +60,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Connection
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

```yaml
Type: PnPConnection
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Order
Sets the order of the text control. (Default = 1)

Expand Down Expand Up @@ -124,10 +116,76 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ImageUrl
Specifies the inline image to be added. Image will be added after the text content.

```yaml
Type: String
Parameter Sets: (All)

## RELATED LINKS
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PageImageAlignment
Specifies the inline image's alignment. Available values are Center, Left and Right.

```yaml
Type: PageImageAlignment
Parameter Sets: (All)

Required: False
Position: Named
Default value: Center
Accept pipeline input: False
Accept wildcard characters: False
```

### -ImageWidth
Specifies the width of the inline image.

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
```yaml
Type: Int32
Parameter Sets: (All)

Required: False
Position: Named
Default value: 150
Accept pipeline input: False
Accept wildcard characters: False
```

### -ImageHeight
Specifies the height of the inline image.

```yaml
Type: Int32
Parameter Sets: (All)

Required: False
Position: Named
Default value: 150
Accept pipeline input: False
Accept wildcard characters: False
```

### -Connection
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

```yaml
Type: PnPConnection
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
40 changes: 20 additions & 20 deletions documentation/Set-PnPListItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Updates a list item
### Single

```powershell
Set-PnPListItem [-List] <ListPipeBind> -Identity <ListItemPipeBind> [-ContentType <ContentTypePipeBind>]
[-Values <Hashtable>] [-UpdateType <UpdateType>] [-Label <String>] [-ClearLabel] [-Connection <PnPConnection>]
Set-PnPListItem [-List <ListPipeBind>] -Identity <ListItemPipeBind> [-ContentType <ContentTypePipeBind>]
[-Values <Hashtable>] [-UpdateType <UpdateType>] [-Label <String>] [-ClearLabel] [-Force] [-Connection <PnPConnection>]
```

### Batched

```powershell
Set-PnPListItem [-List] <ListPipeBind> -Identity <ListItemPipeBind> -Batch <PnPBatch> [-ContentType <ContentTypePipeBind>]
[-Values <Hashtable>] [-UpdateType <UpdateType> [-UpdateOverwriteVersion] [-Connection <PnPConnection>]
Set-PnPListItem [-List <ListPipeBind>] -Identity <ListItemPipeBind> -Batch <PnPBatch> [-ContentType <ContentTypePipeBind>]
[-Values <Hashtable>] [-UpdateType <UpdateType>] [-Force] [-Connection <PnPConnection>]
```

## DESCRIPTION
Expand Down Expand Up @@ -200,21 +200,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -UpdateOverwriteVersion

Update the item without creating a new version. It will not trigger events registered on the list.

```yaml
Type: UpdateType
Parameter Sets: (All)

Required: False
Position: Named
Default value: Update
Accept pipeline input: False
Accept wildcard characters: False
```

### -ClearLabel

Clears the retention label of the item.
Expand Down Expand Up @@ -283,6 +268,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Force

Forces update of the list item even if there are no value changes. This can be useful for triggering webhooks, event receivers, Flows, etc.

```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
2 changes: 1 addition & 1 deletion pnpframework_hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c65a073a2cdf358707470d425e309795351ddd43
83eaf1f88370b8fd35245a3ce2a01272178f4869
6 changes: 4 additions & 2 deletions src/Commands/Apps/GrantAzureADAppSitePermission.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
using System;
using System.Linq;
using System.Management.Automation;

using PnP.PowerShell.Commands.Attributes;
using PnP.PowerShell.Commands.Base;
using PnP.PowerShell.Commands.Base.PipeBinds;
using PnP.PowerShell.Commands.Enums;
using PnP.PowerShell.Commands.Model;
using PnP.PowerShell.Commands.Utilities;

namespace PnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsSecurity.Grant, "PnPAzureADAppSitePermission")]
[RequiredMinimalApiPermissions("Sites.FullControl.All")]
public class GrantPnPAzureADAppSitePermission : PnPGraphCmdlet
{

[Parameter(Mandatory = true)]
[ValidateNotNullOrEmpty]
public Guid AppId;
Expand All @@ -25,7 +27,7 @@ public class GrantPnPAzureADAppSitePermission : PnPGraphCmdlet
public SitePipeBind Site;

[Parameter(Mandatory = true)]
[ValidateSet("Write", "Read")]
[ArgumentCompleter(typeof(EnumAsStringArgumentCompleter<AzureADNewSitePermissionRole>))]
public string[] Permissions;

protected override void ExecuteCmdlet()
Expand Down
7 changes: 5 additions & 2 deletions src/Commands/Apps/SetAzureADAppSitePermission.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.Linq;
using System.Management.Automation;

using PnP.PowerShell.Commands.Attributes;
using PnP.PowerShell.Commands.Base;
using PnP.PowerShell.Commands.Base.PipeBinds;
using PnP.PowerShell.Commands.Enums;
using PnP.PowerShell.Commands.Model;
using PnP.PowerShell.Commands.Utilities;

namespace PnP.PowerShell.Commands.Apps
{
Expand All @@ -21,7 +24,7 @@ public class SetPnPAzureADAppSitePermission : PnPGraphCmdlet
public SitePipeBind Site;

[Parameter(Mandatory = true)]
[ValidateSet("Write", "Read", "Manage", "FullControl")]
[ArgumentCompleter(typeof(EnumAsStringArgumentCompleter<AzureADUpdateSitePermissionRole>))]
public string[] Permissions;

protected override void ExecuteCmdlet()
Expand All @@ -44,7 +47,7 @@ protected override void ExecuteCmdlet()
roles = Permissions.Select(p => p.ToLower()).ToArray()
};

var results = PnP.PowerShell.Commands.Utilities.REST.RestHelper.PatchAsync<AzureADAppPermissionInternal>(Connection.HttpClient, $"https://{Connection.GraphEndPoint}/v1.0/sites/{siteId}/permissions/{PermissionId}", AccessToken, payload).GetAwaiter().GetResult();
var results = Utilities.REST.RestHelper.PatchAsync<AzureADAppPermissionInternal>(Connection.HttpClient, $"https://{Connection.GraphEndPoint}/v1.0/sites/{siteId}/permissions/{PermissionId}", AccessToken, payload).GetAwaiter().GetResult();
WriteObject(results.Convert());
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/Commands/Base/PipeBinds/ContentTypePipeBind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ internal PnPCore.IContentType GetContentTypeOrWarn(Cmdlet cmdlet, PnPCore.IList
return ct;
}

internal PnP.Core.Model.SharePoint.IContentType GetContentTypeOrWarn(Cmdlet cmdlet, PnPBatch batch, PnP.Core.Model.SharePoint.IList list)
{
var ct = GetContentType(batch, list);
if (ct is null)
cmdlet.WriteWarning(NotFoundMessage(list));

return ct;
}

private string NotFoundMessage(bool searchInSiteHierarchy)
=> $"Content type '{this}' not found in site{(searchInSiteHierarchy ? " hierarchy" : "")}.";

Expand Down
Loading

0 comments on commit b51e539

Please sign in to comment.