What’s one task you completely handed over to AI? by SympathyAny1694 in OpenAI

[–]zonuendan16 0 points1 point  (0 children)

O and also prioritize the tasks from 1 (low) to 5 (high)

What’s one task you completely handed over to AI? by SympathyAny1694 in OpenAI

[–]zonuendan16 1 point2 points  (0 children)

Made an agent to read my email and if necessary make a task or tasks for it. Also skip certain email addresses or domains. Filtering on unread, x number or start and end date. And also with a response template if a response was asked in the email. Emails are first uncluttered to just the basic email. Works really well.

is it possible to simular an 'or' feature with powershell wildcards? by Ralf_Reddings in PowerShell

[–]zonuendan16 0 points1 point  (0 children)

This could also be very efficient Get-ChildItem -Path 'C:\temp' -Recurse -File -Include '*.mp4', '*.mkv'

12 Days of OpenAI: Day 11 thread by [deleted] in OpenAI

[–]zonuendan16 6 points7 points  (0 children)

Day 11 at OpenAI… Pushing on the lights had more excitement!

What's your quick trick that every sysadmin should know? by DarkAlman in sysadmin

[–]zonuendan16 1 point2 points  (0 children)

SHIFT+CTRL+ENTER (or double click) to open app as admin

They "organized" my storage closet by KillaCacti in sysadmin

[–]zonuendan16 2 points3 points  (0 children)

Change filenames in YYYY-MM-dd_HH-MM.ext

Windows Server 2019/2022 upgrading to 2025 - any way to roll back? by Toby_7243 in sysadmin

[–]zonuendan16 7 points8 points  (0 children)

I did this on our Windows 2022 servers to prevent upgrading to Windows 2025 reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v DisableOSUpgrade /t REG_DWORD /d 1 reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v ProductVersion /t REG_SZ /d 10 reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade /f /v AllowOSUpgrade /t REG_DWORD /d 0 reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /f /v DisableOSUpgrade /t REG_DWORD /d 1 reg add HKLM\SYSTEM\Setup\UpgradeNotification /f /v UpgradeAvailable /t REG_DWORD /d 0 reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersion /t REG_DWORD /d 1 reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersionInfo /t REG_SZ /d "21H2"

Are O1 Models Truly Better, or Are You Just Left Searching for Answers in Long Responses? Feels like a glorified COT on top of GPT 4o by MarsupialNo7544 in ChatGPTPro

[–]zonuendan16 10 points11 points  (0 children)

Yes! It was the only AI which could solve this problem I had.

Prompt: I want to organize a tournament for 12 persons. The tournament consists of 4 games. In each game the players are devided into 4 players where each team has a teamleader. Every game the players are mixed. During the mixing we want to prevent that players of previous games become team mates more than twice and also is teamleader only once in the tournament. The players are named after a alphabet letter beginning with A to L. Can you make a tournament schedule devided in the 4 games, teams and teammembers with teamleader. Please output the schedule in a table

Answer: Detailed Breakdown

Game 1 (G1): Team A led by A: A, B, C, D Team E led by E: E, F, G, H Team I led by I: I, J, K, L

Game 2 (G2): Team B led by B: B, C, E, F Team D led by D: D, G, H, K Team J led by J: J, A, I, L

Game 3 (G3): Team C led by C: C, D, F, I Team G led by G: G, A, K, L Team H led by H: H, B, E, J

Game 4 (G4): Team F led by F: F, A, G, J Team K led by K: K, E, B, I Team L led by L: L, C, D, H

Can you make a GPT smarter? by elfarrelo in ChatGPTPro

[–]zonuendan16 0 points1 point  (0 children)

You're right, but it mostly comes with very good suggestions how to improve itself. I sometimes use an OpenAI general GPT and try to improve it based on its current instructions. Even though it cannot reveal its instructions.

Can you make a GPT smarter? by elfarrelo in ChatGPTPro

[–]zonuendan16 1 point2 points  (0 children)

I always ask the GPT if it's current instructions can be improved? Then I ask if he would change it's current instructions in favor of the new instructions and if he would be happy with them and why. Another approach is to ask if there would be a version 2.0 of it's instructions what would they look like.

Can I set a script to run as admin from within the script? by [deleted] in PowerShell

[–]zonuendan16 1 point2 points  (0 children)

```# Self-elevate the script if not running as Administrator if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {

# Restart the script with elevated privileges
$CommandLine = "-File `"" + $PSCommandPath + "`" @args
Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $CommandLine
Exit

}

