Skip to content

Instantly share code, notes, and snippets.

Avatar

AlexanderHolmeset

View GitHub Profile
View ExchangeCertificate.ps1
$connection = Get-AutomationConnection -Name AzureRunAsConnection
$tenant = 'alexholmeset.onmicrosoft.com'
Connect-ExchangeOnline -CertificateThumbprint $connection.CertificateThumbprint -AppId $connection.ApplicationID -ShowBanner:$false -Organization $tenant
Get-MessageTrace
View ScheduledTaskEmailReporting.ps1
$credential = Get-AutomationPSCredential -Name 'Exchange'
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'https://outlook.office365.com/powershell-liveid/' -Credential $credential -Authentication Basic -AllowRedirection
Import-Module (Import-PSSession -Session $session -DisableNameChecking -AllowClobber ) -Global
$TodaysDate = Get-Date (Get-Date).AddDays(-1) -Format 'MM/dd/yyyy'
$NumberOfInternalEmails = (Get-MessageTrace -StartDate $TodaysDate -EndDate $TodaysDate | Where-Object{$_.'SenderAddress' -like '*alexholmeset.onmicrosoft.com'} | Where-Object{$_.'RecipientAddress' -like '*alexholmeset.onmicrosoft.com'}).count
View CreateSQLTableEmailReporting.ps1
#Set Defaults (Optional) which allows you to skip defining instance, user, and password each time
$AzureDefaultInstanceName = "ServerName"
$AzureDefaultDatabaseName = "DatabaseName"
$username = Get-AutomationVariable -Name 'Administrator'
$password = Get-AutomationVariable -Name 'Password'
#The actual function
View TeamsAdminPortalCalls.ps1
$url = 'https://tas.teams.microsoft.com/v2/teams/summary-timeseries?timeperiod=last-ninety-days&includeTimeSeries=ActiveUsers&metrics=all&pagesize=20&nextCursor=null'
$token = 'CI6IjE4YzRhOTFiLTRmYTktNGZiZC1hYjFjLWIzOTQ'
$Header = @{"Authorization" = "Bearer $token" }
$data = Invoke-RestMethod -Uri $url -Method GET -Headers $Header -ContentType 'application/json'
View TeamsAdminPortalCalls.ps1
$url = 'https://tas.teams.microsoft.com/v2/teams/summary-timeseries?timeperiod=last-ninety-days&includeTimeSeries=ActiveUsers&metrics=all&pagesize=20&nextCursor=null'
$token = 'CI6IjE4YzRhOTFiLTRmYTktNGZiZC1hYjFjLWIzOTQ'
$Header = @{"Authorization" = "Bearer $token" }
$data = Invoke-RestMethod -Uri $url -Method GET -Headers $Header -ContentType 'application/json'
View AddDataAzureSQL.ps1
#Set Defaults (Optional) which allows you to skip defining instance, user, and password each time
$AzureDefaultInstanceName = "teamssqlserver"
$AzureDefaultDatabaseName = "teamssqldatabase"
$AzureDefaultUserID = "username"
$AzureDefaultPassword = "password"
#The actual function
Function get-azureSQL (
[string]$DatabaseName = $AzureDefaultDatabaseName,
View CreateAzureSQLTable.ps1
#Set Defaults (Optional) which allows you to skip defining instance, user, and password each time
$AzureDefaultInstanceName = "teamssqlserver"
$AzureDefaultDatabaseName = "teamssqldatabase"
$AzureDefaultUserID = "username"
$AzureDefaultPassword = "password"
#The actual function
Function get-azureSQL (
[string]$DatabaseName = $AzureDefaultDatabaseName,
[string]$InstanceName = $AzureDefaultInstanceName
,[string]$UserID = $AzureDefaultUserID
View TeamsSharePointUsageReport.ps1
#Teams and SharePoint usage data consolidation script
#Author: Alexander Holmeset
#Twitter: @AlexHolmeset
function Get-MSGraphAppToken{
<# .SYNOPSIS
Get an app based authentication token required for interacting with Microsoft Graph API
.PARAMETER TenantID
A tenant ID should be provided.
View ExpiredUsers.ps1
#"Password!" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File "D:\temp\PassordUserExpireScript.txt"
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "admin@contoso", (Get-Content "d:\temp\PassordUserExpireScript.txt" | ConvertTo-SecureString)
#Gets all users thats enabled and have a expiration date.
$Users = Get-ADUser -Filter * -Properties AccountExpirationDate | select AccountExpirationDate,Enabled,UserPRincipalName,samaccountname,name | Where-Object{$_.Enabled -eq $true -and $_.AccountExpirationDate}
#Todays date.
$today = Get-Date -Format dd/MM/yyyy
View TeamsAutoAttendantHolidayScheduleGenerator.ps1
### Teams Auto Attendant Holiday Schedule Generator ###
### Version 1.0 ###
### Author: Alexander Holmeset ###
### Email: alexander.holmeset@gmail.com ###
### Twitter: twitter.com/alexholmeset ###
### Blog: alexholmeset.blog ###
#Enter you AutoAttendant ID
$AutoAttendantID = "159980fb-ec85-4c3d-b8be-e09a2a17f4eb"
You can’t perform that action at this time.