Skip to content

Instantly share code, notes, and snippets.

@markgodiy
markgodiy / PSGadgets_Session.md
Last active March 18, 2025 22:07
PSGadgets_Session

PSGadgets_Session

[[TOC]]

WTF is it?

Why do you use it?

What can it do?

@markgodiy
markgodiy / Invoke-Groq.ps1
Last active February 1, 2025 15:32
Invoke-Groq
function Invoke-Groq {
[cmdletbinding()]
param (
[Parameter(Mandatory, Position=0)]
[ValidateNotNull()]
[string]$Prompt, # The input prompt or query to be processed by the API.
[Parameter(Position=1)]
[ValidateNotNullOrEmpty()]
[string]$APIKey = $env:GROQ_API_Key, # API key to authenticate requests to the Groq API.
@markgodiy
markgodiy / ft232h_test.ps1
Last active October 28, 2024 03:30
PowerShell7_iot.device
Add-type -AssemblyName System.Drawing # Required for SkiaSharp
$packagespath = "G:\CSharp\GzeroFT232H\bin\Debug"
gci $packagespath\*.dll | % {
try {
[System.Reflection.Assembly]::LoadFrom($_.FullName)
} catch {
Write-Host "Error loading assembly: $_"
}
@markgodiy
markgodiy / Get-CVEInfo.ps1
Created June 27, 2024 20:36
Get-CVEInfo from CISA Vulnrichment repo
function Get-CVEInfo {
<#
.DESCRIPTION
Get-CVEInfo from CISA Vulnrichment repo. MarkGo2024.
.EXAMPLE
Get-CVEInfo -cveId "CVE-2024-39466"
#>
param (
[string]$cveId
)
<#
A MarkGo project. JUN2024.
Person Sensor Developer Guide
https://github.com/usefulsensors/person_sensor_docs?tab=readme-ov-file#connecting
Byte format (39 bytes)
--------------------
0,1 Reserved
@markgodiy
markgodiy / Out-ZebraZPL.ps1
Last active April 16, 2024 14:54
Print Zebra ZPL using PowerShell and C#
<#
DISCLAIMER: Script is not optimized, just a quick example and reference
RESOURCES:
- Csharp script doing the heavy lifting is by barrypicker; https://stackoverflow.com/a/13201219 posted Nov 2, 2012
- Use `Get-Printer` to find your Zebra Printer Name
- Use https://labelary.com/viewer.html for help with ZPL and preview
- Official Zebra ZPLII programming guide https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/printers/common/programming/zpl-zbi2-pm-en-pg.pdf
#>
// The provided code consists of several C# classes and namespaces that work together to facilitate USB communication with Zebra printers from a .NET application. Below is a brief overview of each component:
// ZebraUsbStream.cs: Defines a ZebraUsbStream class that extends the System.IO.Stream class, specifically for communicating with Zebra printers via USB. It uses an instance of UsbPrinterConnector to handle the low-level USB operations. The class overrides several members of the Stream class, such as Read(), Write(), and Flush(), to utilize the underlying USB connection. It also manages connection state and timeouts.
// FileIO.cs: Contains the FileIO class, which is a utility class providing P/Invoke signatures for various Windows API functions related to file and device I/O operations. This includes methods for creating files (CreateFile), writing to files (WriteFile), and reading from files (ReadFile), among others. These functions are used for low-level access to the USB devices.
// PrinterConnecto
@markgodiy
markgodiy / cndcompanionhashtables.txt
Created November 14, 2023 19:41
cndcompanionhashtables.txt
$WingetCommonID = @{
"Google Chrome" = "Google.Chrome"
"Microsoft Edge" = "Microsoft.Edge"
"Mozilla Firefox" = "Mozilla.Firefox"
"Adobe Acrobat Reader DC x64" = "Adobe.Acrobat.Reader.64-bit"
"Adobe Acrobat Reader DC x32" = "Adobe.Acrobat.Reader.32-bit"
"Visual Studio Code" = "Microsoft.VisualStudioCode"
"Microsoft SQL Server" = "Microsoft.SQLServer"
}
@markgodiy
markgodiy / Get-SCCMPendingPatches.ps1
Created August 21, 2023 13:06
Get-SCCMPendingPatches
<#
.DESCRIPTION
Author: Mark Go
PowerShell script designed to check for pending patches available via SCCM (System Center Configuration Manager). It provides the ability to retrieve pending patch information for specified remote computers and can be used to identify patches that need to be installed. The script also includes the option to automatically start the WinRM service on target hosts if necessary.
.EXAMPLE
Get-SCCMPendingPatches SERVER01 -Verbose
Get pending patches for a specific computer
@markgodiy
markgodiy / gist:7f30f97b4c2da4d3354632652b7caa05
Created July 14, 2023 18:36
WIP-Test-HP-HTTPWebRequest.ps1
$printerIP = <IPaddrr>
# $firmwareFilePath = "C:\path\to\ljM506_fs3.9.12_fw_2309088_001464.bdl"
$policyType = [System.AppDomain]::CurrentDomain.GetAssemblies() |
ForEach-Object { $_.GetTypes() } |
Where-Object { $_.Name -eq 'TrustAllCertsPolicy' }
if (-not $policyType) {
$code = @"
using System.Net;