Skip to content

Instantly share code, notes, and snippets.

View rayterrill's full-sized avatar

Ray Terrill rayterrill

View GitHub Profile
#launch sharepoint powershell first as a farm admin!
#declare an array to hold results
$results = @()
$webApps = Get-SPWebApplication https://sharepoint.portofportland.com
#iterate over web applications
foreach ($w in $webApps) {
$sites = Get-SPSite -WebApplication $w -Limit ALL
#iterate over site collections
param(
[Parameter(Mandatory=$true)][string]$Bigip = "",
[Parameter(Mandatory=$true)][string]$User = "",
[Parameter(Mandatory=$true)][string]$Pass = ""
)
function Do-Initialize() {
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null )
{
Add-PSSnapIn iControlSnapIn
Param(
[Parameter(Mandatory=$True,Position=1)][string]$pdfFile,
[Parameter(Mandatory=$True,Position=2)][string]$eventFile
)
#uses cPDF http://community.coherentpdf.com/
#the pdf file, cpdf, and the event file should be in the current directory
#clean up any previously split ticket pdfs
#splits a pdf $pdfFile by pages into files matching Ticket001.pdf, etc in the same directory
<QueryList>\
<Query Id="0" Path="Application">\
<Select Path="Application">*[System[Provider[@Name='MSSQLSERVER' or @Name='MSSQLSERVER$AUDIT']]]</Select>\
<Suppress Path="Application">*[System[(EventID=852 or EventID=958 or EventID=3014 or EventID=3197 or EventID=3198 or EventID=3406 or EventID=3407 or EventID=3408 or EventID=3421 or EventID=3454 or EventID=6253 or EventID=6290 or EventID=6299 or EventID=8128 or EventID=9666 or EventID=9688 or EventID=9724 or EventID=10981 or EventID=15268 or EventID=17069 or EventID=17101)]]</Suppress>\
<Suppress Path="Application">*[System[(EventID=17103 or EventID=17104 or EventID=17110 or EventID=17111 or EventID=17115 or EventID=17117 or EventID=17118 or EventID=17125 or EventID=17126 or EventID=17135 or EventID=17136 or EventID=17137 or EventID=17147 or EventID=17152 or EventID=17162 or EventID=17164 or EventID=17176 or EventID=17177 or EventID=17201 or EventID=17573)]]</Suppress>\
<Suppress Path="Application">*[System[(EventID=17663 or EventID=17811 o
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$clientID = 'YOUR_APPS_APP_GUID';
$scope = 'https://graph.microsoft.com/.default';
$clientSecret = 'YOUR_APPS_PASSWORD';
$azureTenantID = 'YOUR_AZURE_TENANT_GUID';
# Ensure the build fails if there is a problem.
# The build will fail if there are any errors on the remote machine too!
$ErrorActionPreference = 'Stop'
$user = 'MYADMINUSER'
$password = $env:MYADMINPASSWORD
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$password)))
$server = "https://MSERVER.MYDOMAIN.COM"
$phoneNumber = $env:PhoneNumber
@rayterrill
rayterrill / PowerShellNode.js
Created July 9, 2017 22:57
Use NodeJS to run some PowerShell code.
const shell = require('node-powershell');
let ps = new shell({
executionPolicy: 'Bypass',
noProfile: true,
debugMsg: false
});
ps.addCommand('./test.ps1')
ps.invoke()
@rayterrill
rayterrill / TwitterStreamingBot.js
Created July 10, 2017 04:52
NodeJS Streaming Bot Example
/*
//config.js
module.exports = {
twitter: {
consumer_key: 'CONSUMER_KEY',
consumer_secret: 'CONSUMER_SECRET',
access_token_key: 'ACCESS_TOKEN_KEY',
access_token_secret: 'ACCESS_TOKEN_SECRET'
}
@{
# Point to your module psm1 file...
RootModule = 'SystemStatus.psm1'
# Be sure to specify a version
ModuleVersion = '0.0.1'
Description = 'PoshBot module for getting System Status from Cachet'
Author = 'Ray Terill'
CompanyName = 'Community'
$cred = Get-Credential
Connect-PnPOnline –Url https://mysite.sharepoint.com/sites/TestSite –Credentials $cred
#get the user id for the user from the site
Get-PNPUser
#get the current number of likes ($item.fieldvalues.LikesCount) and likers ($item.fieldvalues.LikedBy)
$item = Get-PNPListItem -Id 1 -List TestList
#increment the number of likes
Set-PNPListItem -Identity 1 -List TestList -Values @{"LikesCount" = 2; "LikedBy" = @(6,12)}