Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1726 from erwinvanhunen/dev
Browse files Browse the repository at this point in the history
Added Get-PnPException cmdlet
  • Loading branch information
erwinvanhunen authored Oct 8, 2018
2 parents f8d0cbb + 324b921 commit c892448
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 29 deletions.
29 changes: 15 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [3.2.1810.0] Unreleased
### Added
- Add-PnPProvisioningSequence
- Add-PnPProvisioningSite
- Add-PnPProvisioningSubSite
- Apply-PnPProvisioningHierarchy
- Get-PnPProvisioningSite
- New-PnPProvisioningHierarchy
- New-PnPProvisioningSequence
- New-PnPProvisioningCommunicationSite
- New-PnPProvisioningTeamNoGroupSite
- New-PnPProvisioningTeamNoGroupSubSite
- New-PnPProvisioningTeamSite
- Read-PnPProvisioningHierarchy
- Save-PnPProvisioningHierarchy
- Test-PnPProvisioningHierarchy
- Add-PnPProvisioningSequence : Adds an in-memory sequence to an in-memory provisioning hierarchy
- Add-PnPProvisioningSite : Adds an in-memory site definition to a in-memory sequence
- Add-PnPProvisioningSubSite : Adds an in-memory sub site defintion to an in-memory site
- Apply-PnPProvisioningHierarchy : Applies a provisioninghierarchy with a site sequence to a tenant
- Get-PnPProvisioningSite : Returns a site as an in-memory object from a given provisioning hierarchy
- New-PnPProvisioningHierarchy : Creates a new in-memory provisioning hierarchy
- New-PnPProvisioningSequence : Creates a new in-memory provisioning sequence
- New-PnPProvisioningCommunicationSite : Creates a new in-memory communication site definition
- New-PnPProvisioningTeamNoGroupSite : Creates a new in-memory team site definition which has no associated office365 group
- New-PnPProvisioningTeamNoGroupSubSite : Creates a new in-memory team sub site definition which has no associated office365 group
- New-PnPProvisioningTeamSite : Creates a new in-memory team site definition
- Read-PnPProvisioningHierarchy : Reads an existing (file based) provisioning hierarchy into an in-memory instance
- Save-PnPProvisioningHierarchy : Saves an in-memory provisioning hierarchy to a pnp file
- Test-PnPProvisioningHierarchy : Tests an in-memory hierarchy if all template references are correct in the site sequence
- Get-PnPException : Returns the last occured exception that occured while using PowerShell.

### Changed
- Updated Set-PnPSite to allow for setting of a logo on modern team site
Expand Down
48 changes: 48 additions & 0 deletions Commands/Base/GetException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Model;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Base
{
[Cmdlet(VerbsCommon.Get, "PnPException")]
[CmdletHelp("Returns the last exception that occured",
@"Returns the last exception which can be used while debugging PnP Cmdlets",
Category = CmdletHelpCategory.Base)]
[CmdletExample(
Code = @"PS:> Get-PnPException",
Remarks = "Returns the last exception",
SortOrder = 1)]
[CmdletExample(
Code = @"PS:> Get-PnPException -All",
Remarks = "Returns all exceptions that occurred",
SortOrder = 2)]
public class GetException : PSCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "Show all exceptions")]
public SwitchParameter All;

protected override void ProcessRecord()
{
var exceptions = (ArrayList)this.SessionState.PSVariable.Get("error").Value;
if (exceptions.Count > 0)
{
var output = new List<PnPException>();
if (All.IsPresent)
{
foreach (ErrorRecord exception in exceptions)
{
output.Add(new PnPException() { Message = exception.Exception.Message, Stacktrace = exception.Exception.StackTrace, ScriptLineNumber = exception.InvocationInfo.ScriptLineNumber, InvocationInfo = exception.InvocationInfo });
}
}
else
{
var exception = (ErrorRecord)exceptions[0];
output.Add(new PnPException() { Message = exception.Exception.Message, Stacktrace = exception.Exception.StackTrace, ScriptLineNumber = exception.InvocationInfo.ScriptLineNumber, InvocationInfo = exception.InvocationInfo });
}
WriteObject(output, true);
}
}
}
}
17 changes: 17 additions & 0 deletions Commands/Model/PnPException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;

