Skip to content

Instantly share code, notes, and snippets.

Asish Padhy AsishP

  • Sydney, Australia
View GitHub Profile
@AsishP
AsishP / SingleWebPartApp.ps1
Last active Feb 27, 2019
Add Single Web Part App Page
View SingleWebPartApp.ps1
Connect-PnPOnline -Url "https://sharepoint.com"
## Add Page using PnP PowerShell
$page = Add-PnPClientSidePage -Name "TestAppPart.aspx" -LayoutType SingleWebPartAppPage
## Add a section the Page
Add-PnPClientSidePageSection -Page $page -SectionTemplate OneColumnFullWidth
## Add a Client Side Web Part
Add-PnPClientSideWebPart -Page $page -DefaultWebPartType SiteActivity -Section 0 -Column 0
View MasterComponentReactControl
export default class MasterComponent extends React.Component<MasterComponentProps, MasterComponentState> {
constructor()
{
super();
this._childSelect = this._childSelect.bind(this);
this.state= {
stateprop1 : null,
stateprop2 : true
}
View ChildComponentReactControl
import * as React from 'react';
import { ChildComponentState } from './ChildComponentState';
import { WebPartContext } from '@microsoft/sp-webpart-base';
export interface ChildComponentProps
{
context : WebPartContext;
childoutput?: (item: any) => void;
}
@AsishP
AsishP / Get data from Office 365 Azure Log
Last active Jan 1, 2019
Get data from Office 365 Azure Log
View Get data from Office 365 Azure Log
//JSON object for Initial Call
public class AuditInitialReport
{
public string ContentUri { get; set; }
public string ContentId { get; set; }
public string ContentType { get; set; }
public string ContentCreated { get; set; }
public string ContentExpiration { get; set; }
}
@AsishP
AsishP / Connect to Azure AD in Azure Function
Last active Apr 9, 2019
Connect to Azure AD in Azure Function
View Connect to Azure AD in Azure Function
string TenantID = <TenantID>;
string authString = "https://login.windows.net/" + TenantID;
string SPServiceUrl = "https://manage.office.com/api/v1.0/" + TenantID + "/activity/feed/subscriptions/content";
string resourceId = "https://manage.office.com";
string clientId = <Client App Id>;
string clientSecret = <Client App secret>;
var authenticationContext = new AuthenticationContext(authString, false);
ClientCredential clientCred = new ClientCredential(clientId, clientSecret);
AuthenticationResult authenticationResult = null;
View Azure Table Scripts reading from CSV
[Reflection.Assembly]::LoadWithPartialName("System.Web.Script.Serialization")
$resourceName = "<Resource Group Name>"
$azureStorage = "<Storage Container Name>"
$azureTable = "<Azure Storage Table>"
$Credential = Get-Credential
function UploadDataToAzureTableStorage {
param (
[Parameter(Mandatory = $true, HelpMessage = 'Please provide the FileName')][ValidateNotNullOrEmpty()][String]$fileName
)
View Search Unified Audit Log
$data = Search-UnifiedAuditLog
-StartDate $startInterval
-EndDate $endInterval
-Operations FileAccessed, FilePreviewed, PageViewed, PageViewedExtended, SearchViewed, CompanyLinkUsed, SecureLinkUsed, FileDownloaded, FileModified, FileUploaded, FileDeleted, FolderModified, CompanyLinkCreated, SharingInheritanceBroken, ListUpdated, FileSyncDownloadedFull, FileSyncUploadedFull
-SessionId $sessionId
-SessionCommand ReturnLargeSet
-ResultSize 5000
## Start Date - Date and Time in local Computer Date Time format
## End Date - Date and Time in local Computer Date Time format
## Operations - For more information see here - https://docs.microsoft.com/en-gb/office365/securitycompliance/search-the-audit-log-in-security-and-compliance#sharing-and-access-request-activities
View Import Exchange Online PowerShell
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber
View React renderMethod
public render(): React.ReactElement<IProps> {
return (
<div>
{
this.props.properties ? (
<TooltipHost content={this.props.tooltipMessage || strings.message}
id='pntp'
calloutProps={{ gapSpace: 0 }}
directionalHint={this.props.tooltipDirectional || DirectionalHint.leftTopEdge}>
{componentHTML}
View React componentDidUpdate
// Check the component properties and state for changes
public componentDidUpdate(prevProps : IProps, prevState : IState) : void
{
// If properties have changed bind it
if(this.props.properties !== prevProps.properties || this.state.stateValue !== prevState.stateValue)
{
//Do more things here
}
}
You can’t perform that action at this time.