Skip to content

Instantly share code, notes, and snippets.

View AsishP's full-sized avatar

Asish Padhy AsishP

  • Sydney, Australia
View GitHub Profile
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;
}
[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
)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber
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}
// 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
}
}
// Using pnpjs to get items and
public componentDidMount()
{
sp.web.lists.getByTitle(listTitle).items.get().then((items: Item[]) => {
this.setState({
stateValue : items
});
});
}
// Do a REST Query to get data from REST using spHttpClient
public componentWillMount()
{
const items: any = await this.props.context.spHttpClient.get(restApi, SPHttpClient.configurations.v1, {
headers: {
'Accept': 'application/json;odata.metadata=none'
}
}).then(resp => resp.json());
}
// SPFx context init below
public onInit(): Promise<void> {
return super.onInit().then(_ => {
// other init code may be present
sp.setup({
spfxContext: this.context
});
});
}
Set-PnPTraceLog -On -LogFile "<Location in hard drive>" -Level Debug
Apply-PnPProvisioningTemplate -Path "<Folder location>" -ClearNavigation -IgnoreDuplicateDataRowErrors
## Create a SharePoint classic site
New-PnPTenantSite -Title "Title" -Url "https://tenant.sharepoint.com/sites/site1" -Lcid 1033 -TimeZone <TimeZoneID> -Template "STS#0" -StorageQuota <Size in MB> -StorageQuotaWarningLevel <Size in MB> -ResourceQuota <quota number> -Description "description" -Owner "owner@tenant.com" -RemoveDeletedSite -Wait
## Create a new Modern SharePoint site
New-PnPSite -Title "Title" -Url "https://tenant.sharepoint.com/sites/test" -Type CommunicationSite -SiteDesign Showcase -Description "description"