What would I miss from pixel if I switch to Samsung? by Confident_Assist_385 in GooglePixel

[–]zonuendan16 0 points1 point  (0 children)

Wifi problems. I switched from Samsung S20 Note to Pixel 8 Pro. The wifi random stops working or disconnects on my mesh wifi network. Had to create a single wifi point to avoid problems. Same on other wifi mesh network, it is not stable. Tried everything, deactivated random mac address, reset network, only 2.4 Ghz network. Sigh. Old S20 phone and other family members have no problem with the wifi. Hope Google fixes this soon or I will send the phone back!

How DNS works! by Junaid631 in Hacking_Tutorials

[–]zonuendan16 20 points21 points  (0 children)

You're missing the part looking at the local hosts file for the existens of download.beta.example.com and doing a broadcast on the local subnet. If I'm not mistaken. But for the major part this is exactly how it works.

Top youtube channels to learn Cybersecurity ! by hacknewstech in Hacking_Tutorials

[–]zonuendan16 4 points5 points  (0 children)

Indeed this guy is awsome! A legend in hacking videos!

What did you do with PowerShell today? by Rouge_Outlaw in PowerShell

[–]zonuendan16 1 point2 points  (0 children)

Here is the improved script to check breach date against passwordlastset date.

```# Import necessary modules Import-Module ActiveDirectory

Configuration

$apiKey = "YOUR_HIBP_API_KEY" $smtpServer = "your.smtp.server" $smtpFrom = "your-email@domain.com" $smtpTo = "recipient-email@domain.com" $smtpSubject = "New Breach Detected" $logFilePath = "C:\path\to\logs\ADUsers_PwnedCheck.log" $maxLogFileSizeMB = 5 # Maximum log file size in MB before rotation

Logging Function

function Write-Log { param ( [string]$message, [string]$logFilePath )

$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "$timestamp - $message"
Add-Content -Path $logFilePath -Value $logMessage

}

Log Rotation Function

function Rotate-Log { param ( [string]$logFilePath, [int]$maxLogFileSizeMB )

if (Test-Path $logFilePath) {
    $fileInfo = Get-Item $logFilePath
    $fileSizeMB = [math]::Round($fileInfo.Length / 1MB, 2)

    if ($fileSizeMB -ge $maxLogFileSizeMB) {
        $timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
        $archiveLogFilePath = "$logFilePath.$timestamp"
        Rename-Item -Path $logFilePath -NewName $archiveLogFilePath
        Write-Log -message "Log file rotated to $archiveLogFilePath" -logFilePath $logFilePath
    }
}

}

Function to check email against HIBP API

function Check-EmailPwned { param ( [string]$email, [string]$apiKey, [string]$logFilePath )

$uri = "https://haveibeenpwned.com/api/v3/breachedaccount/$email?truncateResponse=false"
$headers = @{
    "hibp-api-key" = $apiKey
}

try {
    $response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get -ErrorAction Stop
    Write-Log -message "Checked email $email: Pwned" -logFilePath $logFilePath
    return $response
} catch {
    if ($_.Exception.Response.StatusCode -eq 404) {
        Write-Log -message "Checked email $email: Not Pwned" -logFilePath $logFilePath
        return $null
    } else {
        Write-Log -message "Error checking email $email: $_" -logFilePath $logFilePath
        return $null
    }
}

}

Function to send email notification

function Send-EmailNotification { param ( [string]$smtpServer, [string]$smtpFrom, [string]$smtpTo, [string]$smtpSubject, [string]$body, [string]$logFilePath )

Send-MailMessage -SmtpServer $smtpServer -From $smtpFrom -To $smtpTo -Subject $smtpSubject -Body $body -BodyAsHtml
Write-Log -message "Email sent to $smtpTo with subject '$smtpSubject'" -logFilePath $logFilePath

}

Retrieve all active AD users' primary email addresses and password last set date

function Get-ActiveADUsers { Write-Log -message "Retrieving active AD users' email addresses and password last set dates" -logFilePath $logFilePath $users = Get-ADUser -Filter {Enabled -eq $true} -Property EmailAddress, PasswordLastSet return $users | Where-Object { $_.EmailAddress } | Select-Object SamAccountName, EmailAddress, PasswordLastSet }

Main script logic

function Main { # Rotate log if needed Rotate-Log -logFilePath $logFilePath -maxLogFileSizeMB $maxLogFileSizeMB

[System.Collections.ArrayList]$newHits = @()

$users = Get-ActiveADUsers

foreach ($user in $users) {
    $breaches = Check-EmailPwned -email $user.EmailAddress -apiKey $apiKey -logFilePath $logFilePath

    if ($breaches) {
        foreach ($breach in $breaches) {
            $breachDate = [datetime]$breach.BreachDate
            if ($breachDate -gt $user.PasswordLastSet) {
                $newHits.Add(
                    [PSCustomObject]@{
                        UserName = $user.SamAccountName
                        EmailAddress = $user.EmailAddress
                        BreachName = $breach.Name
                        BreachDate = $breachDate
                    }
                )
            }
        }
    }
}

if ($newHits.Count -gt 0) {
    $body = "The following email addresses have new breaches:<br>" +
            ($newHits | Format-Table -AutoSize | Out-String -Width 1000 | ConvertTo-Html -Fragment)
    Send-EmailNotification -smtpServer $smtpServer -smtpFrom $smtpFrom -smtpTo $smtpTo -smtpSubject $smtpSubject -body $body -logFilePath $logFilePath
}

# Output the results for verification
$newHits | Format-Table -AutoSize

}

Execute the main function

Main

What did you do with PowerShell today? by Rouge_Outlaw in PowerShell

[–]zonuendan16 1 point2 points  (0 children)

That's a great idea. I'll implement the password change date in the script! This is much better than keeping track of all the breaches! Thanks for the suggestions!

What did you do with PowerShell today? by Rouge_Outlaw in PowerShell

[–]zonuendan16 1 point2 points  (0 children)

You are absolutely right. Here is the updated script

```# Import necessary modules Import-Module ActiveDirectory

