Categories:
Email 🠪 Servers 🠪 Testing 🠪 Tips
Hardware 🠪 3D Printing 🠪 Apple 🠪 Batteries 🠪 Drives 🠪 Edgerouter 🠪 Electronics 🠪 Laptop 🠪 Modems 🠪 Phone 🠪 Printers 🠪 Raspberry Pi 🠪 Testing 🠪 Virtualization
Links 🠪 Interesting 🠪 Media
Network 🠪 Data 🠪 Testing 🠪 VPN
Scripts 🠪 Batch 🠪 Linux 🠪 Powershell
Servers 🠪 Databases 🠪 Misc 🠪 Website
Software 🠪 Other
Utilities 🠪 Backup 🠪 Fix Issues 🠪 Recovery
Video 🠪 Editing
Websites 🠪 HTML 🠪 Testing
Windows 🠪 Adjustments 🠪 Issues 🠪 Remote Desktop 🠪 Sercurity 🠪 Slow 🠪 Software 🠪 Startup
Submit Entry | Airin's Notes
Category: Scripts 🠪 Powershell Add full size logo to images | May 24, 2022 | # Call script using:
# powershell.exe -File "AddLogo.ps1" -Filename "C:\Tools\Scripts\File.jpg" -Suffix "-Honor" -TemplateFile "C:\Tools\Scripts\Batch\Template.png"
param([String]$Filename="", [String]$Suffix="", [String]$TemplateFile="")
Add-Type -AssemblyName 'System.Drawing'
if ( $psise ){
$SourceImage = "C:\Tools\Scripts\Batch\test4.jpg"
$Suffix = "-Honor"
$TemplateFile = "C:\Tools\Scripts\Batch\Template-HH.png"
}else{
$SourceImage = $Filename
if ( $Suffix.length -lt 0 ){ $Suffix = "-New" }
}
$SpacingLeft = [Math]::Round( 50 * ( $Image.width / 2400 ) )
$SpacingRight = $SpacingLeft
$SpacingTop = [Math]::Round( 50 * ( $Image.height / 2051 ) )
$SpacingBottom = [Math]::Round( 277 * ( $Image.height / 2051 ) )
Write-Host "Loading picture: $($SourceImage)"
$Image = [System.Drawing.Bitmap]::FromFile($SourceImage)
$FinalImagePath = ( ( $SourceImage | Split-Path -Parent ) + '\' + [System.IO.Path]::GetFileNameWithoutExtension($SourceImage) + $Suffix + ".jpg" )
$Template = [System.Drawing.Bitmap]::FromFile($TemplateFile)
$TemplateResized = New-Object System.Drawing.Bitmap( ( $Image.width + $SpacingLeft + $SpacingRight ).ToInt32($null) , ( $Image.Height + $SpacingTop + $SpacingBottom ).ToInt32($null) )
$TemplateGraphics = [System.Drawing.Graphics]::FromImage($TemplateResized)
$TemplateGraphics.DrawImage($Template, 0, 0, ($Image.width + $SpacingLeft + $SpacingRight ) , ( $Image.Height + $SpacingTop + $SpacingBottom ))
$FinalCanvas = [System.Drawing.Bitmap]::new( ($Image.width + $SpacingLeft + $SpacingRight ).ToInt32($null) , ( $Image.Height + $SpacingTop + $SpacingBottom ).ToInt32($null) )
$g = [System.drawing.graphics]::FromImage($FinalCanvas)
$g.Clear([System.Drawing.Color]::Black)
# Put it there
#$g.DrawImage($Image, $SpacingLeft, $SpacingTop)
#$g.DrawImage($Image, [System.Drawing.Point]::new($SpacingLeft, $SpacingTop) , [System.Drawing.Rectangle]::new(0,0,100,100) )
$g.DrawImage($Image, [System.Drawing.Rectangle]::new($SpacingLeft,$SpacingTop,$Image.width,$Image.height) , [System.Drawing.Rectangle]::new(0,0,$Image.width,$Image.height) , [System.Drawing.GraphicsUnit]::Pixel)
$g.DrawImage($TemplateResized, 0, 0)
#$g.DrawString("test")
# Save it
Write-Host "Saving picture: $FinalImagePath"
$FinalCanvas.Save($FinalImagePath, [System.Drawing.Imaging.ImageFormat]::Jpeg) |
Category: Scripts 🠪 Powershell Debugging | May 24, 2022 | Debug another powershell process. I recommend using this in PSISE.
$ProcessList = Get-Process powershell
Enter-PSHostProcess -Process $ProcessList[correctindex]
Get-Runspace
Debug-Runspace -Id [RunspaceIndex]
|
Category: Scripts 🠪 Powershell Delete duplicate files found with a suffix like (Copy) | May 24, 2022 | $Folder = "E:\Recovered_Files"
$ScanSubfolders = $false
$SuffixForDuplicate = " - Copy"
$Files = get-childitem $Folder
$DeletedCount = 0
foreach ( $File in $Files ){
$MatchName = "$($File.BaseName)$($SuffixForDuplicate)$($File.Extension)"
$Match = $Files | Where-Object { $_.Name -eq $MatchName -and $_.Length -eq $File.Length }
if ( $Match.count -gt 0 ){
#Duplicate found!
write-host "Deleting $($Match.FullName)"
Remove-Item $Match.FullName -Force
...<Too long, click to read the rest> |
Category: Scripts 🠪 Powershell Misc Snippets | May 25, 2022 | ### Text to Speech
$Path = "$env:temp\file.wav"
Add-Type -AssemblyName System.Speech
$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synthesizer.SetOutputToWaveFile($Path)
$synthesizer.Speak('This is a recording.')
$synthesizer.Speak('Adding more to it')
$synthesizer.SetOutputToDefaultAudioDevice()
# Play back the recorded file
Invoke-Item $Path
### View properties of an object
Get-Process *note* | ConvertTo-Json | Out-File $env:APPDATA\GM.json ; $IE=new-objec...<Too long, click to read the rest> |
Category: Scripts 🠪 Powershell My Powershell scripts | May 24, 2022 | This lists some powershell scripts I have created which may be of interest to others.
To run a powershell script automatically using Task Scheduler, set the program to [ powershell.exe ] and the Add Arguments field to [ -File "PathToScript.ps1" ].
Link to more info on setting it.
To run a powershell script and hide the powershell window, use this:
PowerShell.exe -windowst...<Too long, click to read the rest> |
Category: Scripts 🠪 Powershell Sigcheck | May 25, 2022 | This doesn't actually use Powershell YET...
C:\Tools\SysinternalsSuite\sigcheck.exe -accepteula -e -s -vt -vs -u C:\ > C:\Tools\check.txt
keywords: Sysinternals, Signature, Check, sigcheck.exe, digital signatures |
Category: Scripts 🠪 Powershell Swap default printers using Powershell Script | May 22, 2022 | $Printers = Get-CimInstance -Class Win32_Printer
$DefaultPrinter = ""
$Printer1 = "RICOH MP C6004"
$Printer2 = "HP LaserJet 600"
foreach ( $Printer in $Printers ){
if ( $Printer.Default ){ $DefaultPrinter = $Printer.Name }
}
write-Host "Old Default printer: $($DefaultPrinter)"
if ( $DefaultPrinter -match $Printer1 ){
$NewPrinter = $Printer2
}else{
$NewPrinter = $Printer1
}
foreach ( $Printer in $Printers ){
if ( $Printer.Name -match $NewPrinter ){
Invoke-CimMethod -InputObject $Printer -M...<Too long, click to read the rest> |
Category: Scripts 🠪 Powershell Sysmon | May 25, 2022 | https://gist.github.com/psrdrgz/f87e73c4a89c4968f4ac67bf99267cc4
Sysmon is a SysInternals tool from Microsoft which allows logging of things
the computer does to the Event Log. It includes things like file
writes/creates/reads, network access, process start/stop, etc.
You can find it in the Event Viewer under:
Applications and Services\Microsoft\Windows\Sysmon\Operational
Here are some powershell commands to parse out useful information:
Get all Sysmon events, this will take a few minutes, do...<Too long, click to read the rest> |
|