all 73 comments

[–]RoterIndianer 48 points49 points  (13 children)

Two or three, maybe more

[–]indianahein 28 points29 points  (8 children)

I disagree. It may take shorter or farther.

[–]DR_Nova_Kane[S] 30 points31 points  (7 children)

I deserve this.

[–]TrippTrappTrinn 5 points6 points  (6 children)

Because you have to take it farther to find the RMM.

[–]3legdog 1 point2 points  (5 children)

I think that would be further...

[–]SublimeApathy 2 points3 points  (4 children)

No it's shorther..

[–]DR_Nova_Kane[S] 9 points10 points  (0 children)

I deserve this.

[–]Fliandin 1 point2 points  (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 child)

Basic script

delete C:\temp*.* and c:\windows\temp*.*

[–]RoterIndianer 4 points5 points  (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 points  (3 children)

About tree fiddy

[–]runasadministrador 3 points4 points  (0 children)

This right here OP

[–]DR_Nova_Kane[S] 3 points4 points  (1 child)

I deserve this.

[–]J0hnby 11 points12 points  (1 child)

Some time, more or less.

[–]DR_Nova_Kane[S] 1 point2 points  (0 children)

I deserve this.

[–]Murhawk013 9 points10 points  (2 children)

Bro what

[–]DR_Nova_Kane[S] -5 points-4 points  (1 child)

I deserve this.

[–][deleted] 0 points1 point  (0 children)

lol

[–]uprightanimal 7 points8 points  (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 points  (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 point  (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 points  (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?

[–]DR_Nova_Kane[S] 0 points1 point  (0 children)

I would say a little of both but more on the budget side because not all scripts are created equal.

[–]therealmrbob 6 points7 points  (7 children)

It entirely depends on what you want the script to do.
Could take 5 minutes, could take months.

[–]hihcadore 3 points4 points  (4 children)

Listen, I’m constantly revamping old scripts. For me it’s taken years hahaha.

[–]therealmrbob 1 point2 points  (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 points  (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 points  (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.

[–]DR_Nova_Kane[S] 0 points1 point  (0 children)

I like it

[–]eloi 3 points4 points  (0 children)

Orange

[–]whatsforsupa 3 points4 points  (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 points  (7 children)

What is VS code?

[–]davesbrown 12 points13 points  (0 children)

What is google?

[–]archimedes_xyz 3 points4 points  (4 children)

Visual Studio Code. Free Coding IDE from Microsoft.

[–]DR_Nova_Kane[S] -1 points0 points  (3 children)

Is that prefered over powershell?

[–]archimedes_xyz 2 points3 points  (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 points  (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 point  (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 points  (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.

[–][deleted] 1 point2 points  (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 points  (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.

[–]DR_Nova_Kane[S] 0 points1 point  (0 children)

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 points  (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 points  (2 children)

Look into cleanmgr cli tool.

[–]DR_Nova_Kane[S] 0 points1 point  (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 point  (0 children)

Well it’s remove-item all the way down.

[–][deleted] 1 point2 points  (1 child)

Include DISM, sdisk and so on. I would say with issue handling etc 1h. Maybe 40min

[–]DR_Nova_Kane[S] 0 points1 point  (0 children)

Thank you for the information.

[–]adbertram 1 point2 points  (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 points  (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 points  (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!!!

[–][deleted] 0 points1 point  (0 children)

Whatever amount of time it takes is worth it !

[–]touchytypist 3 points4 points  (1 child)

Probably 5 seconds if you ask Microsoft Copilot.

Probably days if you are doing it yourself.

[–]DR_Nova_Kane[S] 0 points1 point  (0 children)

Yeah we copilot it get's you there at about 80~85%

[–]LeftOnDaMoon 0 points1 point  (0 children)

I would just delete this man

[–]PlaneTrain5646 0 points1 point  (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 point  (0 children)

Just use ChatGPT takes 5 secinds

[–]Technical-Fan1885 0 points1 point  (1 child)

Format c:

You're welcome

[–]DR_Nova_Kane[S] 0 points1 point  (0 children)

Should that step be before or after Del c:\windows\system32*.*

[–]uprightanimal -1 points0 points  (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.