Skip to content

Instantly share code, notes, and snippets.

View johndonnelly's full-sized avatar

John Donnelly johndonnelly

View GitHub Profile
@johndonnelly
johndonnelly / Test-ProcessElevated.ps1
Created August 10, 2022 15:47 — forked from 0xfeeddeadbeef/Test-ProcessElevated.ps1
Test whether or not a process is elevated (UAC run as admin)
function Test-ProcessElevated
{
[CmdletBinding()]
[OutputType([bool])]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[System.Diagnostics.Process] $Process
)
begin {
@johndonnelly
johndonnelly / Add-PageParserPath.ps1
Created April 2, 2021 21:14 — forked from joerodgers/Add-PageParserPath.ps1
Uses the SPWebConfigModifications class to deploy custom PageParserPath entries to web.config.
Add-PSSnapin Microsoft.SharePoint.PowerShell
function Add-PageParserPath
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.Administration.SPWebApplication]$WebApplication,
[Parameter(Mandatory=$true)][string]$VirtualPath,
[Parameter(Mandatory=$false)][bool]$AllowServerSideScript = $false,
@johndonnelly
johndonnelly / common_interface.py
Created January 21, 2021 15:58 — forked from oliver-batey/common_interface.py
Common interface for parsing txt, docx, pdf, html and pptx
import os
import io
from docx import Document
from pdfminer3.layout import LAParams, LTTextBox
from pdfminer3.pdfpage import PDFPage
from pdfminer3.pdfinterp import PDFResourceManager
from pdfminer3.pdfinterp import PDFPageInterpreter
from pdfminer3.converter import PDFPageAggregator
from pdfminer3.converter import TextConverter
@johndonnelly
johndonnelly / DownloadImages_fromURL.ps1
Created May 6, 2019 20:15 — forked from PrateekKumarSingh/DownloadImages_fromURL.ps1
Extracting Images from a URL and saving it in a desired directory
$url="https://geekeefy.wordpress.com/2016/03/12/powershell-extract-text-from-image-and-convert-print-in-any-language/"
(Invoke-WebRequest -Uri $url).images.src | ?{$_ -like "*Geekeefy.files*"} -PipelineVariable pv `
| %{$fn = ($pv.split("/")[-1]).split('?')[0];iwr $pv -OutFile "D:\scraping\$fn"}
Function Invoke-WolframAlphaAPI($Query)
{
Return (Invoke-RestMethod -Uri "http://api.wolframalpha.com/v2/query?appid=APIKEY&input=$($Query.Replace(' ','%20'))").queryresult
}
Test-Port -Source '127.0.0.1' -Destination '10.196.11.206','10.196.11.206','10.196.11.206','123.234.234.3' `
-Port 3389,20, 21 -Verbose | ft -AutoSize
#-Iterate | Export-Csv portstatus.csv -NoTypeInformation
#Test-PortConnectivity '127.0.0.1' 'dc1' 57766 -Protocol UDP -Iterate
#Test-PortConnectivity 'localhost' 'dc2' 51753 -Protocol UDP
#Test-PortConnectivity -Source $EUCAS -Destination $EUMBX -Port 135 -Iterate
#Test-PortConnectivity -Source 'localhost' -Destination '127.0.0.1' -Port 135 -Iterate -protocol TCP
Function Test-Port
# Function to enable telnet-ing from [Local/Remote] Source location, which requires credentials for remote source machine
# This Function is a wrapper around Function PSTelnet to add remote source telnet-ing feature
Function Test-Port
{
[cmdletbinding()]
Param
(
[Parameter(Position=0)] $Source = $(Hostname),
[Parameter(Mandatory=$true,Position=1)] $Destination,
# Create an Internet Explorer object
$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true # Make it visible
# Open all websites
$ie.Navigate("www.linkedin.com")
# Navigate2() function to open in new tab in the same IE window
$ie.Navigate2("www.facebook.com",0x1000)
# define a set
$x = [System.Collections.Generic.HashSet[string]]::new()
'python'.ToCharArray().foreach({[void]$x.add($_)})
$y = [System.Collections.Generic.HashSet[string]]::new()
'powershell'.ToCharArray().foreach({[void$y.add($_)})
$x.ExceptWith($y) # All the elements in x but not in y
# union
$x.UnionWith($y) # Unique elements in x or y or both
$data = Invoke-WebRequest https://www.sqlshack.com/top-50-powershell-bloggers-of-2018/
$data.Links.Where({ $_.href -like "*http*" -and
$_.href -notlike "*twitter*" -and
$_.href -notlike "*sql*" -and
$_.href -notlike "*creativecomm*" -and
$_.href -notlike "*microsoft*"
}) | Select-Object href -Unique -ExpandProperty href