Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How to delete Windows user profile with PowerShell?

$
0
0

Helo, guys!

I need to be able to delete all user's profiles on all workstations in case of emergency. I have read similiar topics, but don't think it's suitable for me, so I need some help.

All workstations are working under Win7Pro, so I want to use PowerShell for this duty and I think I can use New-PSSession cmdlet to establish sessions to all my workstations, after that I need to log off users and delete profiles.

I tried to delete a profile at my localhost with next command:

( Get-WmiObject -Class Win32_UserProfile | Where-Object { $_.LocalPath -eq 'c:\users\user' } ).Delete()

but get an exception: Exception calling "Delete" with "0" argument(s)

I thought this method needs some args, but I couldn't find its definition or syntax neither with Get-Member, nor at MSDN. Can you point me - what does this error mean?

By the way - is there an easy way to log off users from system with PowerShell?


Thanks for all replies!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>