Skip to content

Instantly share code, notes, and snippets.

@cmd64
cmd64 / SP_Add-Item.ps1
Last active January 29, 2019 12:18
SharePoint PowerShell - Add item to list
#If run on Windows PowerShell must be add below code
#Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb "http://siteaddress"
$spList = $web.Lists["List Title"]
$newItem = $spList.AddItem()
$newitem["Title"] = "Test"
$newitem["OtherColumn"] = "Test2"
$newitem.update()
@cmd64
cmd64 / SP_URAI-Solution.ps1
Last active January 29, 2019 12:21
SharePoint PowerShell - Uninstall, Remove, Add, Install Solution
#If run on Windows PowerShell must be add below code
#Add-PSSnapin Microsoft.SharePoint.PowerShell
Uninstall-SPSolution -Identity Solution.wsp -WebApplication http://siteaddress
Remove-SPSolution -Identity Solution.wsp
Add-SPSolution -Literal C:\Solution.wsp
Install-SPSolution -Identity Solution.wsp -WebApplication http://siteaddress
@cmd64
cmd64 / change_ssh_port_linux
Last active February 6, 2019 09:05
Change the SSH Port for Your Linux Server
Connect to your server via SSH
Switch to the root user
Run the following command:
nano /etc/ssh/sshd_config
Locate the following line:
# Port 22
Remove # and change 22 to your desired port number.
Restart the sshd service by running the following command:
service sshd restart
@cmd64
cmd64 / Download SP 16 Pre Req Files For Offline.ps1
Last active August 19, 2021 12:54
[Powershell] SharePoint 2016 Download Prerequisite Files For Offline Installer.ps1
Import-Module BitsTransfer
$destPath = "C:\SP16PreReqFiles"
$destPath = $destPath.TrimEnd('\')
function validatePath($destFolder){
## Check that the path entered is valid
If (!(Test-Path $destFolder -Verbose)) {
New-Item -Path $destFolder -ItemType Directory
}
@cmd64
cmd64 / SharePoint Merge Log File
Created April 25, 2019 14:39
SharePoint get log files from all servers
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
#Merges the log data for last one hour
Merge-SPLogFile -Path "C:\FarmMergedLog.csv" -Overwrite -Level Critical
#Merges the log data for particular time range, which is culture-specific to windows timezone.
Merge-SPLogFile -Path "C:\FarmMergedLog2.csv" -Overwrite -Level Critical -StartTime "01.04.2019 00:00" -EndTime "25.04.2019 00:00"
@cmd64
cmd64 / YTDecrypt.cs
Last active May 15, 2019 02:09
Youtube Decrypt Chipher
using System;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace CM.Youtube.Library
{
public class YTDecrypt
{
private static string GetPlayerJS(string videoUrl)
@cmd64
cmd64 / Get All Sites.ps1
Last active August 19, 2021 13:27
[Powershell] Get all site collections on farm.
Get-SPSite -Limit All | Get-SPWeb -Limit All | Select-Object -Property Title, Url | Format-Table *
#Only Root Webs
Get-SPSite -Limit All | Get-SPWeb -Limit All | Where { $_.IsRootWeb } | Select-Object -Property Title, Url | Format-Table *
// ==UserScript==
// @name Download Artwork From Apple Music
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Download best resolution artwork from Apple Music!
// @author CM
// @match https://music.apple.com/*
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @grant GM_download
// ==/UserScript==
@cmd64
cmd64 / sp-change-anonymous-perm-mask.ps1
Last active August 19, 2021 13:28
[Powershell] Anonymous Users cannot open XLSX files from a document library
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = "<site collection URL>";
$site = New-Object Microsoft.SharePoint.SPSite($siteurl);
$web = $site.OpenWeb();
$enumPerms = [Microsoft.SharePoint.SPBasePermissions];
Write-Host $web.AnonymousPermMask64;
$web.AnonymousPermMask64 = $enumPerms::ViewListItems -bor $enumPerms::ViewVersions -bor $enumPerms::ViewFormPages -bor $enumPerms::Open -bor $enumPerms::ViewPages -bor $enumPerms::UseClientIntegration -bor $enumPerms::OpenItems
$web.Update();
Write-Host $web.AnonymousPermMask64;
$web.Dispose();
$(this).mask("#.##0,00", {
byPassKeys: [188, 189, 109],
reverse: true,
placeholder: "0,00",
translation: {
'#': {
pattern: /-|\d/,
recursive: true
}
},