r/PowerShell • • Jul 23 '19

Use PowerShell delete a user profile (step-by-step guide)

https://adamtheautomator.com/powershell-delete-user-profile/?utm_source=reddit&utm_medium=social&utm_campaign=newblogpostnotifications
120 Upvotes

59 comments sorted by

View all comments

20

u/[deleted] Jul 24 '19

[removed] — view removed comment

5

u/Emiroda Jul 24 '19

As you said, right tool for the job.

So GPO for domain machines you are certain will be reachable, where the GPO fits your needs.

Something else for those that might not be. Non-domain joined DMZ servers, road warrior laptops, etc. I use SCCM to run my PowerShell scripts, either as the new CMScript feature or as CIs.

The only thing you can do entirely wrong is going "this looks nice, I'm going to implement this in production right now". Slow down, see the value being presented, research if there's any alternatives (in this case you'd find the GPO that does this) and then decide what's best in your environment.

9

u/adbertram Jul 24 '19

PowerShell all the things!

9

u/[deleted] Jul 24 '19

[removed] — view removed comment

2

u/adbertram Jul 24 '19

I agree. There are always more than one way to skin a cat. It all depends on context.

1

u/lordv0ldemort Jul 24 '19

Although GPO would be the preferred method, I do enjoy seeing things done the PS way as well.

It’s not if you should do it, it’s if you could do it.

3

u/[deleted] Jul 24 '19

[removed] — view removed comment

2

u/lordv0ldemort Jul 25 '19

Right. Again, I do agree with GPO being the preferred method, just stating that I enjoy seeing the PowerShell way as well.

1

u/jatorres Jul 24 '19

Really? I thought PowerShell was the end all, be all of Windows automation? Any guides / best practices for a GPO that would do this?

19

u/[deleted] Jul 24 '19 edited Jul 24 '19

[removed] — view removed comment

3

u/jeshii Jul 24 '19

I used to have a server dedicated to running powershell scripts on a certain schedule via task scheduler when I was a sysadmin. Not that I disagree with using GPO (since its in the domain and therefore automatically redundant), but I think it's not exactly fair to say that powershell scripts can't be run automatically.

0

u/[deleted] Jul 24 '19

[deleted]

4

u/[deleted] Jul 24 '19

GP is like a shotgun that can double as a rifle. PS is more like a snipper rifle that can (sometimes) double as a shotgun.

4

u/billy_teats Jul 24 '19

A shotgun is not going to hit every single bird in a flock. PS will for sure.

GP hunts. It’s going to find you and get you. Just like everyone else. If you’re around when PS goes off though, ain’t nothin you can do to stop it

0

u/vibrants Jul 24 '19

Disable WinRM

2

u/billy_teats Jul 24 '19

Remove your computer from the domain. Unplug it.

There’s ways around everything

0

u/adbertram Jul 24 '19

I disagree. Sure, if you forget to add a filter of some kind, PS can destroy the world but one of the best quotes I've heard is "Automation is the only way to fail at scale". With great power comes great responsibility. :)

2

u/neztach Jul 24 '19

Seconded