Skip to content

Instantly share code, notes, and snippets.

View exactmike's full-sized avatar

Mike Campbell exactmike

View GitHub Profile
@exactmike
exactmike / ExportOffice365Configuration.ps1
Last active February 18, 2020 15:59
A script to install and use the Office365DSC PowerShell Module to export an Office 365 Tenant's Configuration
[cmdletbinding()]
param(
#Specify the username to use for extracting Office 365 Configuration. Should be Global Admin or Equivalent Read access. The script will prompt for password.
[parameter()]
[string]$UserName
,
#Path to a directory for the output of the script. Any existing output may be overwritten. If the directory does not exist, it will be created if possible.
[string]$Path
)
@exactmike
exactmike / PlannerMigration.ps1
Created November 11, 2019 22:51 — forked from AlexanderHolmeset-zz/PlannerMigration.ps1
Microsoft Planner Tenant To Tenant Migration
### Microsoft Planner Tenant To Tenant Migration Script ###
### ###
### Version 1.0 ###
### ###
### Author: Alexander Holmeset ###
### ###
### Twitter: twitter.com/alexholmeset ###
### ###
### Blog: alexholmeset.blog ###
@exactmike
exactmike / Get-SharePointSiteSize.ps1
Created October 15, 2019 00:40
SharePoint report functions
<#
.SYNOPSIS
Gets and exports a csv format Storage Report for all sites in all web applications
.DESCRIPTION
Gets and exports a csv format Storage Report for all sites in all web applications
.EXAMPLE
Get-SharePointSiteSize.ps1 -FilePath SiteSizeReport.csv
Gets a report of storage usage for all sites in all web apps on the attached farm and exports it to SiteSizeReport.csv in the current path
.INPUTS
[string]
@exactmike
exactmike / Get-DateSeries.Tests.ps1
Created February 11, 2019 23:25
Get-DateSeries
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
$defaultParamCount = 11
[object[]]$params = (Get-ChildItem "function:\$CommandName").Parameters.Keys
$knownParameters = 'Start','Interval','Units','Limit','SkipStart'
$paramCount = $knownParameters.Count
It "Should contain specific parameters" {
( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount
@exactmike
exactmike / Out-FileUtf8NoBom.ps1
Created December 11, 2018 19:18
PowerShell function to output a file in UTF8 encoding with no BOM
function Out-FileUtf8NoBom
{
#requires -version 3
<#
.SYNOPSIS
Outputs to a UTF-8-encoded file *without a BOM* (byte-order mark).
.DESCRIPTION
Mimics the most important aspects of Out-File:
* Input objects are sent to Out-String first.
@exactmike
exactmike / GetSelectedUserOneDriveSiteInfo.ps1
Last active November 28, 2018 20:58
Gets OneDrive User Site Information from an Microsoft 365 Tenant for a specified list of users.
#Import the required module
$Module = Get-Module -ListAvailable -Name 'Microsoft.Online.SharePoint.PowerShell' -ErrorAction Stop
if ($Null -eq $Module) {throw ("PowerShell Module Microsoft.Online.SharePoint.PowerShell was not found")}
else {
Import-Module -Name 'Microsoft.Online.SharePoint.PowerShell' -Force -Global -ErrorAction Stop -DisableNameChecking
}
#Get the administratiave credential
#$AdminCredential = Get-Credential -Message "Please provide the SharePoint Online Admin Credential" -ErrorAction Stop
#if ($null -eq $AdminCredential -or $AdminCredential.GetType().name -ne 'PSCredential') {throw ("SharePoint Online Admin Credential Required")}
@exactmike
exactmike / Connect-RDP.ps1
Created November 8, 2018 18:42
RDP Connection Function
function Connect-RDP {
param (
[Parameter(Mandatory=$true)]
[string[]]$ComputerName,
[System.Management.Automation.Credential()]
$Credential
)
#https://www.powershellmagazine.com/2014/04/18/automatic-remote-desktop-connection/
@exactmike
exactmike / CollatzConjecture.ps1
Created October 23, 2018 23:59
Collatz Conjecture
#https://en.wikipedia.org/wiki/Collatz_conjecture
function Test-CollatzConjecture
{
[cmdletbinding()]
param
(
[parameter(ParameterSetName = 'SpecifiedNumber')]
[int32]$BeginningNumber
,
@exactmike
exactmike / NestOPGroupInMasterOLGroupProcess.md
Created October 4, 2018 23:00
Nest OP Group in Master OL Group Process

Process for migrating cross forest DLs to Unified Cloud DL

Preparatory Steps to Intermediate State

  • User Specifies On Premises Distribution Lists to be nested
    • Validate that the identifier(s) are correct and the objects exist
  • Get the Distribution List Object(s)
    • Exchange On Premises Distribution List Object
    • Exchange Online Distribution List Object
  • Store Distribution List objects/attributes for later use/reference
@exactmike
exactmike / MSOnlineLicenseReporting.ps1
Last active October 4, 2018 16:47
Office 365 License Reporting with the MSOnline Module
#Get the available Skus and Usage from the tenant
Get-MsolAccountSku | Select-Object SkuPartNumber,ActiveUnits,ConsumedUnits,@{n='AvailableUnits';e={$_.ActiveUnits-$_.ConsumedUnits}} -OutVariable AllSkus
#Specify which skus you want to specifically report on
$SkusToReportOn = @('STANDARDPACK','ENTERPRISEPACK','ENTERPRISEPREMIUM')
#Report on Users/Sku Usage
$AllLicensedUsers = Get-MsolUser -all | ? IsLicensed -eq $true | Select DisplayName,UserPrincipalName,IsLicensed,@{n='Skus';e={@($_.Licenses.AccountSkuID)}}
#Below expands licensed users so that for each Sku in SkusToReportOn there would be an entry for the user if the user has more than one of them assigned
$ExpandedSkuUsers = @(
foreach ($lu in $AllLicensedUsers)