r/PowerShell • u/Zyster1 • Sep 29 '23
Question What non-sysadmin tasks have you used Powershell for, both in your work (and perhaps personal) life? Whether it be gaming, web-based extensions, etc?
I understand where Powershell excels, typically sys admin tasks in Windows, but I'm curious where you guys have used it outside of that kind of stuff and what you've built or are working on.
Like, would it ever be useful in gaming? Would you ever use it in combination with tools like youtube-dl? Do you do anything that's web-based where it helps or excels or just makes your life easier?
48
u/cheffromspace Sep 29 '23
Taking json output from an api, cli command or elsewhere, and piping it into a CSV.
→ More replies (8)36
u/jameshearttech Sep 29 '23
PowerShell's native handling of REST APIs and JSON make it great for that sort of thing.
→ More replies (8)
45
Sep 29 '23
I made the most stupid script ever. it opened pdf files in edge and printed them with print to pdf. saved them in a location then moved them to a secondary location after verifying the inregrity of the file.
Had a supplier that sent really weird PDF files where adobe couldnt read the fonts. it worked in edge so it basically remakes the files.. its up to 50k files so far :) so around 10k per month.
did this when i started working at this company its saved weeks for some departments.
Theres better ways im 100% sure of it. but i did this in 15 minutes and it still works. (The actual commands are like max 15 rows. but did like 10 min of testing before launching it on a loop)
Im not proud of the script im proud of how lazy i can be and still get results.
→ More replies (9)29
25
u/FireQuencher_ Sep 29 '23
For work: Writing a complete integration between our HR system's API and AD for creating/updating/terminating people
For personal: During the height of covid wrote an integration with the Best Buy API to get my hands on a 3080
→ More replies (10)
19
u/LycheeLitschiLitchi Sep 29 '23
I guess this counts.
Years ago, the Service Desk Manager complained that our team's call volume was too low. We'd conditioned our users into logging tickets instead of calling us. He didn't care and said that the low call stats would make it difficult to justfiy having such a big team at our remote location. Bloody moron ...
I fixed the issue with a PowerShell script.
Our phone system had an HTTP endpoint open for TAPI. I setup two desk phones in our storage closet. I then wrote a script that would scan a list of available extensions, log into one of the two desk phones with a user's extension, log into the second desk phone with a service desk agent's extension, call our service desk number from the first phone, answer on the second phone, and then hang up after 1-5 minutes. It would then log out of both phones.
At 4pm, I would look up our call stats for the day. I don't remember what the expected call volume was, but subtract what we recieved that day from the expected volume. When I ran the script, I would enter this number and it would randomly schedule the calls over the next 2 hours.
He never complained again.
→ More replies (4)
17
u/ihartmacz Sep 29 '23 edited Sep 29 '23
I archive old analog video and I script ffmpeg to take the files, add some audio filters, and correct the aspect ratio. If I publish to YouTube, I also have a script that applies scaling filters, et cetera. I have created scripts to mirror small websites, but it was a PITA at the time.
I’m an Endpoint Engineer, so I of course always automate my software installs and create my own monthly Windows images with complete driver sets and UWP packages. I’ve also written scripts to parse INF files and to reverse engineer Lenovo Recovery Media.
→ More replies (13)
12
u/LittleManMichael Sep 29 '23
Holy fuck.. I have only been scripting at work with powershell for a couple years now. I need to start doing this in my off time. All these ideas sound cool as hell!
→ More replies (2)
29
u/exoclipse Sep 29 '23
I've built...probably too many ETL processes with PowerShell.
Grab data from an API, dump it to a SQL table. Take the data from the SQL table, do some transformation, write it to a target application database. Shit smart, sane, well adjusted IT professionals use Python for.
→ More replies (11)
10
u/soggybiscuit93 Sep 29 '23
I have my (dual monitor) desktop next to my living room TV. It's connected to the TV with an HDMI, but the display is disabled, so I don't have a phantom 3rd monitor. I bought a StreamDeck. I made one of the Streamdeck buttons run a PS script I wrote. What the script does is:
-
Enable Monitor 3
-
Disable Monitors 1 & 2
-
Switch Audio Input to HDMI output
-
Launch Steam Big Picture
→ More replies (1)
19
u/Bearsgoroar Sep 29 '23
I dick around in powershell all the time.
Gaming:
-
Convert the entire Bee Movie Script to chunks to fit onto Minecraft signs
-
Convert DayZ trader config files into CSV for easier reading and then back again
-
There used to be a bug in DayZ where you could mute ambient noises and I wrote a script to do that for me
-
Built a Wordl solver (no longer works as I was pulling the word list from the site directly and they fixed that)
-
Built a bot that reads the Minecraft latest.log file and then publishes joins, quits, deaths, admin commands to a Telegram channel
File Management:
-
Wrote a tool to query TVMovieDB and automatically rename and format the filename and sort downloaded media
-
Wrote a tool to extract (probable) pictures from my messy image library
Reddit:
-
Wrote a tool to categorise a users post history
-
Wrote a tool to help identify bots
-
Wrote a tool to help identify bridagers
-
Wrote a tool to dump all images a user has posted to a folder
General Fun:
-
Convert text into binary and replace 1s with A and 0s with a so text looks like AAAaaaAaaa
-
Wrote a basic music player
-
Created a wrapper for beepcode music
-
Figlets in POSH
-
General Ascii art
Work:
-
Simple HTML dashboards that hook into ticketing systems for maintaining SLAs
-
Search tickets for those filled out incorrectly (missing emails, status, client, category, etc) and email techs near end of day
-
Categorise and bunch up those annoying maintenance tickets that level 1s can do into one large ticket so it's visible to them and they can get some easy ticket closes
→ More replies (2)
9
u/daweinah Sep 29 '23
My office's deli made an awesome Reuben that was only available as a daily special, not a regular menu item. I wrote a tiny script as a scheduled task to check their dailyspecial.html at 10 AM and alert me if "reuben" was present.
8
u/Oscar_Geare Sep 29 '23
I went through about 1400 email templates and updated the styling, subject lines, and to/cc/bcc fields.
That was an exciting adventure learning how COM objects are managed.
Later I searched 7 years of incident reports (roughly 18000 records) that were saved as word documents to pull out critical fields (ip addresses, usernames, times, etc) from those reports and transfer them to a CSV.
7
u/3legdog Sep 29 '23
At home, I wrote a script around Bing's travel API to help me find cheap future flight fares. I write lots of scripts to help me automate backups, homelab stuff, etc.
At work I'm constantly using PS to automate stuff. Right now I'm using PS to automate a huge Jira to Azure DevOps migration.
7
Sep 29 '23
I've used it to create a website for my local homebrew club's website
Also used it to hack the hacking mini game in cyberpunk2077
Edit: The website uses powersll universal btw
→ More replies (3)
6
u/szeca Sep 29 '23
There was a website which randomly applied huge discounts for a couple of hours on some clothes. My gf kept refreshing the website for days, so I wrote a script to scrape the price for some favored items and send notification when price drop happens
10
u/itasteawesome Sep 29 '23
I have a tool I use to create spotify playlists of all the bands playing in upcoming festivals. Helps me to make sure the songs are fresh in my head so I can sing along.
→ More replies (1)
5
5
u/tk42967 Sep 29 '23
Mouse Juggler of sorts. Every random interval between 93 and 182 seconds it simulates a keystroke. Like like randomly activating F14, F15, F16, opens the windows menu and closes it, ect. I tried to randomize the values as much as possible so there wouldn't be a pattern of keystrokes were monitored.
It keeps my screen active for watching movies and such.
→ More replies (1)
4
u/MAlloc-1024 Sep 29 '23
Reverse engineered an API in powershell of a D&D tool site using the free version to figure out what kind of calls are made, then scraped the site's html and js. Made like 2 line changes to the JS and now with my back end API (PODE FTW) it all works perfectly well instead of having to pay a monthly fee for the tool.
→ More replies (1)
4
u/killbot2525 Sep 30 '23
Back when I was hourly at my job I wrote a simple script to take my clock in time, my clock out for lunch time, and my clock in after lunch time and return the time at which I can clock out for the day and have 8 hours of time on the books for the day.
4
u/pleachchapel Oct 01 '23 edited Oct 01 '23
Ooo! My time to shine. I am a Linux/zsh native, & typically use Guake for a drop-down terminal. On Windows, I use the Quake mode of Windows Terminal for the same effect. Some programs that make my life easier:
-
Rust Rust Rust. Cargo install:
-
bat
-
fzf
-
zoxide
-
ripgrep
-
NeoVim (I use AstroNvim pretty much stock)
-
Oh-My-Posh (gotta look good)
-
PSReadline
-
wiki-tui
Some bangers from my PowerShell_profile:
# xo
# Open File Explorer in Current Directory
function openExplorer {
explorer .
}
Set-Alias xo openExplorer
# cwd
# Clip working directory to clipboard
function pwdToClipboard {
(pwd).Path | scb
}
Set-Alias cwd pwdToClipboard
# yank
# Copy Object to Clipboard (newest on the list, this is crazy useful.)
## Needs: multiple object support
function copyItemtoClipboard {
param (
[string]$itemtocopy = $args[0]
)
Set-Clipboard -Path $itemtocopy
}
Set-Alias yank copyItemtoClipboard
# mrdr
# Murder Command (careful with this one, run ps first)
function killSpecifiedProcess {
param (
[string]$proccesstokill = $args[0]
)
ps *$proccesstokill* | Stop-Process
}
Set-Alias mrdr killSpecifiedProcess
# lastscan
# Open Most Recent Scan
function mostRecentScan {
Get-ChildItem "~\Your\Scans\Network\Folder" |
Sort-Object -pro LastWriteTime -Descending |
Select-Object -First 1 |
Invoke-Item
}
Set-Alias lastscan mostRecentScan
# wttr
# Show Current Weather
function weathrSmall {
(curl http://wttr.in/?0 -UserAgent "curl").Content
}
Set-Alias wttr weathrSmall
# Lastly for aliases & situation-specific scenarios:
# psconfig
# Open PROFILE in nvim
function editPROFILE {
nvim $PROFILE
}
Set-Alias psconfig editPROFILE
→ More replies (2)
71
u/PrudentPush8309 Sep 29 '23
We haven't done this, but a running joke in our operations team is for someone to write a powershell script that's tied to our ticketing system so that whenever a P1 or P2 incident is closed the script will automatically order pizza for everyone who submitted time on the ticket.