Skip to content

Instantly share code, notes, and snippets.

@mrik23
mrik23 / PnP-SharePointOnline-RestAPI-AuthAccessToken.ps1
Last active July 9, 2019 15:05
PowerShell script to demonstrate how to make calls to SharePoint Online API using authorization token retrieved with PnP PowerShell
<#
PowerShell script to demonstrate how to make calls to SharePoint Online API using authorization token retrieved with PnP PowerShell
This should work if the SharePoint tenant has LegacyAuthProtocolsEnabled as FALSE (legacy form based auth not authorized)
You need to have SharePoint Online PnP PowerShell installed https://github.com/SharePoint/PnP-PowerShell
#>
$spoUrl = "https://<tenant>.sharepoint.com"
$connection = Connect-PnPOnline -Url $spoUrl -Credentials UserCredential -ReturnConnection
@mrik23
mrik23 / AADSigninsReport.ps1
Last active March 25, 2021 07:11
PowerShell script using the Microsoft Graph API to retrieve Azure AD Audit Log Sign-ins and send the report by email using Microsoft Flow. This script is ready to be used with Azure Functions.
<#
This script retrieves Azure Active Directory Sign-in logs for privileged users from the Microsoft Graph API and send an email report.
Only the sign-ins for the last day will be retrieved (that can be modified with $startDate $endDate).
See the official documentation for more info on the Audit logs API:
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/signin
To connect to the Microsoft Graph API you need to provide ClientId, ClientSecret and TenantDomain.
@mrik23
mrik23 / SharePoint-Modern-Page-ClientSideText.html
Last active September 18, 2018 13:32
HTML content example from SharePoint modern page Text Webpart. See image example https://ibb.co/ffB0Ge.
<p>Normal text<strong> Bold text</strong><em> italic text</em><u> Underline text </u><span class="fontSizeSmall">Font size 12 </span><a data-interception="off" href="https://www.google.com">Link</a></p>
<p><span class="fontColorThemePrimary">Color theme primary</span><span class="fontColorRed"> Color pick red</span>&nbsp; <span class="highlightColorYellow">Highlight color yellow</span></p>
<p style="text-align:center;">Centered text</p>
<p style="text-align:right;">Left text</p>
<p style="text-align:justify;">Justified text</p>
@mrik23
mrik23 / MicrosoftTeams-GetTeamLink.ps1
Last active April 17, 2022 17:38
Script to construct team link using Microsoft Teams PowerShell module
@mrik23
mrik23 / SPO-GetSiteExternalUsersModernSharing.ps1
Created April 8, 2018 07:17
PowerShell script to retrieve external users that have been added via modern sharing experience on files and folders (with verification code to email). These users are not retrieved with Get-SPOExternalUser and not present in Azure AD.
<#
Script to retrieve external users that have been added via modern sharing experience on files and folders (with verification code to email).
These users are not retrieved with Get-SPOExternalUser cmdlet and not added as guest users in Azure AD.
Requires: SharePoint Online Management Shell > https://www.microsoft.com/en-us/download/details.aspx?id=35588
#>
Connect-SPOService -Url https://<tenantName>-admin.sharepoint.com
@mrik23
mrik23 / Test-LeakedPasswordHIBP.ps1
Last active August 3, 2022 20:28
PowerShell script to check password against leaked password database from https://haveibeenpwned.com/ using the Pwned Passwords V2 API. Only the first 5 characters of the password string hash is checked against the API (k-anonymity). More info on the HIBP API at https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2/.
#requires -version 4
<#
.SYNOPSIS
Check password against leaked password database from https://haveibeenpwned.com/ using the Pwned Passwords V2 API https://api.pwnedpasswords.com/range/<hashPrefix>.
.DESCRIPTION
Only the first 5 characters of the password string hash is checked against the API (k-anonymity). The API returns a list of all passwords matching the hash prefix, then the script checks if the suffix is present or not.
@mrik23
mrik23 / AADRiskySigninsNotification.ps1
Last active March 26, 2024 11:51
PowerShell script using the Microsoft Graph REST API to retrieve Azure AD Risky Sign-ins events and send an email notification using also the Microsoft Graph API. This script can be used in Azure Function and using the application settings variables. Go to https://medium.com/@zaab_it/azure-ad-risky-sign-ins-email-notification-6cbfac32f6de for mo…
<#
This script retrieves Azure Active Directory Risk Sign-in Events from the Microsoft Graph API and send an email alert report.
Only the active events from the last 30 days will be retrieved (that can be modified via the $filter value in uriGraphEndpoint or removed to get all events).
See the official documentation for more info:
https://docs.microsoft.com/en-us/azure/active-directory/active-directory-identityprotection-graph-getting-started
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_sendmail
#>
@mrik23
mrik23 / SPO-Column-Formating-Example08.json
Created February 3, 2018 09:50
SharePoint Online JSON script to custom format a person column with a mailto link. This example shows how to convert a column date content to a string. The operators toString() or toLocaleString() could also be used, depending on the desired format output.
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"children": [
{
"elmType": "span",
"style": {
"padding-right": "8px"
},
@mrik23
mrik23 / EOL-DisableMailboxAccessForAllProtocols.ps1
Created January 30, 2018 11:33
PowerShell one-liner script to remove email access for one user (disable POP IMAP MAPI OWA ActiveSync and Outlook app for iOS and Android). Tested on Exchange Online.
Set-CASMailbox -Identity someone@contoso.com -PopEnabled $False -ImapEnabled $False -MAPIEnabled $False -OWAEnabled $False -ActiveSyncEnabled $False -OWAforDevicesEnabled $false -EWSEnabled $False -EwsBlockList @{Add="Outlook-iOS/*","Outlook-Android/*"}
### Re-enable all protocols ###
#Set-CASMailbox -Identity someone@contoso.com -PopEnabled $true -ImapEnabled $true -MAPIEnabled $true -OWAEnabled $true -ActiveSyncEnabled $true -OWAforDevicesEnabled $true -EWSEnabled $true -EwsBlockList @{Remove="Outlook-iOS/*","Outlook-Android/*"} -EwsApplicationAccessPolicy $null
@mrik23
mrik23 / Windows10-Unbloating-v1.ps1
Created December 27, 2017 12:52
PowerShell script to remove bloatware shipped in Windows 10 and disabled unwanted features. Tested on version 1709.
# Windows 10 Unbloating
# Inspired by:
# https://github.com/W4RH4WK/Debloat-Windows-10/blob/master/scripts/remove-default-apps.ps1
# https://github.com/Disassembler0/Win10-Initial-Setup-Script/blob/master/Win10.ps1
# Uninstall default Microsoft applications
$MsftBloatApps = @(
"Microsoft.3DBuilder"
"Microsoft.BingFinance"
"Microsoft.BingNews"