Skip to content

Instantly share code, notes, and snippets.

View kasuken's full-sized avatar
:octocat:
Authoring courses

Emanuele Bartolesi kasuken

:octocat:
Authoring courses
View GitHub Profile
@kasuken
kasuken / removewelcomemessage.ps1
Created November 4, 2020 20:16
How to disable welcome message from Office 365 groups
Connect-ExchangeOnline -UserPrincipalName <YOUR UPN> -ShowProgress $true
#$O365Groups = Get-UnifiedGroup | Where-Object { $_.WelcomeMessageEnabled -eq $true }
$O365Groups = Get-UnifiedGroup
foreach ($group in $O365Groups) {
Write-Host "Disabling Welcome Message on O365 Group: " -NoNewline; Write-Host $group.DisplayName -ForegroundColor Cyan
Set-UnifiedGroup $group.Identity -AlwaysSubscribeMembersToCalendarEvents:$false -AutoSubscribeNewMembers:$false -SubscriptionEnabled:$false -UnifiedGroupWelcomeMessageEnabled:$false
}
@kasuken
kasuken / RemoveAllModermPages.ps1
Created October 29, 2020 04:58
PowerShell script to remove all modern pages from SharePoint Online with PnP
$siteUrl = ""
Connect-PnPOnline –Url $siteUrl -UseWebLogin
$items =Get-PnPListItem -List "SitePages" -PageSize 1000
foreach ($item in $items)
{
if ($item.Id -ne 1)
{
try
@kasuken
kasuken / changeTeamsLanguage.ps1
Created October 27, 2020 13:33
Change Teams Language from PowerShell
$configPath = "$ENV:APPDATA\Microsoft\Teams\desktop-config.json";
$cookiesFilePath = "$ENV:APPDATA\Microsoft\Teams\Cookies"
$cookiesJournalPath = "$ENV:APPDATA\Microsoft\Teams\Cookies-journal"
$teams = Get-Process Teams -ErrorAction SilentlyContinue
if ($teams) {
Stop-Process -Name Teams -Force
}
Start-Sleep -s 5
@kasuken
kasuken / retrieveupn.cs
Created September 11, 2020 05:25
Retrieve UPN from .NET Core
var procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c whoami /upn");
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
var email = result.Trim();
@kasuken
kasuken / Yammer API (Public).postman_collection.json
Last active March 13, 2023 07:36
Yammer API Postman Collection
{
"info": {
"_postman_id": "90d3ea99-ce5f-4b8d-8fe9-2b66766b0bcc",
"name": "Yammer API (Public)",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get My Feed",
"request": {
@kasuken
kasuken / VS 2019 and VS Code - Defender Exclusions.ps1
Last active February 12, 2024 03:30
This script adds path exclusions to Windows Defender for VS 2019 and Visual Studio Code processes and folders.
# Remember to run the script "as Administrator"
$pathExclusions = New-Object System.Collections.ArrayList
$processExclusions = New-Object System.Collections.ArrayList
$pathExclusions.Add('C:\Windows\Microsoft.NET') > $null
$pathExclusions.Add('C:\Windows\assembly') > $null
$pathExclusions.Add($env:USERPROFILE + '\AppData\Local\Microsoft\VisualStudio') > $null
$pathExclusions.Add($env:USERPROFILE + '\.nuget\packages') > $null
$pathExclusions.Add('C:\ProgramData\Microsoft\VisualStudio\Packages') > $null
@kasuken
kasuken / profiles.json
Created January 18, 2020 14:30
Windows Terminal Retrowave Color Scheme
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{7d04ce37-c00f-43ac-ba47-992cb1393216}",
"initialCols": 120,
"initialRows": 30,
"profiles": [
{
"acrylicOpacity": 0.85,
@kasuken
kasuken / AzureCleaner.ps1
Created January 14, 2020 15:39
An Azure Function PowerShell script to clean all expired resources, all empty resource groups and all expired resource groups
$currentUTCtime = (Get-Date).ToUniversalTime()
$expiredResources = Search-AzGraph -Query 'where todatetime(tags.expireOn) < now() | project id, name'
foreach ($r in $expiredResources) {
Write-Host "==> Deleting $($r.name)...";
Remove-AzResource -ResourceId $r.id -Force -WhatIf
}
$expiredResources = Get-AzResourceGroup;
@kasuken
kasuken / DisableFooter.ps1
Created January 6, 2020 10:18
Disable footer on Office 365 Communication Sites
$orgName = "M365cm599554"
$userCredential = Get-Credential
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
$sites = Get-SPOSite -Template SITEPAGEPUBLISHING#0
foreach ($site in $sites) {
Connect-PnPOnline -Url $site.url -Credentials $userCredential
$web = Get-PnPWeb
$web.FooterEnabled = $false
@kasuken
kasuken / 00 - A collection of free DNS Servers
Last active March 19, 2024 14:48
Set and Reset DNS Settings with PowerShell
A collection of my favorites DNS