Skip to content

Instantly share code, notes, and snippets.

@exactmike
Last active February 18, 2020 15:59
Show Gist options
  • Select an option

  • Save exactmike/e0f8638ec557c63325804b57e504327f to your computer and use it in GitHub Desktop.

Select an option

Save exactmike/e0f8638ec557c63325804b57e504327f to your computer and use it in GitHub Desktop.
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
)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201
Install-Module -Name PowerShellGet -Scope CurrentUser -Force
Install-Module -Name Office365DSC -Scope CurrentUser -Force
$GACredential = Get-Credential -UserName $Username -Message "O365 Admin"
Import-Module -Name Office365DSC
Set-O365DSCTelemetryOption -Enabled $False #prevents telemetry data from being sent to Azure for this module
Start-O365ConfigurationExtract -Path $Path -GlobalAdminAccount $GACredential -AllComponents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment