Skip to content

Instantly share code, notes, and snippets.

@jrdnr
jrdnr / Get-AVStatus.ps1
Created April 10, 2022 03:21 — forked from jdhitsolutions/Get-AVStatus.ps1
This PowerShell function uses WMI via the Get-CimInstance command to query the state of installed anti-virus products.
#requires -version 5.1
Function Get-AVStatus {
<#
.Synopsis
Get anti-virus product information.
.Description
This command uses WMI via the Get-CimInstance command to query the state of installed anti-virus products. The default behavior is to only display enabled products, unless you use -All. You can query by computername or existing CIMSessions.
.Example
@jrdnr
jrdnr / Install-MSUWindowsUpdate.ps1
Last active July 15, 2021 18:46
Download and Install MSU from Hashtable based on OS version
# CU KBs and DL links https://www.catalog.update.microsoft.com/Search.aspx?q=2021-03%20cumulative%20update
#Optional Runtime Variable $AutoReboot False by default.
"`$AutoReboot set to '$AutoReboot'"
# Get Windows Version
$winVer = Get-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion" |
Select-Object -Property ReleaseID,@{
n='Version'; e={[System.Version]('{0}.{1}.{2}' -f [int]$_.CurrentMajorVersionNumber,[int]$_CurrentMinorVersionNumber,[int]$_.CurrentBuildNumber)}}
$kbs = @{
### Keybase proof
I hereby claim:
* I am jrdnr on github.
* I am jrdnr (https://keybase.io/jrdnr) on keybase.
* I have a public key ASDk9_-qGILludu2PsKlxuEVfA3eQouG0J1cnZYMrOXE1go
To claim this, I am signing this object:
@jrdnr
jrdnr / CheckPublicNetwork.ps1
Last active July 15, 2021 18:45
CheckPublicNetwork.ps1
if ($env:SyncroModule){Import-Module $env:SyncroModule}
$PartOfDomain = (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain
# Check for network connections set to Public
[hashtable]$NetworkConnections = @{}
try {
$networkInfo = Get-NetConnectionProfile -ErrorAction Stop
}
@jrdnr
jrdnr / Retrieve BitLockerRecoverKeys.ps1
Last active July 15, 2021 18:46
Retrieve Bitlocker Recovery Keys to Syncro
# Prerequisites: You must have a custom asset field
# Name: "Bitlocker Drives"
# Type: "Text area"
#
try{
# Get Bitlocker Volumes or exit.
$BitLockerVolume = Get-BitLockerVolume -ErrorAction stop
# Create output as [string] for Text area Asset-Field.
@jrdnr
jrdnr / TryCatchURLtoXML.ps1
Last active April 14, 2020 16:40
Catching Exceptions when retrieving xml from web
$PMESetup_detailsURI = 'https://sis.n-able.com/Components/MSP-PME/latest/PMESetup_details.xml'
try {
$PMESetup_details = Invoke-RestMethod $PMESetup_detailsURI
#This xml file has some weird characters at the start of the first line
#Splitting on '<\?xml.*\?>' and selecting last part as Powershell does not need that line to parse xml
[xml]$x = ($PMESetup_details -split '<\?xml.*\?>')[-1]
$PMEdetails = $x.ComponentDetails
}
catch [System.Net.WebException] {
Write-Output 'Error Fetching PMESetup_Details.xml Doublecheck your Source URL!!'
@jrdnr
jrdnr / CollectionBuilder.ps1
Last active May 13, 2020 01:59
Test Speed to read a file and build a collection in powershell
# Using the following file from
# https://github.com/danielmiessler/SecLists/blob/master/Passwords/Common-Credentials/10-million-password-list-top-100000.txt
#$FilePath = 'C:\git\SecLists\Passwords\Common-Credentials\10-million-password-list-top-500.txt'
$FilePath = 'C:\git\SecLists\Passwords\Common-Credentials\10-million-password-list-top-10000.txt'
#$FilePath = 'C:\git\SecLists\Passwords\Common-Credentials\10-million-password-list-top-100000.txt'
#$FilePath = 'C:\rockyou.txt'
$LineLengthFilter = 1
#requires -Version 4.0
<#
Author: Luke Murray (Luke.Geek.NZ)
Version: 0.1
Purpose: Windows 10 Baseline Hardening using DSC per DoD DISA STIG recommendations 22/06/18.
Modified to include comments explaining config by Frankie McDonough 01/23/19.
#>
Configuration 'Win10'
{
function Get-ChocoJsonPackage {
$PackageCacheSec = (Get-Date).AddSeconds('-60')
$ChocojsonList = Join-Path -Path $env:ChocolateyInstall -ChildPath 'ChocoInstalled.json'
if ( $PackageCacheSec -lt (Get-Item $ChocojsonList -ErrorAction SilentlyContinue).LastWriteTime ) {
$res = (Get-Content -Raw $ChocojsonList | ConvertFrom-Json)
} else {
choco list -lo -r | ConvertFrom-Csv -Header 'Name', 'Version' -Delimiter "|" -OutVariable res | ConvertTo-Json | Out-File $ChocojsonList
}