Skip to content

Instantly share code, notes, and snippets.

View ArtisanByteCrafter's full-sized avatar

Nathaniel Webb ArtisanByteCrafter

View GitHub Profile
@ArtisanByteCrafter
ArtisanByteCrafter / AOC_Day5.ps1
Last active December 23, 2020 16:28
Advent Of Code Day 5 2020
#-------
# PART 1
#-------
# input file
$plane=Get-Content "/Users/{username}/Downloads/AdventOfCode_Day5.txt"
Function Get-Seat {
[cmdletbinding()]
param(
[Parameter(Mandatory)]
@ArtisanByteCrafter
ArtisanByteCrafter / Get-GhostBlogStatusCode.ps1
Last active June 9, 2020 06:05
gets the status codes of a ghost blog's public urls
[string] $Site = 'https://www.example.com'
[string] $ApiKey = '123456'
$posts = (Invoke-RestMethod -Uri "$Site/ghost/api/v2/content/posts/?key=$ApiKey").posts.url
$posts | Foreach-Object {
[PSCustomObject]@{
'Url'=$_
'StatusCode'=(iwr -Uri $_).StatusCode
}
@ArtisanByteCrafter
ArtisanByteCrafter / IPAddresses.ps1
Created June 20, 2019 01:27
a Universal Dashboard implementation of IP Addresses from nmap
New-UDPage -Name "Home" -Icon home -Content {
New-UDRow -Columns {
New-UDColumn -Size 6 {
New-UDGrid -Title 'IP Addresses' -AutoRefresh -RefreshInterval 3600 -Endpoint {
$IPs = nmap -sn 192.168.202.0/24 | grep scan
$Results = Foreach ($IP in $IPs) {
[PSCustomObject]@{
Hostname = ($IP -split ' ')[4]
IP = ($IP -split ' ')[5]
}
# This is required if script is not run as admin. It will open up this script as Admin
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
$Orgs = @('Default', 'YourOrg1', 'YourOrg2')
$Result = Foreach ($Org in $Orgs) {
$params = @{
Server = "https://kace.example.com"
Org = $Org
Credential = (Get-Credential) # or supply stored creds in desired manner
QueryParameters = "?paging=limit all"
}
$query = Get-SmaMachineInventory @params
Function Get-OwnedPW {
param(
[string] $test
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$a, $b = (Get-FileHash -A 'SHA1' -I ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($test)))).Hash -split '(?<=^.{5})'
(((Invoke-RestMethod "https://api.pwnedpasswords.com/range/$a" -UseB) -split '\r\n' -like "$b*") -split ':')[-1] |
Foreach-Object {
Write-Host -ForegroundColor Green "This has been publically cracked $_ times according to api.pwnedpasswords.com"
@ArtisanByteCrafter
ArtisanByteCrafter / WBSummary.ps1
Created April 11, 2019 23:04
PRTG sensor for Get-WBSummary
param(
[Parameter(Mandatory = $true)]
[string] $Device,
[PSCredential] $Credential
)
$InvokeParams = @{
Computername = $Device
ScriptBlock = { Get-WBSummary }
# Often, a 32-bit binary needs to call a 64bit binary or registry hive.
# Place the following code at the very top of a powershell script to determine if powershell.exe is being invoked as a 32bit process, redirect it to use 64bit, then continue executing whatever follows.
# Relaunch in x64 powershell if not already
if ($PSHOME -like "*syswow64*") {
Write-Output 'Relaunching as x64'
& (Join-Path ($PSHOME -replace 'syswow64', 'sysnative') powershell.exe) `
-File $Script:MyInvocation.MyCommand.Path `
@args
Exit
# put programs to remove in this array. Java and Opera are in this example.
$remove = @('*Java*', '*Opera*' )
function Get-InstalledApps {
param (
[Parameter(ValueFromPipeline=$true)]
[string[]]$ComputerName = $env:COMPUTERNAME,
[string]$NameRegex = ''
)
$Servers = Get-ADComputer -Filter {(enabled -eq $True) -and (OperatingSystem -like "*Windows*")} | Select-Object -ExpandProperty Name
$OnlineServers = Test-Connection -ComputerName $Servers -AsJob -Count 1 | Wait-Job | Receive-Job | where-object { $_.StatusCode -eq 0} | select -ExpandProperty Address
$RemoteScriptBlock = {
$SMB1Enabled = Get-SmbServerConfiguration | Select-Object -ExpandProperty EnableSMB1Protocol
[pscustomobject]@{
'Computer' = $Env:ComputerName
'SMB1 Present' = $SMB1Enabled