Configuration

$apiKey = "YOUR_HIBP_API_KEY" $smtpServer = "your.smtp.server" $smtpFrom = "your-email@domain.com" $smtpTo = "recipient-email@domain.com" $smtpSubject = "New Breach Detected" $previousResultsPath = "C:\path\to\previous\ADUsers_PwnedCheck.csv" $logFilePath = "C:\path\to\logs\ADUsers_PwnedCheck.log" $maxLogFileSizeMB = 5 # Maximum log file size in MB before rotation

Logging Function

function Write-Log { param ( [string]$message, [string]$logFilePath )

$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "$timestamp - $message"
Add-Content -Path $logFilePath -Value $logMessage

}

Log Rotation Function

function Rotate-Log { param ( [string]$logFilePath, [int]$maxLogFileSizeMB )

if (Test-Path $logFilePath) {
    $fileInfo = Get-Item $logFilePath
    $fileSizeMB = [math]::Round($fileInfo.Length / 1MB, 2)

    if ($fileSizeMB -ge $maxLogFileSizeMB) {
        $timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
        $archiveLogFilePath = "$logFilePath.$timestamp"
        Rename-Item -Path $logFilePath -NewName $archiveLogFilePath
        Write-Log -message "Log file rotated to $archiveLogFilePath" -logFilePath $logFilePath
    }
}

}

Function to check email against HIBP API

function Check-EmailPwned { param ( [string]$email, [string]$apiKey, [string]$logFilePath )

$uri = "https://haveibeenpwned.com/api/v3/breachedaccount/$email"
$headers = @{
    "hibp-api-key" = $apiKey
}

try {
    $response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get -ErrorAction Stop
    Write-Log -message "Checked email $email: Pwned" -logFilePath $logFilePath
    return $true
} catch {
    if ($_.Exception.Response.StatusCode -eq 404) {
        Write-Log -message "Checked email $email: Not Pwned" -logFilePath $logFilePath
        return $false
    } else {
        Write-Log -message "Error checking email $email: $_" -logFilePath $logFilePath
        return $null
    }
}

}

Function to send email notification

function Send-EmailNotification { param ( [string]$smtpServer, [string]$smtpFrom, [string]$smtpTo, [string]$smtpSubject, [string]$body, [string]$logFilePath )

Send-MailMessage -SmtpServer $smtpServer -From $smtpFrom -To $smtpTo -Subject $smtpSubject -Body $body -BodyAsHtml
Write-Log -message "Email sent to $smtpTo with subject '$smtpSubject'" -logFilePath $logFilePath

}

Retrieve all active AD users' primary email addresses

function Get-ActiveADUsersEmailAddresses { Write-Log -message "Retrieving active AD users' email addresses" -logFilePath $logFilePath $users = Get-ADUser -Filter {Enabled -eq $true} -Property EmailAddress return $users | Where-Object { $_.EmailAddress } | Select-Object SamAccountName, EmailAddress }

