Skip to content

Instantly share code, notes, and snippets.

View markekraus's full-sized avatar
😀

Mark Kraus markekraus

😀
View GitHub Profile
$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 @"
@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
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 / 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
@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 / StyleCopErrors.txt
Created December 21, 2017 13:40
Web Cmdlet StyleCop Issues
.\commands\utility\WebCmdlet\StreamHelper.cs(279,27): error SA1204: Static members should appear before non-static members
.\commands\utility\WebCmdlet\FormObject.cs(40,16): error SA1201: A constructor should not follow a property
.\commands\utility\WebCmdlet\FormObject.cs(17,23): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObject.cs(22,23): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObject.cs(27,23): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObject.cs(32,43): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObjectCollection.cs(19,13): error SA1616: Element return value documentation should have text
.\commands\utility\WebCmdlet\FormObjectCollection.cs(18,13): error SA1614: Element parameter documentation should have text
.\commands\utility\WebCmdlet\Common\BasicHtmlWebResponseObject.Common.cs(5,1): error SA1200: Using directive should ap
@markekraus
markekraus / CodeCommitEvent.cs
Last active February 13, 2018 21:03
CodeCommitEvent Model for Receiving CodeCommit Events in C# AWS Lambdas
using System;
namespace Lambda
{
public class CodeCommitEventCodecommitReference
{
public string commit;
public bool created = false;
public string @ref;
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 / PBnC-Deployment.log
Created March 16, 2018 13:44
Peanut Butter and Chocolate Deployment Log data from Azure Functions Web App Deployment and AWS CloudWatch for AWS Lambda
----------------------- Azure Web App Deployment Log -----------------------------------
log_time : 2018-02-18T21:11:19.1757131Z
id : 9e378a01-337f-4303-bd35-39f84845320b
message : Updating submodules.
type : 0
details_url :
log_time : 2018-02-18T21:11:19.3475551Z
@markekraus
markekraus / DownloadCmdletDemo.cs
Created March 31, 2018 20:13
Demo of the Download Cmdlet Interfaces and a fake mock up the the cmdlet and how it would use them
using System;
using System.Collections.Generic;
using System.IO;
using System.Management.Automation;
using System.Text;
namespace System.Management.Automation
{
internal interface IInvokeDownloadProtocolFactory
{