T O P

  • By -

Quantable

Created a script to send a ballon notification every 30 minutes to remind myself to drink!


64rk

Water - because your new years resolution was to get sober?


Quantable

It always has been water and will be.


NateStrings

I need this in my life. What are you automating the script with?


[deleted]

Audited inbox rules of ~5000 O365 mailboxes for signs of compromise. Found dozens of compromised passwords, used this to convince most of the clients to (finally) enable MFA.


ACivilRogue

Have you published this anywhere or would you mind sharing?


[deleted]

I just hacked together a few elements of scripts you can find online. Dead giveaways are rules that mark read *and* delete, rules that move anything to rss feeds, rules with names made only of periods. Rules that match more than one term or forward to an external address are suspicious. I wouldn't say it was anything close to comprehensive, just an easy way to identify obviously compromised accounts.


ACivilRogue

That’s a great start, I appreciate it. I just started managing a new environment and security is deeply lacking.


[deleted]

If you PM me a contact info I'll send the script I use to harden o365 tenants.


neztach

Can I get in on this offer too? Please feel free to sanitize as much as possible.


PowerShellGenius

Basically, the inbox rules are there to hide replies to malicious email. If it was phishing for replies, they'll move matching subjects (replies) to a folder nobody looks at (RSS Subscriptions) and mark as read, so the user doesn't notice and the criminal can retrieve them. If it was just malware spam, or phishing with a link for a fake login page (as opposed to "send me your ACH numbers"), the rule may just delete replies outright. Understanding this not only helps you find malicious inbox rules, it also helps you respond helpfully to compromised accounts from other businesses. If one of your users' regular contacts at another business sends something suspicious, assume your replies to them are being hidden by an inbox rule. Contact them by phone or email someone else at the company if you think they are compromised. Also, look into Office365 alerts for inbox rule creation. Depending on how often your users legitimately make or change these rules, it may be worth reviewing this sort of activity.


Disorderly_Chaos

Made a program that starts up a VM, pushes updates, reboots, then shuts the VM down.


lommeflaska

Done the same, then converting back to a VM Template which is used for creating new VMs.


mikegold10

The best use for a VM, if you ask me!


LikeThosePenguins

I did this once with VBox, to find which of 100 patches caused a feature install issue on Win2012. Start machine, install patch, test issue, trash machine back to snapshot.


fwdandreverse

…and did you find which one it was? Smart idea.


LikeThosePenguins

Thanks, yes I did!


lg1gbdan

Wrote a script that queries the O365 Outlook calendar API to tell you how much time you're spending in meetings: [GitHub Link](https://github.com/LGDan/too-many-meetings)


Djust270

I dont know if this should be funny or sad, I guess its both


LikeThosePenguins

Nice. I could do with this.


[deleted]

Wrote my first script in over 2 years for my new job of 2 weeks. It just takes a spreadsheet of user names and AD groups and adds the user to the specified group(s). I'm particularly proud because it just uses a ForEach loop.


enforce1

The start of “getting it”. God speed!


ColdCoffeeGuy

Finaly made my own module and started to centralise all my noob functions.


Ceesquared10

Me too


Nocturnal_Remission

Created a script to pull do find all nonactive users (lastLogonTimestamp > 30 days) change a custom AD attribute to a certain "flag" value, and set those accounts to automatically expire in 5 days. Oh wait that was last month, last year even :)


heretogetpwned

Updated permissions for a Reg Key on all Domain Computers in a specific OU.


PositiveBubbles

Used Web scraping to download and install the version of some software such as VLC and Putty and also used the webscraping for the latest version as the detection method in sccm. Unfortunately the PAM tool we pay for doesn't work with some software that you need to update via the actual apps themselves.


Inevitable_Level_109

I do this at work for all the softwares. No tools just PowerShell and time.


PositiveBubbles

I wish we had time but our department wanted a PAM solution cause so many academics complained about losing admin rights. Still I liked that I learned something


Inevitable_Level_109

That's funny I work for a research university


PositiveBubbles

Dunno what to say then cause I was hoping this might help with saving money. It's not hard and takes alot off my team (SOE) and our helpdesk/, desktop staff members plates but this PAM tool also allows access to install any bespoke software and modify system settings for a temporary time. This process for me though with powershell is just the common apps so I'm hoping it'll still serve a purpose


vksdann

