Skip to content

Instantly share code, notes, and snippets.

View Sumeet-Gandhi's full-sized avatar

Sumeet Gandhi Sumeet-Gandhi

View GitHub Profile
Add-PSSnapin Microsoft.SharePoint.Powershell
$webapp = Get-SPWebApplication https://abc.com
foreach($site in $webapp.Sites){
$siteURL = $site.Url.ToLower().Replace("https://abc.com/clients/","")
Write-host
if($siteURL.StartsWith("m") -or $siteURL.StartsWith("n") -or $siteURL.StartsWith("o") -or $siteURL.StartsWith("p") -or $siteURL.StartsWith("q") -or $siteURL.StartsWith("r") -or $siteURL.StartsWith("s") -or $siteURL.StartsWith("t") -or$siteURL.StartsWith("u") -or $siteURL.StartsWith("v") -or $siteURL.StartsWith("w") -or $siteURL.StartsWith("x") -or $siteURL.StartsWith("y") -or $siteURL.StartsWith("z"))
{
@Sumeet-Gandhi
Sumeet-Gandhi / Clear SharePoint Cache.ps1
Created August 25, 2019 04:41
Clear SharePoint Cache
# Clear SharePoint Cache
Add-PSSnapin -Name Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue
write-host "CLEAR CONFIG CACHE ON FARM" -fore green
$servers = get-spserver | ?{$_.role -eq "Application"}
foreach ($server in $servers)
{
$servername = $server.Address
write-host "Stop Timer Service on server $servername" -fore yellow
(Get-WmiObject Win32_Service -filter "name='SPTimerV4'" -ComputerName $servername).stopservice() | Out-Null
@Sumeet-Gandhi
Sumeet-Gandhi / Exchange Online.ps1
Created August 25, 2019 04:36
exchange online connect
$UserCredential = Get-Credential
Import-Module MSOnline
Connect-MsolService –Credential $UserCredential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking -AllowClobber
Set-OwaMailboxPolicy -Identity Default -AdditionalStorageProvidersAvailable $false
Remove-PSSession $Session