Skip to content

Instantly share code, notes, and snippets.

View kasuken's full-sized avatar
🦄
Learning how to tame Unicorns

Emanuele Bartolesi kasuken

🦄
Learning how to tame Unicorns
View GitHub Profile
@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 December 24, 2024 07:07
Set and Reset DNS Settings with PowerShell
A collection of my favorites DNS
@kasuken
kasuken / RestartSP.cmd
Created November 15, 2019 09:21
A simple command file to restart all SharePoint 2016 services on the server
@echo off
@echo Stopping Sharepoint services...
@echo Restarting The SharePoint Timer Service...
net stop SPTimerV4
net start SPTimerV4
@echo Restarting The SharePoint Administration Service...
@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": {
@kasuken
kasuken / profiles.json
Created June 23, 2019 12:22
Windows Terminal settings and files
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
@kasuken
kasuken / EmptySiteCollectionsRecycleBin.ps1
Last active June 19, 2019 09:49
Powershell script to remove an SPOsite (from the recycle bin, as well)
$username = ""
$password = ""
$Password = ConvertTo-SecureString -String $password -AsPlainText -Force;
$Credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
Connect-SPOService -Url "https://[tenant]-admin.sharepoint.com" -Credential $Credentials
Get-SPODeletedSite | Remove-SPODeletedSite
@kasuken
kasuken / devmachine.ps1
Last active January 27, 2022 10:40
Boxstarter script for a dev machine
#####################
# PREREQUISITES
#####################
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Set-TaskbarSmall
# Console
cinst PowerShell
cinst poshgit
@kasuken
kasuken / RestartSharePoint.cmd
Created June 11, 2019 04:58
A CMD script to restart all SharePoint services and IIS (it works on SP2010, SP2013, SP2016, SP2019)
@echo off
@echo Stopping Sharepoint services...
@echo Restarting The SharePoint Timer Service...
net stop SPTimerV4
net start SPTimerV4
@echo Restarting The SharePoint Administration Service...
@kasuken
kasuken / AllItem.aspx
Created January 3, 2019 10:09
SharePoint 2013/2016 TreeView
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<table style="width: 100%">
<tr valign="top">
<td width="20%">
<SharePoint:SPHierarchyDataSourceControl ID="docLibDataSource" runat="server" RootContextObject="List" ShowFolderChildren="True" EnableViewState="false"></SharePoint:SPHierarchyDataSourceControl>
<SharePoint:SPTreeView ID="doclibtreeview" runat="server" DataSourceID="docLibDataSource" EnableViewState="false" ExpandDepth="2" SelectedNodeStyle-CssClass="ms-tvselected"></SharePoint:SPTreeView>
</td>