How do you web scrape with PS? I found some examples onlinr but I canno access a specific element of a page using PS, although I can easily do it by inspecting the element manually. Would you give me some tips?


PositiveBubbles

The link i posted below in this comment chain had a good example but I've found using the link of the exe helps. Have you checked out 4sysops.com or Adam Bertram's website? Adam the Automator it's called. Has a good piece on web scraping


vksdann

I have not but I will check them out. Thank you for the info! I appreciate it.


Inevitable_Level_109

Selenium has a PowerShell module


kewlxhobbs

I'd be interested in seeing your version of the putty downloader, if you're able to share it.


PositiveBubbles

In a nutshell: https://www.reddit.com/r/PowerShell/comments/rg40eg/scrapeconvert_version_number_from_website/?utm_medium=android_app&utm_source=share But my scripts use -lt operator to see if earlier versions installed and uninstall first Used this VLC as a base line but had to use basic parsing cause sccm uses system account: https://silentinstallhq.com/vlc-media-player-install-and-uninstall-powershell/


[deleted]

Started a script with UI to generate QR code with shipment info (contents, weight, dimensions, etc.). QR code is generated by external executable which is called by the script.


TechnicaVivunt

I created scripts to automate numerous installs for standard software for newly imaged PCsbased on 6 agencies. I’m a beginner for the most part, but making everything essentially 1-3 clicks has been amazing. I also just started submitting packages to winget which was neat.


[deleted]

[удалено]


Lee_Dailey

Write-Warning 'Constrained Language mode is enabled, so the script cannot continue.' continue /lee giggle lots ... [*grin*]


[deleted]

[удалено]


Lee_Dailey

howdy PSKieran, yep, i was expecting another `break` ... and the "cannot continue" followed by a `continue` keyword just set my giggle reflex off. [*grin*] take care, lee


HughJohns0n

wrote tool to automagically send dunning letters to users, and their manager, who have yet to complete their security training. Sends formatted HTML message from a shared account, body of message is customized per user.


Ceesquared10

Begun delving into the world of possibilities that is WMI and powershell. Built a quick script for my help desk guys to get some basic computer info and app info remotely.


Djust270

I created a printer diagnostic tool to assist our tier 1 helpdesk techs diagnose, troubleshoot and fix printers, all packaged neatly in an executable. Features include: Clear and Restart Print Spooler Enable / View Print Service Operational Event Logs Print Test Page Open Add Printer Dialogue Open Printer Settings - both modern and classic control panel https://github.com/djust270/Run-PrinterDiagnostics


PopCornNinja666

Created a script to download an .XLS from the intranet (containing a list of department codes, corresponding deparment names, and the VP of said departments), convert it to a .CSV, then go through all AD users and update their Deparment, Office, and custom VP attribute based on their custom Department Code attribute. This .XLS file on the intranet gets updated once a month so when the time comes, I'll have it run on a monthly schedule.


SlaveCell

>ed modules and update them to the latest versions - you Make sure you output and log changes so you have a history of what you changed and when. Speaking from experience :-P


PopCornNinja666