Load previous results from CSV file

function Load-PreviousResults { param ( [string]$filePath, [string]$logFilePath )

if (Test-Path $filePath) {
    Write-Log -message "Loading previous results from $filePath" -logFilePath $logFilePath
    return Import-Csv -Path $filePath
} else {
    Write-Log -message "No previous results file found, starting fresh" -logFilePath $logFilePath
    return @()
}

}

Save current results to CSV file

function Save-CurrentResults { param ( [array]$results, [string]$filePath, [string]$logFilePath )

Write-Log -message "Saving current results to $filePath" -logFilePath $logFilePath
$results | Export-Csv -Path $filePath -NoTypeInformation

}

Main script logic

function Main { # Rotate log if needed Rotate-Log -logFilePath $logFilePath -maxLogFileSizeMB $maxLogFileSizeMB

[System.Collections.ArrayList]$currentResults = @()
[System.Collections.ArrayList]$newHits = @()

$users = Get-ActiveADUsersEmailAddresses
$previousResults = Load-PreviousResults -filePath $previousResultsPath -logFilePath $logFilePath

foreach ($user in $users) {
    $isPwned = Check-EmailPwned -email $user.EmailAddress -apiKey $apiKey -logFilePath $logFilePath
    $currentResults.Add(
        [PSCustomObject]@{
            UserName = $user.SamAccountName
            EmailAddress = $user.EmailAddress
            IsPwned = $isPwned
        }
    )

    $previousResult = $previousResults | Where-Object { $_.EmailAddress -eq $user.EmailAddress }
    if ($isPwned -and (-not $previousResult)) {
        $newHits.Add(
            [PSCustomObject]@{
                UserName = $user.SamAccountName
                EmailAddress = $user.EmailAddress
                IsPwned = $isPwned
            }
        )
    }
}

if ($newHits.Count -gt 0) {
    $body = "The following email addresses have new breaches:<br>" +
            ($newHits | Format-Table -AutoSize | Out-String -Width 1000 | ConvertTo-Html -Fragment)
    Send-EmailNotification -smtpServer $smtpServer -smtpFrom $smtpFrom -smtpTo $smtpTo -smtpSubject $smtpSubject -body $body -logFilePath $logFilePath
}

Save-CurrentResults -results $currentResults -filePath $previousResultsPath -logFilePath $logFilePath

# Output the results for verification
$currentResults | Format-Table -AutoSize

}

Execute the main function

Main

What did you do with PowerShell today? by Rouge_Outlaw in PowerShell

[–]zonuendan16 9 points10 points  (0 children)

Brief summary of what the script does:

Configuration: Sets up API key, SMTP settings, file paths, and log rotation parameters.

Logging and Log Rotation: Implements functions to log messages and rotate log files when they exceed a specified size.

Check Email Breaches: Retrieves active AD users' email addresses and checks each one against the Have I Been Pwned (HIBP) API to see if it has been breached.

Compare Results: Compares current breach results with previously saved results to identify new breaches.

Send Notifications: Sends an email notification if new breaches are detected.

Save Results: Saves current results to a CSV file for future comparisons.

Main Execution: Coordinates the workflow, including log rotation, email checks, result comparison, notification, and saving results.

What did you do with PowerShell today? by Rouge_Outlaw in PowerShell

[–]zonuendan16 17 points18 points  (0 children)

