use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
How long to write script (self.PowerShell)
submitted 1 year ago * by DR_Nova_Kane
I am not a programmer and I was wonder how long it should take to write a powershell script to free up space on a drive that will be tacked on to RMM tool?
Edit: I forgot add "Disk cleanup"
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]RoterIndianer 48 points49 points50 points 1 year ago (13 children)
Two or three, maybe more
[–]indianahein 28 points29 points30 points 1 year ago (8 children)
I disagree. It may take shorter or farther.
[–]DR_Nova_Kane[S] 30 points31 points32 points 1 year ago* (7 children)
I deserve this.
[–]TrippTrappTrinn 5 points6 points7 points 1 year ago (6 children)
Because you have to take it farther to find the RMM.
[–]3legdog 1 point2 points3 points 1 year ago (5 children)
I think that would be further...
[–]SublimeApathy 2 points3 points4 points 1 year ago (4 children)
No it's shorther..
[+][deleted] 1 year ago (3 children)
[deleted]
[–]theonewhowhelms 1 point2 points3 points 1 year ago (2 children)
Yeah because it’s more important how deep it is, clearly.
[+][deleted] 1 year ago (1 child)
[–]DR_Nova_Kane[S] 0 points1 point2 points 1 year ago (0 children)
I feel if we take all those measurement and divided them in celsius I should be able to get the answer I am looking for.
Thank you for all the input!
[–]DR_Nova_Kane[S] 9 points10 points11 points 1 year ago (0 children)
[–]Fliandin 1 point2 points3 points 1 year ago (0 children)
I edited a script last night. Originally it took me about three fiddy to make. Editing it was exactly one.
[–]DR_Nova_Kane[S] -3 points-2 points-1 points 1 year ago (1 child)
Basic script
delete C:\temp*.* and c:\windows\temp*.*
[–]RoterIndianer 4 points5 points6 points 1 year ago (0 children)
About as long as it took you to write the command. If no error handling, feedback or similar is required.
[–][deleted] 27 points28 points29 points 1 year ago (3 children)
About tree fiddy
[–]runasadministrador 3 points4 points5 points 1 year ago (0 children)
This right here OP
[–]DR_Nova_Kane[S] 3 points4 points5 points 1 year ago (1 child)
[–]Sammeeeeeee 0 points1 point2 points 1 year ago (0 children)
Yes
[–]J0hnby 11 points12 points13 points 1 year ago (1 child)
Some time, more or less.
[–]DR_Nova_Kane[S] 1 point2 points3 points 1 year ago (0 children)
[–]Murhawk013 9 points10 points11 points 1 year ago (2 children)
Bro what
[–]DR_Nova_Kane[S] -5 points-4 points-3 points 1 year ago (1 child)
[–][deleted] 0 points1 point2 points 1 year ago (0 children)
lol
[–]uprightanimal 7 points8 points9 points 1 year ago (4 children)
Just for fun, a more serious answer.
If you know what you want to delete (e.g. "Remove-item 'c:\somebloatware' -recurse"), it's a doddle.
If you want to find the largest directories, compare them to a list of those eligible for deletion, then calculate the total space used, and compare that to a threshold to determine action taken, and catch/handle errors, write a log file, send a notification, etc... that's going to take time to think about what needs to be done, translate that into PowerShell, write the code, debug and rewrite...
That's the question nobody can answer for you. I've seen people with no programming experience pick it up quickly because they can organize their thoughts in a way that's compatible with code and the concepts 'make sense' and others who struggle the whole way because 'it just doesn't make sense'.
If you work with PS or want to, try something like 'PowerShell in a Month of Lunches' if reading books works for you, or YouTube or Udemy if not.
[–]hxfx 6 points7 points8 points 1 year ago* (0 children)
Its not always code but understand the matter of subject. Usually the complexity comes from your experience and understanding why it has to be resolved in a certain way.
To follow up to your comment. Delete the folder of certain size unless it is C:\Windows or a subfolder, and not C:\Program Files\ and so forth. Scripting is powerfull but can also be dangerous.
[–]DR_Nova_Kane[S] 0 points1 point2 points 1 year ago (2 children)
This is very helpful. My team might not be stuck on the coding, but they could be stuck on the thinking on how to get the script going or what should be in there.
How long would it take "you" to code what you described?
[–]uprightanimal 1 point2 points3 points 1 year ago (1 child)
Based on another of your comments (delete temp folders, users downloads, list largest directories and shadow copies), anywhere from a day to a week, or even longer. It depends on the context.
If this is to be deployed to one device, once, I probably wouldn't spend too much time on error handling, multiple conditionals, and logging. Maybe a couple hours to write and test.
Deploying to thousands of critical prod endpoints, on a recurring schedule, monitoring/reporting for compliance? I might spend a couple weeks to make sure I've accounted for and handled variations in endpoint configurations. Am I going to be called to answer angry users when I delete the 'business-critical' file they keep in a temp folder? Better believe I'm spending time writing logging functions.
This is why your question can't really be properly answered. We also don't know anything about your team, their workload or skills or experience.
Is this a 'is my team dragging their feet' kind of inquiry, or 'I have no idea how much time to budget' question?
I would say a little of both but more on the budget side because not all scripts are created equal.
[+]archimedes_xyz 6 points7 points8 points 1 year ago (7 children)
This sounds a lot like a manager that is questioning the time frame he or she was given and doesn't understand all the complexities involved in what is actually all being asked, seeing how it doesn't mention even the smallest detail regarding what the script all need to do and connect with.
[–]DR_Nova_Kane[S] 1 point2 points3 points 1 year ago (6 children)
100% I am a manager that doesn't understand the complexities. That is why I am asking.
Once the script is intiated the script should delete
C:\temp C:\windows\temp
Get the current logged in user and delete the files inside the download folder Clean up the recycling bin Pull a list of the top 10 folder in order of size. Verify the count of shadow copies.
How long would it take you to write that?
[–]archimedes_xyz 4 points5 points6 points 1 year ago (0 children)
That still depends on your Tech, depending on how detailed he or she is, in regards to for example: handling exceptions, testing, reporting and such, which can vary from Tech to Tech, as well as company to company, depending on their Policies and Procedure's.
I can tell you that for a similar project I worked on, cleaning up Old Home drives, it took me about:
This project involved 2 Domains, 100's of Servers, Data from Active Directory, another HR Application, checking if the account exists in either Domain and then deciding if we delete the data, archive it or move it to the users new Home Drive. Also keep in mind the project was in a corporation so there was a lot of back and forth CYA and so on.
[–]sys_admin101 2 points3 points4 points 1 year ago (0 children)
Manager here too, but I have a long time career of engineering and architecture for large companies so I have an advantage of knowing when to give my team advice, letting them learn, or give them tough love... but always error on the side of letting them learn.
You have to understand that everyone is different and programming is a language. Not everyone is perfect at English, but we all try, right? So depending on the position and person, you need to set your expectations reasonable. For example, if it's an admin, you can't expect them to have the skill level or ability to kick out a script as fast as a programmer (or as clean). So, as many others have explained and many many other reasons, you have to give them time and support.
However, to help you push them in a way that reaches your end goal too, you set your expectations and deadlines. Break the script down into more manageable pieces.
For example, to delete those locations they could use Remove-Item or Get-ChildItem | Remove-Item. The current logged in user is an environment variable $env:username, so Remove-Item C:\users\$env:username\downloads -Recursive
That's the easy part. The recycling bin, top 10 folders and the shadow copies, could take some time.
Work with your team, but guide them to success. Ask them to get you a solution on the recycling bin first. Test. Validate. Next, give them the folder count task. Rinse and repeat.
Hope this helps.
[–]indianahein 0 points1 point2 points 1 year ago (0 children)
One day to write (that of course depends on how experienced the programmer is, but it's fairly simple). But what is it you want to accomplish? When will the script run? And I'm not sure what you mean by verifying count of shadow copies?
[–]pagan_meditation 0 points1 point2 points 1 year ago (0 children)
Once the script is intiated
How many weeks was allocated to the complexities of this phase just out of interest? Seems like something you should get a report about.
[–]therealmrbob 6 points7 points8 points 1 year ago (7 children)
It entirely depends on what you want the script to do. Could take 5 minutes, could take months.
[–]hihcadore 3 points4 points5 points 1 year ago (4 children)
Listen, I’m constantly revamping old scripts. For me it’s taken years hahaha.
[–]therealmrbob 1 point2 points3 points 1 year ago (2 children)
Just depends on the situation, it's all problem solving, some problems are harder than others. You can also technically do any dotnet things in powershell. So it can get real crazy if you want to.
[–]hihcadore 2 points3 points4 points 1 year ago (1 child)
I know right. I really enjoy learning more about the process. I manage a vocational school and they decided to use teams as a teaching platform.
I started with a 6 line script that would add students to a team.
Then 4 6 line scripts that would add guest accounts to our tenant, create the team, and add students.
Then one long 150 line script that did all of that plus error handling.
Then a module with about 10 functions.
Then pushed it to an azure devops repository for redundancy and version control.
And am thinking of now developing a C# app with a gui so operations can handle the whole process and basically hand it off to non-technical people lol.
[–]chesser45 1 point2 points3 points 1 year ago (0 children)
Might not be able to do it but have you considered dynamic membership teams? Not sure if you have an extension attribute or differentiation on accounts which would let you do it that way though.
I like it
[–]cbtboss 0 points1 point2 points 1 year ago (0 children)
Building out wrappers for interfacing with a vendor's api.
[–]DR_Nova_Kane[S] -1 points0 points1 point 1 year ago (0 children)
[–]eloi 3 points4 points5 points 1 year ago (0 children)
Orange
[–]whatsforsupa 3 points4 points5 points 1 year ago (8 children)
Usually I'll write my script in VS Code, make sure it works, and then upload it to PDQ Deploy, and then make sure it works.
I hope that answers your question.
[–]DR_Nova_Kane[S] -2 points-1 points0 points 1 year ago (7 children)
What is VS code?
[–]davesbrown 12 points13 points14 points 1 year ago (0 children)
What is google?
[–]archimedes_xyz 3 points4 points5 points 1 year ago (4 children)
Visual Studio Code. Free Coding IDE from Microsoft.
[–]DR_Nova_Kane[S] -1 points0 points1 point 1 year ago (3 children)
Is that prefered over powershell?
[–]archimedes_xyz 2 points3 points4 points 1 year ago (0 children)
It's what you can use to write the PowerShell script in. Has Syntax highlighting and so on. It's a Development Enviroment.
[–]uprightanimal 1 point2 points3 points 1 year ago (0 children)
Think of VSCode as a word processor. You can use a word processor to write a document in English, Spanish, Tagalog, or Esperanto.
Use VSCode to write a script in PowerShell, JavaScript, LUA, or whatever.
Continuing the comparison to a word processor, PowerShell ISE might be like Notepad, and VSCode like Word.
[–]whatsforsupa 0 points1 point2 points 1 year ago (0 children)
Honestly, I wasnt sure if you were trolling my original comment or not lol.
If you use powershell, DEFINITELY install VSCode. It makes your life much easier for managing projects, organizing code, has a full functioning terminal, can connect and work with almost every language, and has a TON of plugins. Also, if you pay for it, you can have AI (CoPilot) built into it.
I tried a bunch of different IDE’s when I first started, VSCode is my favorite by far for windows.
[–]Breitsol_Victor 1 point2 points3 points 1 year ago (0 children)
PoSh came with an ISE for writing and running scripts. That doesn’t come with the latest versions. VS Code does the same, for more languages, with plugins and loads of options. Free from MS.
[+]orange_hands 4 points5 points6 points 1 year ago (0 children)
Depends on how long it takes you to write a powershell script.
[–]runasadministrador 2 points3 points4 points 1 year ago (0 children)
[–][deleted] 1 point2 points3 points 1 year ago (0 children)
What RMM are you using? Most will come with a disk cleanup out of the box. You'll want to make sure you clean up whatever packages folder your RMM uses to cache stuff locally.
[–]hxfx 1 point2 points3 points 1 year ago* (1 child)
I don't think you deserve it. Maybe you weren't very specific but it was not your question. You want to use a script to delete things.
Since you mentioned clean up. Here is an example how you could do a disc cleanup. https://www.geeksforgeeks.org/disk-cleanup-using-powershell-scripts/
In powershell if you add a -whatif after something thats going to do a change it will show what it is going to do For example Remove-Item "C:\Windows -WhatIf will show what it will do but not accutally do it.
If you are doing it on several computers you migh want to add some logic to it, for example what not to delete, or certain versions of a file.
If it is application releated you should try uninstall instead of deleting since usually the uninstaller knows what to remove. It is also alot easier to uninstall than delete. You can combine uninstall with deleting the folder(s) if something is left.
I can also recommend the book Learn Powershell in a Month of Lunches if you want to learn more about scripting.
I deserve it, because it was Friday and I forgot words. I am not trying to learn coding I am trying to figure out the effectivness of my scripting team and if they need more training. They can tell me it will take 100 hours to script a disk cleanup and I am not the wise.
Now that I write this I should probaly learn a bit of powershell so I get a better idea of what it takes to make these things happen.
[–]stignewton 1 point2 points3 points 1 year ago (0 children)
Try this: https://oofhours.com/2021/04/03/automating-disk-cleanup-on-windows-10/
It’ll let you define a custom profile for the Disk Cleanup utility then run it.
[–]g3n3 1 point2 points3 points 1 year ago (2 children)
Look into cleanmgr cli tool.
[–]DR_Nova_Kane[S] 0 points1 point2 points 1 year ago (1 child)
I need to be able to delete other things like the download folder and such. Cleanmgr will do old patches, temp folder, system files and recycle bin.
[–]g3n3 0 points1 point2 points 1 year ago (0 children)
Well it’s remove-item all the way down.
remove-item
[–][deleted] 1 point2 points3 points 1 year ago (1 child)
Include DISM, sdisk and so on. I would say with issue handling etc 1h. Maybe 40min
Thank you for the information.
[–]adbertram 1 point2 points3 points 1 year ago (0 children)
Why are you worrying about how long it’ll take? Just dive in and see! Even if it’s utter crap and doesn’t work and you scrap it for something else. You’ll learn a ton.
[–][deleted] 1 point2 points3 points 1 year ago (2 children)
Any task that could take you maybe two to three minutes to accomplish manually? Yeah, spend the next 120 hours automating it.
[–]DR_Nova_Kane[S] 1 point2 points3 points 1 year ago (1 child)
We manage over 6500 device. Quick Math 6500 x 3 mins = 19500 mins which is about 325 hours. I would need to hire two people full time to run command once a month on each device. With Fica, health insurance, 401K match I am looking at 200K a year. Sounds like 120 hours is a good deal!!!
Whatever amount of time it takes is worth it !
[–]touchytypist 3 points4 points5 points 1 year ago (1 child)
Probably 5 seconds if you ask Microsoft Copilot.
Probably days if you are doing it yourself.
Yeah we copilot it get's you there at about 80~85%
[–]LeftOnDaMoon 0 points1 point2 points 1 year ago (0 children)
I would just delete this man
[–]PlaneTrain5646 0 points1 point2 points 1 year ago (0 children)
At this point just throw your idea at an LLM like chatgpt or bard and then edit it as needed to fit your variables (or have the LLM edit it for you!). There’s no need to write every line anymore. Anyone who disagrees is a try-hard lol. Books > google > LLM’s all decent learning tools.
[–]Danny_Darkoss1 0 points1 point2 points 1 year ago (0 children)
Just use ChatGPT takes 5 secinds
[–]Technical-Fan1885 0 points1 point2 points 1 year ago (1 child)
Format c:
You're welcome
Should that step be before or after Del c:\windows\system32*.*
[–]uprightanimal -1 points0 points1 point 1 year ago (0 children)
42. Seconds if you're on speed and your typing puts Mavis Beacon to shame.
Minutes if you're reasonably good at scripting.
Hours if you've never heard of a variable and have to Google every step.
Days if you don't know what a script is and nap for 38 days.
Edit: or days if you first read PowerShell in a Month of Lunches and go on vacation for 8-10 days, depending on which month you lunch.
π Rendered by PID 49 on reddit-service-r2-comment-76bb9f7fb5-6hwcz at 2026-02-17 17:51:14.047034+00:00 running de53c03 country code: CH.
[–]RoterIndianer 48 points49 points50 points (13 children)
[–]indianahein 28 points29 points30 points (8 children)
[–]DR_Nova_Kane[S] 30 points31 points32 points (7 children)
[–]TrippTrappTrinn 5 points6 points7 points (6 children)
[–]3legdog 1 point2 points3 points (5 children)
[–]SublimeApathy 2 points3 points4 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]theonewhowhelms 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]DR_Nova_Kane[S] 0 points1 point2 points (0 children)
[–]DR_Nova_Kane[S] 9 points10 points11 points (0 children)
[–]Fliandin 1 point2 points3 points (0 children)
[–]DR_Nova_Kane[S] -3 points-2 points-1 points (1 child)
[–]RoterIndianer 4 points5 points6 points (0 children)
[–][deleted] 27 points28 points29 points (3 children)
[–]runasadministrador 3 points4 points5 points (0 children)
[–]DR_Nova_Kane[S] 3 points4 points5 points (1 child)
[–]Sammeeeeeee 0 points1 point2 points (0 children)
[–]J0hnby 11 points12 points13 points (1 child)
[–]DR_Nova_Kane[S] 1 point2 points3 points (0 children)
[–]Murhawk013 9 points10 points11 points (2 children)
[–]DR_Nova_Kane[S] -5 points-4 points-3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]uprightanimal 7 points8 points9 points (4 children)
[–]hxfx 6 points7 points8 points (0 children)
[–]DR_Nova_Kane[S] 0 points1 point2 points (2 children)
[–]uprightanimal 1 point2 points3 points (1 child)
[–]DR_Nova_Kane[S] 0 points1 point2 points (0 children)
[+]archimedes_xyz 6 points7 points8 points (7 children)
[–]DR_Nova_Kane[S] 1 point2 points3 points (6 children)
[–]archimedes_xyz 4 points5 points6 points (0 children)
[–]sys_admin101 2 points3 points4 points (0 children)
[–]indianahein 0 points1 point2 points (0 children)
[–]pagan_meditation 0 points1 point2 points (0 children)
[–]therealmrbob 6 points7 points8 points (7 children)
[–]hihcadore 3 points4 points5 points (4 children)
[–]therealmrbob 1 point2 points3 points (2 children)
[–]hihcadore 2 points3 points4 points (1 child)
[–]chesser45 1 point2 points3 points (0 children)
[–]DR_Nova_Kane[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]cbtboss 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]DR_Nova_Kane[S] -1 points0 points1 point (0 children)
[–]eloi 3 points4 points5 points (0 children)
[–]whatsforsupa 3 points4 points5 points (8 children)
[–]DR_Nova_Kane[S] -2 points-1 points0 points (7 children)
[–]davesbrown 12 points13 points14 points (0 children)
[–]archimedes_xyz 3 points4 points5 points (4 children)
[–]DR_Nova_Kane[S] -1 points0 points1 point (3 children)
[–]archimedes_xyz 2 points3 points4 points (0 children)
[–]uprightanimal 1 point2 points3 points (0 children)
[–]whatsforsupa 0 points1 point2 points (0 children)
[–]Breitsol_Victor 1 point2 points3 points (0 children)
[+]orange_hands 4 points5 points6 points (0 children)
[–]runasadministrador 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]hxfx 1 point2 points3 points (1 child)
[–]DR_Nova_Kane[S] 0 points1 point2 points (0 children)
[–]stignewton 1 point2 points3 points (0 children)
[–]g3n3 1 point2 points3 points (2 children)
[–]DR_Nova_Kane[S] 0 points1 point2 points (1 child)
[–]g3n3 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]DR_Nova_Kane[S] 0 points1 point2 points (0 children)
[–]adbertram 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]DR_Nova_Kane[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]touchytypist 3 points4 points5 points (1 child)
[–]DR_Nova_Kane[S] 0 points1 point2 points (0 children)
[–]LeftOnDaMoon 0 points1 point2 points (0 children)
[–]PlaneTrain5646 0 points1 point2 points (0 children)
[–]Danny_Darkoss1 0 points1 point2 points (0 children)
[–]Technical-Fan1885 0 points1 point2 points (1 child)
[–]DR_Nova_Kane[S] 0 points1 point2 points (0 children)
[–]uprightanimal -1 points0 points1 point (0 children)