Skip to content

Instantly share code, notes, and snippets.

@mrik23
mrik23 / AzureRM-CreateVmDiskEncryptionEnabled.ps1
Last active July 9, 2018 19:30
This PowerShell script create a new VM and enable disk encryption. Necessary components like Azure AD app and Key Vault are also created.
#Azure PowerShell v2
#Check documentation https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0
Import-Module AzureRM
$credential = Get-Credential
Login-AzureRmAccount -Credential $credential
#Set variables
$location = "eastus" #Find the choice of location with 'Get-AzureRmLocation | select location'
$rgName = "myResourceGroup" + (Get-Random -Maximum 99).ToString()
@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 / 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 / EOL-RemoveAllMailboxFolderPermissions.ps1
Created December 12, 2017 11:32
Exchange Online PowerShell script to remove added permissions on all foldders of an user's mailbox. Can be used with Exchange Online PowerShell module with MFA.
<#
.SYNOPSIS
EOL-RemoveAllMailboxFolderPermissions.ps1
.DESCRIPTION
A script to remove permissions from all folders present in a particular user mailbox.
.OUTPUTS
Console output for progress.
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"attributes": {
"class": {
"operator": "?",
"operands": [
{
"operator": "==",
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"children": [
{
"elmType": "span",
"style": {
"padding-right": "8px"
},
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": {
"operator": "?",
"operands": [
{
"This is a test." | Out-File ([Environment]::GetFolderPath("Desktop") + "\test.txt")
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": {
"operator": "?",
"operands": [
{