Skip to content

Instantly share code, notes, and snippets.

Avatar

Asish Padhy AsishP

  • Sydney, Australia
View GitHub Profile
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
}
}
View React componentDidMount
// Using pnpjs to get items and
public componentDidMount()
{
sp.web.lists.getByTitle(listTitle).items.get().then((items: Item[]) => {
this.setState({
stateValue : items
});
});
}
View React ComponentWillMount
// 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());
}
View React OnInit
// SPFx context init below
public onInit(): Promise<void> {
return super.onInit().then(_ => {
// other init code may be present
sp.setup({
spfxContext: this.context
});
});
}
View Apply PnP Provisioning Template PowerShell
Set-PnPTraceLog -On -LogFile "<Location in hard drive>" -Level Debug
Apply-PnPProvisioningTemplate -Path "<Folder location>" -ClearNavigation -IgnoreDuplicateDataRowErrors
View SharePoint Create Site PowerShell Command
## 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"
You can’t perform that action at this time.