Skip to content

Instantly share code, notes, and snippets.

@rheid
rheid / cleanTeamsCache.ps1
Created August 12, 2022 17:37
PowerShell Basics: How to Delete Microsoft Teams Cache for All Users
Get-ChildItem "C:\Users\*\AppData\Roaming\Microsoft\Teams\*" -directory | Where name -in ('application cache','blob storage','databases','GPUcache','IndexedDB','Local Storage','tmp') | ForEach{Remove-Item $_.FullName -Recurse -Force -WhatIf}
@rheid
rheid / postman.js
Created April 3, 2021 16:09
PostMan AzureAD Collection Login
var client_id = pm.collectionVariables.get("adminClientId");
var client_secret = pm.collectionVariables.get("adminClientSecret");
var tenant = pm.collectionVariables.get("netforcetenantid")
var resource = pm.collectionVariables.get("adminRessounce")
pm.sendRequest({
url: 'https://login.microsoftonline.com/' + tenant + '/oauth2/token',
method: 'POST',
header: {
'Content-Type': 'multipart/form-data',
@rheid
rheid / CreateTable.sql
Last active July 5, 2019 20:08
The following script creates the EMPLOYEES table with 1000 entries.
CREATE TABLE employees (
employee_id NUMERIC NOT NULL,
first_name VARCHAR(1000) NOT NULL,
last_name VARCHAR(900) NOT NULL,
date_of_birth DATE ,
phone_number VARCHAR(1000) NOT NULL,
junk CHAR(1000) ,
TS timestamp,
id_num int IDENTITY(1,1),
CONSTRAINT employees_pk
@rheid
rheid / spupdateRequestAccessEmail.ps1
Created August 31, 2018 09:15
Update SharePoint RequestAccessEmail
$webapp = Get-SPWebApplication "https://WEBAPP"
foreach($site in $webapp.Sites){
foreach($web in $site.AllWebs){
if ($web.HasUniqueRoleDefinitions){
if($web.RequestAccessEnabled){
Write-Host $Web.URL
Write-Host $Web.RequestAccessEmail
Write-Host "---"
if ($web.RequestAccessEmail -eq 'my.email@email.com'){
Write-Host $Web.URL "Update RequestAccessEmail"
@rheid
rheid / SPSolutions.ps1
Created August 16, 2018 09:01
Backup WSP Solution from running SharePoint
$farm = Get-SpFarm
$file = $farm.Solutions.Item(“documenteventreceiver.wsp ”).SolutionFile
$file.SaveAs(“E:\WSPFiles\documenteventreceiver.wsp ”)
@rheid
rheid / spedit.js
Created March 16, 2018 22:20
CHANGE DEFAULT FORM BUTTON REDIRECT – THE SIMPLE WAY
function changeRedirect(options) {
for (var i = 0, buttons = document.querySelectorAll(options.selector); i < buttons.length; i++) {
var newOnClick = function(originalOnClick) {
return function(){
Nav.navigate = STSNavigate = function() {
window.location = options.redirectTo
}
originalOnClick()
}
}
@rheid
rheid / sqlattach.sql
Created November 26, 2017 17:19
Get Detach or Attach all user databases script
USE [master];
GO
DECLARE @database NVARCHAR(200) ,
@cmd NVARCHAR(1000) ,
@detach_cmd NVARCHAR(4000) ,
@attach_cmd NVARCHAR(4000) ,
@file NVARCHAR(1000) ,
@i INT ,
@DetachOrAttach BIT;
@rheid
rheid / Throttling.ps1
Created October 27, 2017 06:24
Configure Resource Throttling in SharePoint 2013 using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Function to set Resource throttling values in SharePoint 2013
Function Set-ResourceThrottling
{
param (
[parameter(Mandatory=$true)] [string]$WebAppURL,
[parameter(Mandatory=$true)] [string]$ListViewThreshold,
@rheid
rheid / web.config
Created July 24, 2017 19:50
IIS Web Config for directoryBrowse and mimeMap Azure WebServer Download
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".ipa" mimeType="application/octet-stream" />
<mimeMap fileExtension=".zip" mimeType="application/octet-stream" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
<directoryBrowse enabled="true" showFlags="Date,Time,Extension,Size" />
</system.webServer>
</configuration>
@rheid
rheid / createSPWebFromTemplate.js
Created February 12, 2017 19:52
SharePoint JS CSOM code to create a subsite using a custom Site Template
var webUrl = "newSubSite",
webTitle = "New Sub Site",
webDesc = "Description about the new web/site";
var siteTemplate;
var CONST_PROJECT_TEMPLATE = "Custom Project Template";
var ctx = SP.ClientContext.get_current();
var webTemplates = ctx.get_web().getAvailableWebTemplates(1033, false);
ctx.load(webTemplates);