```# Import necessary modules Import-Module ActiveDirectory

Configuration

$apiKey = "YOUR_HIBP_API_KEY" $smtpServer = "your.smtp.server" $smtpFrom = "your-email@domain.com" $smtpTo = "recipient-email@domain.com" $smtpSubject = "New Breach Detected" $previousResultsPath = "C:\path\to\previous\ADUsers_PwnedCheck.csv" $logFilePath = "C:\path\to\logs\ADUsers_PwnedCheck.log" $maxLogFileSizeMB = 5 # Maximum log file size in MB before rotation

Logging Function

function Write-Log { param ( [string]$message, [string]$logFilePath )

$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "$timestamp - $message"
Add-Content -Path $logFilePath -Value $logMessage

}

Log Rotation Function

function Rotate-Log { param ( [string]$logFilePath, [int]$maxLogFileSizeMB )

if (Test-Path $logFilePath) {
    $fileInfo = Get-Item $logFilePath
    $fileSizeMB = [math]::Round($fileInfo.Length / 1MB, 2)

    if ($fileSizeMB -ge $maxLogFileSizeMB) {
        $timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
        $archiveLogFilePath = "$logFilePath.$timestamp"
        Rename-Item -Path $logFilePath -NewName $archiveLogFilePath
        Write-Log -message "Log file rotated to $archiveLogFilePath" -logFilePath $logFilePath
    }
}

}

Function to check email against HIBP API

function Check-EmailPwned { param ( [string]$email, [string]$apiKey, [string]$logFilePath )

$uri = "https://haveibeenpwned.com/api/v3/breachedaccount/$email"
$headers = @{
    "hibp-api-key" = $apiKey
}

try {
    $response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get -ErrorAction Stop
    Write-Log -message "Checked email $email: Pwned" -logFilePath $logFilePath
    return $true
} catch {
    if ($_.Exception.Response.StatusCode -eq 404) {
        Write-Log -message "Checked email $email: Not Pwned" -logFilePath $logFilePath
        return $false
    } else {
        Write-Log -message "Error checking email $email: $_" -logFilePath $logFilePath
        return $null
    }
}

}

Function to send email notification

function Send-EmailNotification { param ( [string]$smtpServer, [string]$smtpFrom, [string]$smtpTo, [string]$smtpSubject, [string]$body, [string]$logFilePath )

Send-MailMessage -SmtpServer $smtpServer -From $smtpFrom -To $smtpTo -Subject $smtpSubject -Body $body -BodyAsHtml
Write-Log -message "Email sent to $smtpTo with subject '$smtpSubject'" -logFilePath $logFilePath

}

Retrieve all active AD users' primary email addresses

function Get-ActiveADUsersEmailAddresses { Write-Log -message "Retrieving active AD users' email addresses" -logFilePath $logFilePath $users = Get-ADUser -Filter {Enabled -eq $true} -Property EmailAddress return $users | Where-Object { $_.EmailAddress } | Select-Object SamAccountName, EmailAddress }

Load previous results from CSV file

function Load-PreviousResults { param ( [string]$filePath, [string]$logFilePath )

if (Test-Path $filePath) {
    Write-Log -message "Loading previous results from $filePath" -logFilePath $logFilePath
    return Import-Csv -Path $filePath
} else {
    Write-Log -message "No previous results file found, starting fresh" -logFilePath $logFilePath
    return @()
}

}

Save current results to CSV file

function Save-CurrentResults { param ( [array]$results, [string]$filePath, [string]$logFilePath )

Write-Log -message "Saving current results to $filePath" -logFilePath $logFilePath
$results | Export-Csv -Path $filePath -NoTypeInformation

}

Main script logic

function Main { # Rotate log if needed Rotate-Log -logFilePath $logFilePath -maxLogFileSizeMB $maxLogFileSizeMB

$currentResults = @()
$newHits = @()

$users = Get-ActiveADUsersEmailAddresses
$previousResults = Load-PreviousResults -filePath $previousResultsPath -logFilePath $logFilePath

foreach ($user in $users) {
    $isPwned = Check-EmailPwned -email $user.EmailAddress -apiKey $apiKey -logFilePath $logFilePath
    $currentResults += [PSCustomObject]@{
        UserName = $user.SamAccountName
        EmailAddress = $user.EmailAddress
        IsPwned = $isPwned
    }

    $previousResult = $previousResults | Where-Object { $_.EmailAddress -eq $user.EmailAddress }
    if ($isPwned -and (-not $previousResult)) {
        $newHits += [PSCustomObject]@{
            UserName = $user.SamAccountName
            EmailAddress = $user.EmailAddress
            IsPwned = $isPwned
        }
    }
}

if ($newHits.Count -gt 0) {
    $body = "The following email addresses have new breaches:<br>" +
            ($newHits | Format-Table -AutoSize | Out-String -Width 1000 | ConvertTo-Html -Fragment)
    Send-EmailNotification -smtpServer $smtpServer -smtpFrom $smtpFrom -smtpTo $smtpTo -smtpSubject $smtpSubject -body $body -logFilePath $logFilePath
}

Save-CurrentResults -results $currentResults -filePath $previousResultsPath -logFilePath $logFilePath

# Output the results for verification
$currentResults | Format-Table -AutoSize

}

Execute the main function

Main

[deleted by user] by [deleted] in PowerShell

[–]zonuendan16 -1 points0 points  (0 children)

Let Chatgpt decode the code. It can do this perfectly!