PowerShell

Just another Tech site

MECM: clean uninstall

Trying to clean up MECM clients that have failed to get updated or have corrupt installs   <# MECM Full Removal Script – Graceful uninstall (if possible) – Forced cleanup of all MECM components – Logging to file – Summary report at end #> # ============================ # Logging + Summary Functions # ============================ $Global:LogFile =…
Read more

MECM: Client re-install

Re-installing the MECM client   <# MECM Reinstall Script – Installs MECM client cleanly after full removal – Logging + summary report – Validates installation success #> # ============================ # Logging + Summary Functions # ============================ $Global:LogFile = “C:\Windows\Temp\SCCM_Reinstall_$(Get-Date -Format ‘yyyyMMdd_HHmmss’).log” $Global:Summary = @() function Write-Log { param( [string]$Message, [string]$Level = “INFO” ) $timestamp =…
Read more

MECM: Client check

Updating to a new client and want to check to make sure the client is working correctly.   <# SCCM Health Check Script – Validates SCCM client health – Logging + summary report – Designed to pair with removal/reinstall scripts #> # ============================ # Logging + Summary Functions # ============================ $Global:LogFile = “C:\Windows\Temp\SCCM_HealthCheck_$(Get-Date -Format ‘yyyyMMdd_HHmmss’).log”…
Read more

MECM: uninstall MECM client from a list using PowerShell

Trying to cleanly clean up MECM client installation # Path to list of computers $ComputerList = Get-Content “C:\Scripts\Computers.txt” # Log file $LogFile = “C:\Scripts\SCCM_Removal_Log.txt” “=== SCCM/MECM Client Removal Log – $(Get-Date) ===” | Out-File $LogFile # Max concurrent jobs $MaxJobs = 20 # Script block for removal $RemoveSCCM = { param($ComputerName) try { Write-Host “[$ComputerName]…
Read more

PowerShell – RGB Color Table

RGB color table something to help with coding colors RGB color space RGB color space or RGB color system, constructs all the colors from the combination of the Red, Green and Blue colors. The red, green and blue use 8 bits each, which have integer values from 0 to 255. This makes 256*256*256=16777216 possible colors.…
Read more

PowerShell Script – Batman Download Tool

I was learning a new way to use Windows forms by building a download tool for common applications I was working on building a cool download tool for Google Chrome, Mozilla Firefox and 7-Zip   #region Variables $Script:FormWidth = 1080 $Script:FormHeight = 800 $Script:Formicon = “batman.ico” $Script:FormTitle = “Batman Download & Deploy Tool” $Script:FormVersion =…
Read more

PowerShell: Base64 compression to clipboard

Using the Base64 to embed logos into a Windows form and then compressing the image to reduce the footprint of the size of the code. Add-Type -AssemblyName System.IO.Compression $imagePath = “Location to file\firefoxlogosmall.png” $bytes = [System.IO.File]::ReadAllBytes($imagePath) $ms = New-Object System.IO.MemoryStream $gzip = New-Object System.IO.Compression.GZipStream($ms, [System.IO.Compression.CompressionMode]::Compress) $gzip.Write($bytes, 0, $bytes.Length) $gzip.Close() $base64 = [Convert]::ToBase64String($ms.ToArray()) Set-Clipboard -Value $base64…
Read more

PowerShell: Remove folders older than x amount of days

Trying to do a clean up of installation version folders for applications installed after x amount of days.  This will remove folders and files in subfolders older than 4 days  as scripted below.  Change the variables to help identify the folder locations.  Please run on a test system before using for production, just to make…
Read more

PowerShell: update to Embed Audio file

Trying to get that the data stream is on one line vs hundreds of lines. The change was in the Convert to Base64 block. I found that I needed to add some additional parameters: [Convert]::ToBase64String($encrypted, [Base64FormattingOptions]::None) This will output the data stream to a one line, and even if output to a text file, now…
Read more

PowerShell: Script to embed audio

Playing around with embedding an audio wave file into a Windows Form, that starts when started, loops and then stops when closed.  I wanted to see if that can be done with a little Batman audio clip. Here is the audio with the encrypted compressed audio file as short demo $key can be what you…
Read more

PowerShell: New Installation of Google Chrome

Worked on a new way to install Google Chrome To have and show with a progress bar with each step To do an uninstall process to remove and clean up folder Copy files to an install location Added logo built in Log file Remove Icon from desktop Install Script # Ensure script runs with admin…
Read more

PowerShell script to check on 503 error and sent to IT Support

PowerShell script to run a report in a table on a remote server to check web status is ok, if 503 error, highlight in yellow with a bold red font and send only if error via email to IT Support as html. <### Code Explanation: This PowerShell script is designed to monitor the status of…
Read more

PowerShell script that checks the status of a web server

Here’s a PowerShell script that checks the status of a web server by running a report, highlights any 503 errors in yellow with bold red font, and sends the results via email as an HTML table to IT Support. This script assumes you have the necessary permissions and configurations for email sending and server access.…
Read more

PowerShell Script to gather information from Remote server and email it.

Here is a PowerShell script that gathers CPU utilization, memory usage, disk space, and uptime information from a remote server, formats it into an HTML table, and sends it via email to IT Support. Make sure to run this script with appropriate permissions and update the placeholders with your specific details. # Define variables $RemoteServer…
Read more

PowerShell script for server information in an email report

PowerShell script that gathers server CPU and memory utilization, disk space, and uptime, generates a report, and sends it via email to IT Support. This script uses WMI and requires SMTP configuration for email functionality. # **Configuration Section** $SMTPServer = “smtp.yourdomain.com” # Replace with your SMTP server $SMTPPort = 587 # Replace with your SMTP…
Read more

PowerShell Download script ideas

These are just PowerShell Scripted ideas playing around with to understand the scripting process.  

Server Status Report

Server Status Report from PowerShell to HTML for CPU, Memory, IP Address, and Hard Drive information. # Define the input file containing server names (one per line) $ServerListFile = “D:\Lists\Servers.txt” # Text file containing server names (one per line) # Define the output HTML file $OutputHtmlFile = “C:\Logs\ServerStatusReporttbl.html” # Path to save the HTML report…
Read more

Powershell form close form after 30 minutes if no activity exists

To close a PowerShell form after 30 minutes of inactivity, you can use a timer to track user activity and close the form if no interaction occurs within the specified time. Below is an example script using Windows Forms: # Load Windows Forms assembly Add-Type -AssemblyName System.Windows.Forms # Create the form $form = New-Object System.Windows.Forms.Form…
Read more

BTT

New design for form tool, I call the Bat Tech Tool using PowerShell. File Zip Content  

RDP by selecting list of systems

I was looking for a way to select from a list of systems to RDP into and came up with a combo box inside of a form.  Simple form display               Add-Type -AssemblyName System.Windows.Forms # Create the form $form = New-Object System.Windows.Forms.Form $form.Text = “RDP Connection” $form.Size = New-Object…
Read more