Skip to content

Instantly share code, notes, and snippets.

View poiriersimon's full-sized avatar

Simon Poirier poiriersimon

View GitHub Profile
@poiriersimon
poiriersimon / LogiLitra.ps1
Last active December 20, 2023 07:29
Logitech Litra Glow Beam Powershell Function
#Litra Glow and Litra Beam Powershell Controller
#Download hidapitester here : https://github.com/todbot/hidapitester/releases
#Based on https://www.reddit.com/r/LogitechG/comments/sacz2x/comment/j7doia4/?utm_source=share&utm_medium=web2x&context=3
#Change to point to the extract folder
$HIDAPItesterFolderPath = "C:\Users\username\Scripts\"
#HIDAPItester
$global:HIDAPItesterPath = $HIDAPItesterFolderPath + "hidapitester.exe"
@poiriersimon
poiriersimon / get-TeamsChannelsAnalytics.ps1
Last active August 26, 2020 14:53
Get Teams Channels Analytics to CSV file
#This is a quick and dirty way to dump all the last 90 days analytics of a Team to a CSV file
#Requirement :
#-Install-module MicrosoftTeams
#-Get your bearer token and replace it in the variable
$UPN = "user@domain.com"
$TeamDisplayName = "My Team To Analyse"
$bearer ="Bearer ESAsadmaisjdoasjdoaskdokasopdkasopdjaiopjdd very long bearer token"
###########
$headers = @{
@poiriersimon
poiriersimon / UploadToAzureBlob.ps1
Created August 15, 2019 14:03
Upload file to Azure Blog Container
$StorageAccountName = "Demostorage"
$ContainerName = "Democontainer"
$BlobDirectory = "BlobDir"
$localFilePath = "C:\Temp\"
$CredObj = Get-Credential "Enter Storage Account Key Only"
Import-Module AzureRM
$StorageAccountKey = $CredObj.GetNetworkCredential().Password
$ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
@poiriersimon
poiriersimon / AddUserToGroupWithGraph.ps1
Last active July 30, 2019 13:15
Add User to group in batch with Graph
#You need Powershell API module @ https://github.com/poiriersimon/PowershellAPIModule
Import-Module "C:\Modules\PowershellAPI\PowershellAPI.psd1"
$AdminAccount = "user@domain.com"
$clientid = "1b730954-1685-4b74-9bfd-dac224a7b894";
$RessourceURI = "https://graph.windows.net";
$RedirectURI = "urn:ietf:wg:oauth:2.0:oob";
#FindGroupId
$Groupids = Invoke-GraphApi -Resource groups -UserPrincipalName $AdminAccount -ClientID $Clientid -redirectUri $RedirectURI | select Displayname,id
# Choose une from here Need to be a Office 365 group or a security group based on https://docs.microsoft.com/en-us/graph/api/group-post-members?view=graph-rest-1.0&tabs=http
@poiriersimon
poiriersimon / Get-TransportRuleEstimatedSize.ps1
Last active June 4, 2019 15:21
Estimate Exchange (Online) Transport rule size
#Help identify rule size for limit
# https://docs.microsoft.com/en-us/office365/servicedescriptions/exchange-online-service-description/exchange-online-limits#journal-transport-and-inbox-rule-limits
$TransportRules = Get-TransportRule
$Result = @()
Foreach($TransportRule in $TransportRules){
if($Matches){$Matches.Clear()}
$RuleLength = 0
$Regex = $TransportRule.Description -match "If the message:([\w\W]*)Take the following actions:"
if($Regex){
$RuleLength+= $Matches[1].trim().Length
@poiriersimon
poiriersimon / Get-CurrentUPN.ps1
Created April 23, 2019 18:32
Powershell function to detect UPN for the currently logged user
Function Get-CurrentUPN
{
$UserPrincipalName = $NULL
#
$UPNList = @()
$UPN = $Env:USERNAME
if($UPN -eq $NULL){
$UPN = (whoami)
if($UPN -ne $NULL){
@poiriersimon
poiriersimon / Connect-Intune.ps1
Last active May 2, 2019 19:49
Powershell function to connect to Intune Graph API
#You need AzureAD Module (Save-Module AzureAD -Path C:\temp)
#You need Function Get-GraphAuthHeaderBasedOnUPN @ https://gist.github.com/poiriersimon/ded7cdca600ba0aab84b75b7f47c1235
Function Connect-Intune{
param
(
[Parameter(Mandatory = $True)]
[string]$Tenant,
[Parameter(Mandatory = $True)]
[string]$UserPrincipalName,
[string]$clientId = "d1ddf0e4-d672-4dae-b554-9d5bdfd93547",
@poiriersimon
poiriersimon / Get-GraphAuthHeaderBasedOnUPN.ps1
Last active May 2, 2019 16:41
Powershell Function to Get Auth Header based on UPN with Graph API
#You need AzureAD Module (Save-Module AzureAD -Path C:\temp)
#Azure DLL are sideloaded in a job to bypass potential conflict with other version
function Get-GraphAuthHeaderBasedOnUPN
{
[cmdletbinding()]
param(
[Parameter(Mandatory = $True)]
[string]$Tenant = "",
[Parameter(Mandatory = $false)]
[string]$clientId = "1950a258-227b-4e31-a9cf-717495945fc2",
@poiriersimon
poiriersimon / ProxyAuth.ps1
Created April 23, 2019 18:21
Powershell cmdlet to authenticate to Proxy
#Configuration du proxy pour permettre l'Accès a Graph API sans problème
$wc = New-Object System.Net.WebClient
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
@poiriersimon
poiriersimon / Remove Database with no mailboxes.ps1
Created February 11, 2019 20:01
Remove Database with no mailboxes for Exchange 2010+
$MailboxDatabase = Get-mailboxDatabase | where {$_.Recovery -eq $False}
$EmptyDBs = @()
foreach($DB in $MailboxDatabase){
$Mailboxes = $DB | Get-Mailbox | select Identity -first 1
if($Mailboxes -eq $NULL){
$EmptyDB = New-Object PSObject
$EmptyDB | Add-Member NoteProperty -Name "Name" -Value $DB.Name
$EmptyDB | Add-Member NoteProperty -Name "EDBPath" -Value $DB.EdbFilePath
$EmptyDB | Add-Member NoteProperty -Name "LogPath" -Value $DB.LogFolderPath
$EmptyDB | Add-Member NoteProperty -Name "Servers" -Value $($DB.Servers -join ',')