Skip to content

Instantly share code, notes, and snippets.

View markekraus's full-sized avatar
😀

Mark Kraus markekraus

😀
View GitHub Profile
Install-Module PSRAW -Scope CurrentUser
Import-Module PSRAW
# Go here https://ssl.reddit.com/prefs/apps
# use https://127.0.0.1 for redirect uri
# register Script App and note client id and secret
Connect-Reddit
$Params = @{
@markekraus
markekraus / express.js
Last active December 9, 2017 22:18
Test scripts and progranm for IRM memory leak troubleshooting
const express = require('express')
const app = express()
app.get('/api', function (req, res)
{
res.send('0')
})
app.listen(5001, function ()
{
@markekraus
markekraus / Sort-DotSpelling.ps1
Last active September 20, 2017 23:40
Sorts .spelling file for Powershel/Powershell
$File = (Get-Content .\.spelling)
$Head = $File[0..4]
$Count = 0
$Dictionary = foreach($Line in $File[5..($File.Count -1)]){
$Count ++
if($Line -Match '^#region ' -or [string]::IsNullOrEmpty($line)){continue}
if($line -match '^ -|^#endregion'){break}
$line
}
$Dictionary = $Dictionary | Sort-Object
class MockedWebResponseAsyncResult : System.IAsyncResult {
[System.Net.WebRequest] $Request;
[Object]$state
MockedWebResponseAsyncResult([System.Net.WebRequest] $request, [object]$State) {
$this.Request = $request
$This.State = $State
}
[bool] get_IsCompleted () {
@markekraus
markekraus / Patch-NotPetya.ps1
Last active June 28, 2017 18:51
Patch AD Computers for NotPetya. Supports multiple runs to skip previously patched machines and provides detailed logging objects.
#Requires -Modules PoshRSJob, ActiveDirectory
# create this file as read-Only before running script
$SourceFile = "C:\perfc"
$ServerFilter = {enabled -eq $True -and DnsHostName -like "*" -and operatingSystem -like "*windows*"}
$SearchBase = "dc=adatum,dc=com"
$LogFile = "C:\NotPetyaPatch.xml"
$Throttle = 40
@markekraus
markekraus / Add-SharePointSiteExternalUser.ps1
Last active May 7, 2021 13:56
PowerShell function to invite an external user or list of external users to a SharePoint site
<#
.SYNOPSIS
Invites an external user or list of external users to a SharePoint site.
.DESCRIPTION
Invites an external user or list of external users to a SharePoint site.
External users can be granted View, Edit, or Owner permissions within
the site. A custom e-mail message can be included or the invitation email
can be suppressed.
.PARAMETER SiteURL
URL string of the SharePoint site to which the user(s) will be invited.
$OS = (Get-WMIObject Win32_OperatingSystem).Caption
$DaysToDelete = 30
if(($OS -like "*2008*") -or ($OS -like "*2012*")){
$diskbefore = GWMI -Class win32_LogicalDisk -Filter "DeviceID = 'C:'" | Select-Object @{ n = "$OS"; e = {$_.PSComputerName}}, @{ n = "FreeSpace(GB) Before" ; e = {"{0:N1}" -f( $_.Freespace / 1gb ) } }, @{ n = "PercentFree Before" ; e = {"{0:P1}" -f( $_.FreeSpace / $_.Size ) } } | Out-String
Write-Output "$diskbefore"
}
else{
write-host @"