Skip to content

Instantly share code, notes, and snippets.

View mwjcomputing's full-sized avatar

Matthew Johnson mwjcomputing

View GitHub Profile
$wmiQuery = Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName $pcName -Filter "HotFixID=$kbs"
if ($wmiQuery) {
#do stuff
} else {
# do stuff
}
function New-PoshSecTemplate {
[CmdletBinding()]
param(
## Baseline Parmerter Set
[Parameter(ParameterSetName='Baseline')]
[switch]$Baseline,
[Parameter(ParameterSetName='Baseline')]
[string]$BaselinePath
)
foreach ($entry in $entries) {
$object = New-Object psobject
$object | Add-Member -Name "mail" -value $entry.value
$object | Add-Member -Name "StevesInfo" -Value "Info"
}
[Cmdlet(VerbsCommon.Get, "MWJName")]
public class GetMwjName : PSCmdlet
{
private string _typedName;
[Parameter(
Mandatory = true,
ValueFromPipeline = true,
ValueFromPipelineByPropertyName = true,
Position = 0,
@mwjcomputing
mwjcomputing / Get-DnsLulz.ps1
Created July 7, 2014 14:14
A Fun DNS Lulz Script
function Get-DnsLulz {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$IPAddress
)
$TheIP = $IPAddress.Split('.')
for ($x=1; $x -le 3; $x++) {
@mwjcomputing
mwjcomputing / Test-IPv4Address.ps1
Created July 24, 2014 13:05
This function shows a cleanly written and well documented function.
function Test-IPv4Address {
[CmdletBinding()]
param(
[parameter(Mandatory=$true, ValueFromPipeline=$true, HelpMessage='Enter data to validate as IP Address.')]
[alias('IPAddress')]
[string]$IP
)
begin{}
process{
$Computer = 'localhost'
Get-EventLog -ComputerName $Computer System -Source Microsoft-Windows-Winlogon | select $UserProperty,$TypeProperty,$TimeProeprty
@mwjcomputing
mwjcomputing / Copy-VSCodeUserSnippets.ps1
Created May 17, 2018 13:43
Copy-VSCodeUserSnippets copies the VS Code User Snippet Files to a directory for backup.
function Copy-VSCodeUserSnippets {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, HelpMessage="Enter the destination address")]
[String] $Destination
)
# Global Variables
$SnippetFolder = "C:\Users\$ENV:Username\AppData\Roaming\Code\User\snippets\"
@mwjcomputing
mwjcomputing / DaysTillConverge2020.go
Created September 26, 2019 16:39
A simple Go script to calculate days until Converge 2020.
// ==================================================
// = FileName: daysTillConverge2020.go
// = Author: Matt Johnson (@mwjcomputing)
// = Description: Calculates days until Converge 2020
// ==================================================
package main
import (
"fmt"
@mwjcomputing
mwjcomputing / DaysTillConverge2020.py
Last active September 26, 2019 17:44
A simple Python script to calculate days until Converge 2020.
# ==================================================
# = FileName: daysTillConverge2020.py
# = Author: Matt Johnson (@mwjcomputing)
# = Description: Calculates days until Converge 2020
# ==================================================
# Import datetime module
import datetime
# Set start of Converge 2020 date and time