Explicit Permission Hunter

# Specify the root folder path
$rootFolderPath = "C:\Temp"
 
# Get all items (files and subfolders) under the root folder
$items = Get-ChildItem -Path $rootFolderPath -Recurse
 
# Iterate through each item
foreach ($item in $items) {
    # Get the ACL for the item
    $acl = Get-Acl -Path $item.FullName
 
    # Check if any explicit permissions exist (not inherited)
    $explicitPermissions = $acl.Access | Where-Object { $_.IsInherited -eq $false }
 
    if ($explicitPermissions.Count -gt 0) {
        Write-Host "Explicit permissions found for $($item.FullName):"
        foreach ($permission in $explicitPermissions) {
            Write-Host "  User: $($permission.IdentityReference)"
            Write-Host "  Permissions: $($permission.FileSystemRights)"
            Write-Host "  Access Control Type: $($permission.AccessControlType)"
            Write-Host "  Inherited: $($permission.IsInherited)"
            Write-Host ""
        }
    }
}

Validate SHA256 Checksums with Python

import tkinter as tk
from tkinter import filedialog, simpledialog, messagebox
import hashlib

def calculate_sha256(file_path):
    sha256_hash = hashlib.sha256()
    with open(file_path, "rb") as f:
        # Read and update hash string value in blocks of 4K
        for byte_block in iter(lambda: f.read(4096), b""):
            sha256_hash.update(byte_block)
    return sha256_hash.hexdigest()

def verify_checksum():
    file_path = filedialog.askopenfilename(title="Select the file to check the SHA256 checksum on", filetypes=[("All Files", "*.*")])

    if file_path:
        # Prompt user for SHA256 checksum
        entered_checksum = simpledialog.askstring("Checksum Verification", "Enter SHA256 checksum:")

        # Calculate the SHA256 checksum of the selected file
        file_checksum = calculate_sha256(file_path)

        # Compare entered checksum with calculated checksum
        if entered_checksum == file_checksum:
            messagebox.showinfo("Verification Result", "Checksum verification successful. The file has not been tampered with.")
        else:
            messagebox.showerror("Verification Result", "Checksum verification failed. The file may have been tampered with.")
    else:
        messagebox.showinfo("File Selection", "File selection cancelled by the user.")

# Create the main application window
root = tk.Tk()
root.withdraw()  # Hide the main window

# Call the verify_checksum function
verify_checksum()

# Start the main loop
root.mainloop()

Don’t Scan Random QR codes

Don’t scan codes from strangers (if you receive a QR code from an unsolicited message — text, social media, email, or physical — be skeptical and don’t use it!) If it’s a physical QR code — take a look to see if it was tampered with.

Check service status on multiple nodes

# List of remote computer names
$computers = @("Server01", "Server02", "Server03", "Server04", "Server05", "Server06")
 
# Name of the service you want to check
$serviceName = "PrintSpooler"
 
# Loop through the list of remote computers and check the service status
foreach ($computer in $computers) {
    try {
        $serviceStatus = Get-Service -ComputerName $computer -Name $serviceName
        Write-Host "Service $serviceName on $computer is $($serviceStatus.Status)"
    } catch {
        Write-Host "Failed to get service status on" $computer
    }
}

Show all users RDP’d into many computers


# List of computer names or IP addresses.
# Note: Un-comment the preferred source 
#$computers = @("ServerA", "ServerB")
#$computers = Get-Content -Path "C:\TEMP\AllNodes.txt
 
foreach ($computer in $computers) {
    Write-Host "Users logged on to"$computer":"
    try {
        $loggedOnUsers = query user /server:$computer 2>&1 | ForEach-Object {
            # Split the line into individual pieces of information
            $userDetails = $_ -split '\s+'
            if ($userDetails[1] -ne "USERNAME" -and $userDetails[1] -ne "No") {
                # Filter out header and empty lines
                $userDetails[1]
            }
        }
       
        if ($loggedOnUsers -eq $null) {
            Write-Host "No users are currently logged on to $computer."
        } else {
            $loggedOnUsers
        }
    } catch {
        Write-Host "Error connecting to "$computer": $_"
    }
    Write-Host
}
 

Check for Windows Activation for a group of nodes

 
# Define list of nodes to check
$servers = Get-Content -Path "C:\TEMP\AllNodes.txt" 
 
# Query activation status
foreach ($server in $servers) {
    $activation = Get-WmiObject -Query "SELECT * FROM SoftwareLicensingProduct WHERE (PartialProductKey IS NOT NULL)" -ComputerName $server
   
    if ($activation) {
        Write-Host "Server $server is activated."
    } else {
        Write-Host "Server $server is not activated."
    }
}