r/PowerShell • u/blownart • Dec 29 '16
r/PowerShell • u/nickrod518 • Sep 20 '16
Script Sharing Never too busy to have fun... send cat facts to coworker's PC's using PowerShell
r/PowerShell • u/Prateeksingh1590 • Dec 21 '16
Powershell Cheat Sheet Compilation
Follow below link for some useful #Powershell & related technology Cheat sheets.
https://github.com/PrateekKumarSingh/CheatSheets
Or run the following command from your Powershell Console to download them.
(iwr "https://github.com/PrateekKumarSingh/CheatSheets").Links | ?{$_.title -Like "*Powershell*"} | %{iwr "http://github.com$($_.href)?raw=true" -OutFile $_.title -Verbose}
I've Dumped them in one location for my reference and thought it may be useful for others as well.
r/PowerShell • u/Rodion15 • Jun 06 '22
Question Is Powershell worth learning for an IT technician for small IT aims (very small companies)?
I wonder if Powershell would be useful for an IT Technician working for a company that fixes computers and issues with very small companies (max 20 staff or so) and home users...looks like it's intended for larger companies?
I'm learning Active Directory and windows server as it's sometimes used in these very small environments.
r/PowerShell • u/jevans_ • Aug 08 '20
Information Visual Studio Code - Useful Extensions
Hi all,
Here are some extensions for Visual Studio code I've either found myself or a friend\co-worker told me about, and why the extensions have been useful so far from a PowerShell perspective.
If you have any of your own that you reckon more people need to know about then please share :)
In no particular order
VSCode Icons: This extension will add icons to the side navigation bar not only for file types but based on folder names as well (e.g. src, doc, public/private, test etc). Even if the idea of having distinct icons for different folders doesn't appeal I'd at least consider it for having different coloured icons for .ps1, .psm1, and .psd1 files.
Better Comments: Colour-codes your comments based on what you place in the line. This can be incredibly useful for code where there are plenty of comments and you want to be able to distinguish properly between TODO's, questions, deprecated code, or anything else you may want to highlight. The examples given on the marketplace aren't in PowerShell but work all the same if you swap out '*' for '#'.
Live Share: If screen sharing is a bit of a hassle then Live Share might appeal a bit more. Think of it as a live Google doc, where you share not only the files you're working on but the PowerShell terminal (including session) as well.
Trailing Spaces: Trailing spaces aren't an issue in PowerShell of course, but if you're a neat freak like I sometimes am this is the equivalent of having a blacklight shone on a hotel room - once you see it you must clean
EditorConfig for VS Code: Overrides editor settings in VSCode with a (in my opinion) much more accessible and easier way to configure VSCode to do any low-level clean-up and maintain some standards in my code. Can be incredibly useful if you're working on code as a team and want an easy way to keep formatting consistent between team members.
Edit csv: Not specifically PowerShell related, but if you're importing\exporting csv's as part of your scripts this will save you the trouble of going between different programs.
Remote - SSH: Still dipping my toes in this one, but for someone who has recently decided to take up PS vers 6/7's offer of doing the open source penguin dance being able to store different SSH session configurations and connect directly via VS Code has been good. This is more for the fact that I want to be able to work on code meant for my Linux machines without having to connect via RDP. Side note: If anyone has any starting points they'd recommend for Linux I'd love to know as it'd save me a mountain of Googling.
Bonus
This one isn't an extension but good to know anyways if you use the Pester module. If you right-click on a Pester test in the side navigation bar you'll have the option to run or debug the test from there, kinda useful to know if you've been scrolling all the way to the top or pasting in the same command over and over like me :)
Hopefully these make the shell life a bit easier for you as it has for me.
r/PowerShell • u/bhreddy99 • Apr 24 '20
Question How good is "Learn PowerShell in a month of lunches " book?
Being a learner of PowerShell wanted to know all of your valuable opinions on this book before starting on this.
r/PowerShell • u/[deleted] • Mar 11 '19
How to Create Your Own PowerShell Dashboard for ESXi
r/PowerShell • u/MadBoyEvo • Feb 18 '19
PowerShell - Few tricks about HashTables and Arrays I wish I knew when I started
r/PowerShell • u/tsclapper • Jul 29 '21
What was I thinking?
Have you ever written a sweet piece of code that you were proud of? Have you ever looked at that code 5 years later and wondered what idiot wrote that shit code?
r/PowerShell • u/adbertram • Aug 26 '19
How to Build a PowerShell GUI for your Scripts
Hey guys, June Castillote just wrote a shiny new PowerShell blog post you may enjoy.
Summary: Learn how to build a PowerShell GUI with a little PowerShell and free Visual Studio in this step-by-step walkthrough.
r/PowerShell • u/Prateeksingh1590 • Nov 27 '17
Information Powershell Cheat sheet compilation
r/PowerShell • u/[deleted] • Dec 20 '19
The Ultimate Guide to Building REST APIs with PowerShell
r/PowerShell • u/TheLazyAdministrator • Feb 05 '19
PowerShell Function to Connect to All Office 365 Services With Support for MFA
r/PowerShell • u/mdgrs-mei • Apr 25 '23
Information Building your own Terminal Status Bar in PowerShell
I wrote a blog post about how I used the console title area as a status bar using a module that I published last month.
https://mdgrs.hashnode.dev/building-your-own-terminal-status-bar-in-powershell
The article should explain the concept of the module better than the README on the GitHub repository.
I hope you enjoy it. Thanks!
r/PowerShell • u/[deleted] • May 18 '22
Call REST APIs with Invoke-RestMethod in PowerShell
r/PowerShell • u/ThomasMaurerCH • Apr 23 '21
News Getting started and Learn PowerShell on MicrosoftLearn with 5 new modules!⚡🎓
r/PowerShell • u/rawrtherapy • Oct 25 '20
Misc I think PowerShell is easier than Python
The syntax in PowerShell uses common sense as opposed to other languages
Wanna send mail? Send-Mail Message Wanna get the date? -GetDate Wanna get something from a file? -GetContent
Not really sure what this post is about but after learning Python and having it he twisted in its syntax in some ways and then currently learning PowerShell because of work
I can tell you that PowerShell is so much easier to write code in and pick up
r/PowerShell • u/compwiz32 • Jun 07 '20
Information Iron Scripter: Learn PowerShell through code challenges
Hello PowerShell Peeps!
I've recently posted on PowerShell.org about the Iron Scripter competition and the individual code challenges that are available for everyone to try. I invite you to participate in the challenges and see how you do.
https://powershell.org/2020/06/iron-scripter-learn-powershell-through-code-challenges/
r/PowerShell • u/give_the_lemons_back • May 23 '15
Question Saw a sign today that said "$ale"...thought it was a variable for beer.
Do I have a problem?
r/PowerShell
•
u/Ros3ttaSt0ned
•
Dec 21 '25
Script Sharing A Christmas gift for /r/PowerShell!
You may remember me from such hits as the guy who wrote a 1000+ line script to keep your computer awake, or maybe the guy that made a PowerShell 7+ toast notification monstrosity by abusing the shit out of PowerShell's string interpolation, or maybe its lesser-known deep-cut sibling that lets it work remotely.
In the spirit of the holidays, today, I'm burdening you with another shitty tool that no one asked for, nor wanted: PSPhlebotomist, a Windows DLL injector written in C# and available as a PowerShell module! for PowerShell version 7+
You can install from PSGallery via:
Install-Module -Name PSPhlebotomistThis module will not work in Windows PowerShell 5.1. You MUST be using PowerShell version 7+. The README in the Github repo explains it further, but from a dependencies and "my sanity" standpoint, it's just not worth it to make it work in version 5.1, sorry. It was easier getting it to compile, load, import, and mostly function in Linux than it was trying to unravel the tangled dependency web necessary to make it work under PowerShell 5.1. Let that sink in.
After installing the module, you can start an injection flow via New-Injection with no parameters, which will start an interactive mode and prompt for the necessary details, but it's also 100% configurable/launchable via commandline parameters for zero interaction functionality and automation. I documented everything in the source code, but I actually forgot to write in-module help docs for it, so here's a list of its commandline parameters:
-Inject: This parameter takes an array of paths, with each element being a path to a DLL/PE image to inject. You can feed it just a single path as a string and it'll treat it as an array with one element, so just giving it a single path via a string is OK. If providing multiple files to inject, they will be injected in the exact order specified.
-PID: The PID of the target process which will receive the injection. This parameter is mutually exclusive with the -Name parameter and a terminating error will be thrown if you provide both.
-Name: The process name, i.e., the executable's name of the target process. This parameter is mutually exclusive with the -PID parameter and a terminating error will be thrown if you provide both. Using the -Name parameter also enables you to use the -Wait and -Timeout parameters. The extension is optional, e.g. notepad will work just as well as notepad.exe.
-Wait: This is a SwitchParameter which signals to the cmdlet that it should linger and monitor the Windows process table. When the target process launches and is detected, injection will immediately be attempted. If this parameter isn't specified, the cmdlet will attempt to inject your DLLs immediately after receiving enough information to do it.
-Timeout: This takes an integer and specifies how long the cmdlet should wait, in seconds, for the target process to launch. This is only valid when used in combination with -Wait and is ignored otherwise. The default value is platform-dependent and tied to the maximum value of an unsigned integer on your platform (x86/x64), which, for all practical purposes, is an indefinite/infinite amount of time.
-Admin: This is a SwitchParameter, and if specified, the cmdlet will attempt to elevate its privileges and relaunch PowerShell within an Administrator security context, reimport itself, and rerun your original command with the same commandline args. It prefers to use a sudo implementation to elevate privileges if it's available, like the official sudo implementation built in to Windows 11, or something like gsudo. It'll still work without it and fall back to using a normal process launch with a UAC prompt, but if you have sudo in your PATH, it will be used instead. If you're already running PowerShell under an Administrator security context, this parameter is ignored.
There's a pretty comprehensive README in the Github repo with examples and whatnot, but a couple quick examples would be:
Guided interactive mode
New-InjectionThis will launch an interactive mode where you're prompted for all the necessary information prior to attempting injection. Limited to injecting a single DLL.
Guided interactive mode as Admin
New-Injection -AdminThe same as the example above, but the cmdlet will relaunch PowerShell as an Administrator first, then proceed to interactive mode.
Via PID
New-Injection -PID 19298 -Inject "C:\SomePath\SomeImage.dll"This will attempt to inject the PE image at C:\SomePath\SomeImage.dll into the process with PID 19298. If there is no process with PID 19298, a terminating error will be thrown. If the image at C:\SomePath\SomeImage.dll is nonexistent, inaccessible, or not a valid PE file, a terminating error will be thrown.
Via Process Name
New-Injection -Name "Notepad.exe" -Inject "C:\SomePath\SomeImage2.dll"This will attempt to inject the PE image at C:\SomePath\SomeImage2.dll into the first process found with the name Notepad.exe. If there is no process with that name, a terminating error will be thrown. If the image at C:\SomePath\SomeImage2.dll is nonexistent, inaccessible, or not a valid PE file, a terminating error will be thrown.
Via Process Name, multiple DLLs with explicit array syntax, indefinite wait
New-Injection -Name "calculatorapp.exe" -Inject @("C:\SomePath\Numbers.dll", "C:\SomePath\MathIsHard.dll") -WaitVia Process Name, multiple DLLs, wait for launch, timeout after 60 seconds
New-Injection -Name "SandFall-Win64-Shipping" -Inject "C:\SomePath\ReShade.dll", "C:\SomePath\ClairObscurFix.asi" -Wait -Timeout 60This will attempt to inject the PE images at C:\SomePath\ReShade.dll and C:\SomePath\ClairObscurFix.asi, in that order, into the process named SandFall-Win64-Shipping (again, extension is optional with -Name). If the process isn't currently running, the cmdlet will wait for up to 60 seconds for the process to launch, then abandon the attempt if the process still isn't found. If either image at C:\SomePath\ReShade.dll or C:\SomePath\ClairObscurFix.asi is nonexistent, inaccessible, or not a valid PE file, a terminating error will not be thrown; the cmdlet will skip the invalid file and continue on to the next. As shown in the example, the extension of the file you're injecting doesn't matter; as long as it's a valid PE file, you can attempt to inject it.
There are more examples in the README. I made this because I got real sick of having to fully interact with the DLL injector that I normally use since it doesn't have commandline arguments, immediately fails if you make a typo, etc. I originally wrote it as just a straight C# program, but then thought "That isn't any fun, let's turn it into a PowerShell module for shits and giggles." And now this... thing exists.
Preemptive FAQ:
Why? Why not?
No, really, why? Because I can. Also the explanation in the paragraph above, but mostly just because I can.
Will this let me cheat in online games? Actually yes, it could, because you can attempt to inject any valid PE image into any process. But since this does absolutely nothing more than inject the file and call its entrypoint, you're gonna get banned, and I'm gonna laugh at you, because not only are you a dirty cheater, you're a dumb cheater as well.
I'm mad that this doesn't work in PowerShell 5.1. That is a statement, not a question, and I already covered it at the beginning of this post. It ain't happening. Modern PowerShell isn't scary, download it.
Will this work in Linux? It actually might, with caveats, in very particular scenarios. It builds, imports, and RUNS in PowerShell on Linux, but since it's reliant on Windows APIs, it's not going to actually INJECT anything out of the box, not to mention the differences between ELF and PE binaries. It MIGHT work to inject a DLL into a process that's running through WINE or Proton, but I haven't tested that.
You suck and I think your thing sucks. Yeah, me too.
Why is everything medically-themed in the source code? At some point I just became 100% committed to the bit and couldn't stop. Everything is documented and anything with a theme-flavored name is most likely a direct wrapper to something else that actually has a useful and obvious-as-to-its-purpose name.
Ackchyually, Phlebotomists TAKE blood out, they don't put stuff in it. Shut up.
Anyway, that's it. Hopefully it's a better gift than a lump of coal, but not by much.
r/PowerShell • u/odwulf • Nov 19 '24
Question Our security team proposal: "remove all access to Powershell for non admin users"
I work for a company big enough to have several IT departments, for several internal structures, plus an independent (IE. not part of any of those IT departments) security team. I work for one of the IT departments, handling automation for a few thousands users and computers.
After some kind of drama where communication between the infosec team and us could have been better handled, we extended a hand so that we can collaborate more. Their nearly immediate reply was: "Good idea, let's talk about how things could be better. Why don't you block Powershell.exe and the ISE for every non admin user?"
We have a heavily automated environment: logon scripts, GPO scripts, tools distributed to users, etc. Lots of scripts have to run in the user's context, and execution policy is set on AllSigned". Also, our environment is a layer on top of a corporate basic image we cannot change, already using Powershell automation. Any tip on how to best reply to that brilliant idea?
Edit: I'd like to thank all of you. Your feedback is invaluable.
r/PowerShell • u/MotasemHa • Jan 09 '21
Information Basics of PowerShell P2 : Port Scanning and Pattern Matching - TryHackme Hacking with Powershell
r/PowerShell • u/MadBoyEvo • Oct 27 '24
Question What am I doing wrong? Did I fail to build community around my PowerShell modules?
Hi,
So I've been thinking for some time now, and even more lately, that over the years, I've created a lot of PowerShell modules (80+) that I've given up for free, published on PSGallery, but I have a feeling that I failed to build a community around it.
https://www.powershellgallery.com/profiles/Przemyslaw.Klys -> PSGallery profile says I have 83 packages and over 43 million downloads so far, and this grows a lot daily
https://github.com/EvotecIT -> 80+ repositories with over 6000+ stars across the field
https://evotec.xyz/hub/ -> blog about those modules with lots of other information with 70k+ unique visits per month
https://github.com/PrzemyslawKlys -> according to this I made over 4500+ contributions to Github in the last year
And when I look at the work I did over the last few years, I get very few contributors to my modules in any way (PR, issues, helping with other people's problems, help with documentation), very few github sponsors, if any, feedback is pretty much minimal on new releases, and I think I do something wrong. Don't get me wrong I greatly appreciate the people that helped in any way they did so far, I believe that for the amount of stuff I creteated/maintain I would see much more "action".
I could assume nobody uses my stuff, but I don't believe it's true, as PSGallery, GitHub downloads, and blog visits show a different story.
When I release a new PSWriteHTML, it's basically 1000+ downloads in a day, yet according to GitHub, it appears nobody cares. People can create issues on repositories, and until I actually get to it, no one will even try to help them. I have to go and try to help people even after the issue has been open for a few days.
I own plenty of modules, including AD, GPO, O365, Infoblox, Qualys, DNS, Office, HTML writing/Parsing, FTP/SFTP, PGP, Images, and all kinds of random modules that are hard to track. Yet, I keep maintaining them, adding new features, fixes, upgrades, and so on. Yet, I'm all alone with this.
It would be easy to say the projects are not used, so you get no feedback, sponsors, help with issues, or discussions, and pretty much you can stop doing this, but the "stats," however you read them, are telling quite a different story. I am baffled and genuinely thinking, what am I doing wrong?
Most of my licenses are from MIT, but recently, I've noticed one company that plans to wrap around my Testimo module and start selling it. They brag about it with screenshots on their page. While I always wanted to share my work, it's not something I had in mind when making an MIT license, so I am considering making some changes.
This gets me thinking:
What am I doing wrong?
How do you think this can be improved?
Are people afraid to help? Is the entry-level too high, or are the projects just too easy/advanced (pick one) for them?
Or are there some other issues I am not aware of?
Maybe it's a language barrier (me being a non-native speaker), and my language is not friendly enough (and I don't notice this)
What do you think? Why do some other projects thrive, and mine are "silent"? To name a few, 'dbatools', 'importexcel', etc. Why do some people have many sponsors and others have fewer?
With regards,
Przemek
PS. Just to be clear - I don't want you to go now and create many issues around my PowerShell modules, so I get even more overloaded and have an even harder time—I am just genuinely curious about what I just wrote.
r/PowerShell • u/Techplained • Apr 22 '23
Information ChatGPT the ultimate teaching assistant
I've found a rather effective method for learning Python, as someone familiar with PowerShell.
As someone who benefits from interactive learning and asking questions to form connections, I've found AI to be a game-changer. In the past six months, the AI's direct feedback has helped me learn more than I ever did in the preceding years, even after passing eight Microsoft exams!
Since November, I've been captivated by AI and decided to learn Python for two reasons:
a) to work with APIs and explore exciting applications
b) to overcome my struggles with math and hopefully spark my interest through Python.
To facilitate my learning, I've been using the Edge browser's Bing chat sidebar to interact with the dreary Microsoft Learn pages.By turning complex concepts into engaging fantasy stories or condensing the information into digestible chunks, I've been able to retain the knowledge better, even if it takes a bit longer to complete each module. (I have a pretty great prompt for that too if anyone wants it)
So I wondered if the GPT-4 model's ability to merge concepts and find connections could help me transfer my programming knowledge to Python. To my delight, it's been incredibly helpful.
Here's my approach:
Open Edge and the Bing sidebar (Creative Mode). Use any free Python website as context for the sidebar (or a PDF eBook if you have one).
For each lesson, paste the prompt below.
Remember to refresh the topic each time to avoid repetitive responses from Bing.
Give it a try and see how it works for you! This method has been a fantastic learning tool for me, and I hope it serves you well too.
Prompt:
Re-explain the current web page, which teaches Python, in a more comprehensive and engaging manner. Keep in mind that the reader is well-versed in PowerShell. Utilize the reader's existing knowledge of PowerShell to teach Python more effectively, highlighting the similarities and differences between the two languages in the context of the topic. Choose an appropriate format and structure for the topic, avoiding the use of tables. Use markdown to enhance formatting and engage the reader, emphasizing critical Python-related terms or concepts by bolding or underlining them. Do not search the web for new information.
Edit: more information added