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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / powershellsnippetvscode.json
Created September 25, 2019 06:46
PowerShell snippet for VS Code
{
"Condition statement": {
"prefix": "cond",
"body": [
"${_} { ${0}; break }"
],
"description": "Switch condition statement"
},
"Condition single quoted string statement": {

Keybase proof

I hereby claim:

  • I am kasuken on github.
  • I am ebartolesi (https://keybase.io/ebartolesi) on keybase.
  • I have a public key ASD-nHf_Ps_Yh4_wIO0bTyr07z47zTI9shrcpK0FKt_XIwo

To claim this, I am signing this object:

@kasuken
kasuken / settings.json
Last active December 17, 2021 15:05
My Windows Terminal Settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},