namespace SharePointPnP.PowerShell.Commands.Model
{
public class PnPException
{
public string Message;
public string Stacktrace;
public int ScriptLineNumber;
public InvocationInfo InvocationInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1306,5 +1306,28 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PnPException</Name>
<ViewSelectedBy>
<TypeName>SharePointPnP.PowerShell.Commands.Model.PnPException</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Message</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Stacktrace</PropertyName>
</ListItem>
<ListItem>
<PropertyName>ScriptLineNumber</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -1306,5 +1306,28 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PnPException</Name>
<ViewSelectedBy>
<TypeName>SharePointPnP.PowerShell.Commands.Model.PnPException</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Message</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Stacktrace</PropertyName>
</ListItem>
<ListItem>
<PropertyName>ScriptLineNumber</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
63 changes: 50 additions & 13 deletions Commands/ModuleFiles/SharePointPnP.PowerShell.Core.Format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -589,30 +589,30 @@
<TableColumnItem>
<ScriptBlock>
if($_.Name -eq ""){
$_.ServerRelativeUrl.TrimEnd("/").Substring($_.ServerRelativeUrl.TrimEnd("/").LastIndexOf("/") + 1)
$_.ServerRelativeUrl.TrimEnd("/").Substring($_.ServerRelativeUrl.TrimEnd("/").LastIndexOf("/") + 1)
}
else{
$_.Name
$_.Name
}
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
if($_.GetType().Name -eq "Folder" -and $_.Name -eq ""){
"Subweb"
"Subweb"
}
else{
$_.GetType().Name
$_.GetType().Name
}
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
if($_.GetType().Name -eq "File"){
$_.Length
$_.Length
}
else{
$_.ItemCount
$_.ItemCount
}
</ScriptBlock>
</TableColumnItem>
Expand Down Expand Up @@ -801,6 +801,9 @@
<Width>36</Width>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Child Terms</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
Expand All @@ -811,6 +814,16 @@
<TableColumnItem>
<PropertyName>Id</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
if($_.IsObjectPropertyInstantiated("Terms")){
$_.TermsCount
}
else{
"$($_.TermsCount) (Not loaded)"
}
</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
Expand Down Expand Up @@ -1290,7 +1303,7 @@
<TableColumnHeader>
<Label>Alias</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
Expand Down Expand Up @@ -1366,7 +1379,8 @@
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View><View>
</View>
<View>
<Name>TenantSiteDesign</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Online.SharePoint.TenantAdministration.TenantSiteDesign</TypeName>
Expand Down Expand Up @@ -1439,7 +1453,7 @@
<TableColumnItem>
<PropertyName>Version</PropertyName>
</TableColumnItem>
<TableColumnItem>
<TableColumnItem>
<PropertyName>Content</PropertyName>
</TableColumnItem>
</TableColumnItems>
Expand Down Expand Up @@ -1515,7 +1529,7 @@
<Label>Position</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<TableColumnHeader>
<Label>PropertiesJson</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
Expand All @@ -1541,20 +1555,20 @@
<TableColumnItem>
<PropertyName>Order</PropertyName>
</TableColumnItem>
<TableColumnItem>
<TableColumnItem>
<PropertyName>PropertiesJson</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<View>
<Name>NavigationNode</Name>
<ViewSelectedBy>
<TypeName>Microsoft.SharePoint.Client.NavigationNode</TypeName>
</ViewSelectedBy>
<TableControl>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Id</Label>
Expand Down Expand Up @@ -1780,5 +1794,28 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PnPException</Name>
<ViewSelectedBy>
<TypeName>SharePointPnP.PowerShell.Commands.Model.PnPException</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Message</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Stacktrace</PropertyName>
</ListItem>
<ListItem>
<PropertyName>ScriptLineNumber</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,10 @@
<TableColumnItem>
<ScriptBlock>
if($_.IsObjectPropertyInstantiated("Terms")){
$_.TermsCount
$_.TermsCount
}
else{
"$($_.TermsCount) (Not loaded)"
"$($_.TermsCount) (Not loaded)"
}
</ScriptBlock>
</TableColumnItem>
Expand Down Expand Up @@ -1846,5 +1846,28 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PnPException</Name>
<ViewSelectedBy>
<TypeName>SharePointPnP.PowerShell.Commands.Model.PnPException</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Message</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Stacktrace</PropertyName>
</ListItem>
<ListItem>
<PropertyName>ScriptLineNumber</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
2 changes: 2 additions & 0 deletions Commands/SharePointPnP.PowerShell.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@
<Compile Include="Admin\RemoveTenantTheme.cs" />
<Compile Include="Base\AddStoredCredential.cs" />
<Compile Include="Base\DisablePowerShellTelemetry.cs" />
<Compile Include="Base\GetException.cs" />
<Compile Include="Base\GetPowerShellTelemetryEnabled.cs" />
<Compile Include="Base\EnablePowerShellTelemetry.cs" />
<Compile Include="Base\GetAccessToken.cs" />
Expand All @@ -480,6 +481,7 @@
<Compile Include="Enums\StorageEntityScope.cs" />
<Compile Include="InformationManagement\GetLabel.cs" />
<Compile Include="InformationManagement\SetLabel.cs" />
<Compile Include="Model\PnPException.cs" />
<Compile Include="Model\ServicePrincipalPermissionGrant.cs" />
<Compile Include="Navigation\GetNavigationNode.cs" />
<Compile Include="Branding\SetWebTheme.cs" />
Expand Down

0 comments on commit c892448

Please sign in to comment.