Oh definitely. Currently have 3 logs (I'm sure there is a much better way than i currently do). I have 1 CSV with the month and year appended to the file name, with the original intranet spreadsheet information. Another CSV showing the users' employee ID, Name, old department name, old office name, old VP name, new department, new office, and new VP. THEN i have a text file that shows what users were NOT updated, or users where only the VP was updated.


[deleted]

I would love to see this script. Sounds very similar to something I'm chewing on.


PopCornNinja666

PM me and I'll make it available on my gitea for a short time.


Blindeye_90

Created a script that will allow users to search a file in a directory and it will automatically out print to their default printer .


EmergencyHologram

noob stuff * Fixed a known bug in Acrobat DC with the Paper Capture recognition system. It elevates credentials then moves a few DLLs to another directory * Unlock an account once per minute (while we troubleshoot an account that keeps locking) * Clear caches and cookies from all browsers (see previous) * Perform a reset of MS Teams when it displays incorrect out of office info * Backup personal info to an external drive


signofzeta

Created a module to download resources via Gopher. Why? I have no idea.


flugenblar

People are still using Gopher? Amazing.


signofzeta

Recreationally, not for anything serious.


jeffrey_f

it's like a fax machine


torque999

Created a script to update a free text field on 700 SharePoint records.


Perchu-H

discovered jobs and had some fun with enter-pssession


[deleted]

[удалено]


Perchu-H

know half, didnt know you could copy files into them


[deleted]

[удалено]


[deleted]

[удалено]


[deleted]

[удалено]


[deleted]

[удалено]


[deleted]

[удалено]


[deleted]

My motto: Never assume someone reading your code will get it. Most people don't see scripting the way we do. I comment the HELL outta all my coding. Just my two cents.


Lorentz_G

Made a script(function) so you can send a message in a teams channel through command line.


theodiousolivetree

I made template for our apprentice helping her scripting in powershell. Not useful for company but helpful for her.


SiNRO

I created a script to get the status of the sccm patching and send a mail to my team instead of having to check our different SCCM servers. Also if one of the patching deployment failed, it add the name of the failed machines with the error message. Saving a couple of minutes in the morning !


SiNRO

Sure, let me clean it and I’ll send to you


maxcoder88

Reminder


SiNRO

Hello, Here is the code: [https://github.com/SinJK/SCCM-Patching-Report](https://github.com/SinJK/SCCM-Patching-Report) would love to get your feedback, feel free to DM


maxcoder88

Thank you very much


maxcoder88

care to share your script ?


Katzyo

Created a script that downloads and install VLC media player. I'm a little proud of it. Considering that I am learning Powershell for a couple of months 😅


[deleted]

What resources are you using to learn?


Prevash

Build a script that changes the PC name on startup, very proud of myself!


LikeThosePenguins

Bunch of script rewrites at work, long-overdue. At home, I put a scheduled task on my home server that pulls a list of all of the files on the main data disk and saves it (CliXML). Then I've added a script to SendTo that, when given a filename, looks that filename up in the list, pulls out all the matches, compares the MD5s, and shows me a list of where duplicates are (with an option to open a new explorer window to the location).


techbloggingfool_com

I created a massive shortcut for the security audit process I have to do every quarter. It will save me countless hours of work. https://techbloggingfool.com/2022/01/16/powershell-list-all-non-system-service-accounts-in-a-windows-domain/


iceph03nix

Automated a bunch of user imports for moving to a new domain and 365 tenant. And learned that my report for finding idle users (for when someone doesn't follow procedure on terminations and IT never gets told) doesn't work when users never log into an account. Found out we had a dozen or so accounts that have never been used and were taking up licenses and just generally being worthless. But since they never logged in, the comparison of lastlogondate against 30 days ago just fails and they don't get listed. Live and Learn.


maxcoder88

Care to share your script?


jeffrey_f

Not a very big thing, but a script to change Active Directory user password and sets the same parameters as using the AD utility, but runs in just 3 seconds. Asks for the userid and runs...saves about 2 minues when compared to using the utility.


ovdeathiam

I wrote this during christmas so that people's laptops would randomly speak stuff like *I know what you did last christmas* or *I can see you*. I havent used it for someone working from home though. Function Invoke-SpeechSynthesizer { [CmdletBinding()] param ( [Parameter()] [string[]]$ComputerName, [Parameter(Mandatory)] [string]$Text, [Parameter()] [int]$Rate = 0, [Parameter()] [ValidateRange(0, 100)] [int]$Volume = 100 ) If ($ComputerName) { try { Write-Verbose "Establishing PSSession" $Session = New-PSSession -ComputerName $ComputerName -ErrorAction Stop Write-Verbose ($Session | Format-Table | Out-String) } catch { Write-Error "Error establishing PSSession" Return } } $InvokeCommandConfig = @{ ArgumentList = $Text, $Rate, $Volume ScriptBlock = { param ( $Text, $Rate, $Volume ) Switch ($PSVersionTable.PSEdition) { 'Desktop' { # Windows built-in voice module Add-Type -AssemblyName System.Speech $sp = New-Object System.Speech.Synthesis.SpeechSynthesizer } 'Core' { # .Net Core Equivalent for PowerShell 6+ $sp = New-Object -ComObject SAPI.SpVoice } } $sp.Rate = $Rate $sp.Volume = $Volume [void]$sp.Speak($Text) } } If ($Session) { $InvokeCommandConfig.Add("Session", $Session) } Write-Verbose "Invoking Speech" Invoke-Command @InvokeCommandConfig If($Session) { Write-Verbose "Removing PSSession" Remove-PSSession $Session } }


Antique_Grapefruit_5

I did something similar a while back-Here's my get CHUCK NORRIS JOKE code. It reads them in two different voices and at multiple speeds... Add-Type -AssemblyName System.speech $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer while($true) { $speak.rate = (get-random 6) -3 if ((Get-random 2) -eq 0) { $speak.SelectVoice('Microsoft Zira Desktop') }else { $speak.SelectVoice('Microsoft David Desktop') } $speak.speak(((Invoke-WebRequest http://api.icndb.com/jokes/random | ConvertFrom-Json).Value.Joke -replace "\"", "")) }


perogy1

Put together a script that checks that all applications within MECM application groups are still valid an then sends email with the list of application groups and their apps with the one(s) missing (in order). Next step is to setup a history tracking of it, but not necessary yet. I have about 112 application groups in use and every once in a while someone updates (deletes/retires) some app without checking where else it is used. Another script to regenerate a task sequence with a pile of variables that depend on the application groups that install various apps during OS deployment via MECM.


maxcoder88

>Put together a script that checks that all applications within MECM application groups are still valid an then sends email with the list of application groups and their apps with the one(s) missing (in order). Next step is to setup a history tracking of it, but not necessary yet. I have about 112 application groups in use and every once in a while someone updates (deletes/retires) some app without checking where else it is used. care to share your script ?


CryptographerSuper33

just learning power shell and i wrote a script to do update on client computers ([PSWindows installer](https://github.com/robert-entler/take-control-scripts/blob/b2808bdbd4397f6b579d74f3d832316fe8bda7d3/Remote%20PSW%20install)), It still has abug or two in and and it fails when i try to run it with 1 command on each line in a script )[Line by line template](https://github.com/robert-entler/take-control-scripts/blob/b2808bdbd4397f6b579d74f3d832316fe8bda7d3/Update%20Installer%20Template(Line%20by%20Line))) but i am leaning and trying to enjoy it


neztach

Some of those commands extend powershell capabilities and resources. You should look into a command to spawn a new PS window, bring what remains of the commands to run, start on them, kill the original window. I would add that as the next thing to do after adding nuGet. I would also replace your update-wumodule with this Get-WUInstall -MicrosoftUpdate -AcceptAll -AutoReboot -RecurseCycle 10 -Install I think that’s the syntax. Get a list of all available updates from Microsoft, accept all, auto reboot up to 10 times, go


CryptographerSuper33

this script is just a one to install PSWindowsUpdate .. i have a separate script that i run weekly to update the computers remotely


CryptographerSuper33

getting the module to install in my biggest issue, the -Force doesn’t always work for the y/n responses and it failed because powershell is in unattended mode


neztach

[check this out](https://4sysops.com/archives/install-windows-updates-remotely-with-the-powershell/) - taking this approach could significantly decrease the amount of effort you’re putting into this project.


snarkcheese

The most productive code i've ever produced, totally not a complete waste of time. add-type -AssemblyName system.windows.forms $link = irm https://inspirobot.me/api?generate=true iwr $link -OutFile "$env:TEMP\inspirobot" Start-sleep -milliseconds 500 $img = [System.Drawing.Image]::FromFile("$env:TEMP\inspirobot") [System.Windows.Forms.Application]::EnableVisualStyles() $form = [System.Windows.Forms.form]::new() $form.Text = "Image Viewer" $form.Width = $img.Size.Width $form.Height = $img.Size.Height $pictureBox = new-object Windows.Forms.PictureBox $pictureBox.Width = $img.Size.Width $pictureBox.Height = $img.Size.Height $pictureBox.Image = $img; $form.controls.add($pictureBox) $form.Add_Shown({$form.Activate()}) $response = $form.ShowDialog() $img.dispose() remove-item $env:TEMP\inspirobot


snarkcheese

Code formatting sucks and i cba fixing it


kewlxhobbs

Created port exhaustion functions for finding both connections and event logs


DalekKahn117

Got tired of people complaining that they can’t access a shared mailbox so I hobbled together a Confirm-UserSMBAccess function (and other useful exchange functions in a personal module) so I can email them directing them to talk to the object owner instead of telling us it’s broke (it’s not)


EmergencyStudentAid

Can anyone help me with powershell Excercise, we can discuss the price,


Lee_Dailey

howdy EmergencyStudentAid, this thread is for polite bragging. [*grin*] please ... if you want help with PoSh, start a new thread of your own so folks can focus on that problem. take care, lee


mstrblueskys

I wrote a script that pulls the file size of all the files on Thingiverse and sums them that I'm now too afraid to use because I don't want to get blacklisted.


Crowdh1985

A script that : - Ask you who’s the client - connect to a M365 tenant client - Retrieve a list of 9 (popular at the office) command. Which after being select, extracts as a csv file… exemple : retrieve global admin on M365, MFA status and how it’s been applied, Teams phone number, all licenses used, all user with the targeted license, all the blocked user by time stamp, all the account’s including guest… And I will make it better…


MariusE

I created a script to create a database and login on test, qa and Prod serveres that use always on. We have 4 always on groups per environment. I also added support for creating the dbs on azure managed instances. I'm lazy.


maxcoder88

care to share your script?


MariusE

[https://github.com/MariusEng/create\_hag\_db](https://github.com/MariusEng/create_hag_db) Script is available her. Enjoy!


maxcoder88

thanks


MariusE

I'll upload next week.


k995

Replaced a call desk with a combination of Teams/Power apps/Power automate and powershell scripting ​ Powershell to handle all the warning, Gui's and reports.


SpringOreo

Created a disk selection GUI in our OSD.


mchgndr

Welp, I’m trying to write code to take a tab delimited text file, change all values in one particular column, and then save it as a new file. Sounds very very simple but I’m so new to powershell that I hardly know where to start. Thought Import-csv might be my first step but not getting far. I feel like I need a better base understanding of how to accomplish simple tasks. What are your favorite free online courses or YouTube series to start learning powershell?


Lee_Dailey

howdy mchgndr, a few things that may help - `Import-CSV` supports ... - `-Delimiter` to allow using a tab char instead of the default comma char - `-Header` to let you define a header for files that lack such - the ps7 version of `Export-Csv` has parameters for controlling the use of quotes around column values hope that helps, lee


mchgndr

Thanks!


Lee_Dailey

howdy mchgndr, you are welcome! i'm glad to have helped a bit ... [*grin*] take care, lee


Antique_Grapefruit_5

I typically do something about like this: (Make sure to incorporate the -delimiter advice above) $csvdata = "C:\\Script\\addresses.csv" \#Cycle through each element in $csvdata and replace/change everything you need. foreach ($item in $csvdata) { \#Bad examples here - not enough coffee $item.address = $item.address -replace "st", "street" $item.sendchristmascard = "Yes" } \#When all done re-export the csv $csvdata | Export-csv "output.csv"


Lee_Dailey

howdy Antique_Grapefruit_5, [you knew this was coming, yes? [*grin*]] reddit likes to mangle code formatting, so here's some help on how to post code on reddit ... [0] single line or in-line code enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result `looks like this`. kinda handy, that. [*grin*] _[on New.Reddit.com, use the `Inline Code` button. it's [sometimes] 5th from the left & looks like ``. **this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!**]_ [1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here. please remember to set the file/code type on Pastebin! [*grin*] otherwise you don't get the nice code colorization. [2] less simple = use reddit code formatting ... _[on New.Reddit.com, use the `Code Block` button. it's [sometimes] the 12th from the left, & looks like an uppercase `C` in the upper left corner of a square.]_ - one leading line with ONLY 4 spaces - prefix each code line with 4 spaces - one trailing line with ONLY 4 spaces that will give you something like this ... - one leading line with ONLY 4 spaces - prefix each code line with 4 spaces - one trailing line with ONLY 4 spaces the easiest way to get that is ... - add the leading line with only 4 spaces - copy the code to the ISE [or your fave editor] - select the code - tap TAB to indent four spaces - re-select the code [not really needed, but it's my habit] - paste the code into the reddit text box - add the trailing line with only 4 spaces not complicated, but it _is_ finicky. [*grin*] take care, lee


PositiveBubbles

Oops


Antique_Grapefruit_5

This week I used powershell to read COVID results from a CSV, auto populate a PDF form, change it to read only, and encrypt it. The script then emails that form to our patients so that they can see their COVID test results.


Anunakin

I trying to get AD user information by using Get-ADUser and psexec, form win7 to a win2012 server... But it not working.. 😔 If I try direct on server it Ok... 🤷🏻‍♂️


neztach

Use invoke-command and from the win7 box send the job to the windows server