Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET

Manage user profiles

Home Forums Scripting PowerShell Manage user profiles

Viewing 1 post (of 1 total)
  • Author
    Posts

  • 12man
    Member
    #167314

    Group,
    I am not versed in PowerShell- still learning.

    I need to manage Userprofiles on 1000+ computers.
    I am starting small.

    The end goal is to remotely delete User profiles (other than specials) over 5 days old)

    This is the ‘rough’ goal

    Get-WMIObject -class Win32_UserProfile -ComputerName ‘XXXXX’| Where {(!$_.LocalPath -like ‘**.*’) -and ($_.ConvertToDateTime($_.LastUseTime) -lt (Get-Date).AddDays(-5))} | Remove-WmiObject



    [SIZE=14px]My initial script only deals with the user profiles[/SIZE]:

    (Get-WmiObject Win32_UserProfile -ComputerName ‘XXXXX’ | Where {($_.LocalPath -like ‘**.*’)}|)

    This successfully enumerates all profiles that fit the pattern (firstname.lastname)

    (Get-WmiObject Win32_UserProfile -ComputerName ‘XXXX’ | Where {($_.LocalPath -like ‘**.*’)}| Remove-WmiObject -whatif)

    This lists all profiles that would be deleted- no errors

    (Get-WmiObject Win32_UserProfile -ComputerName ‘xxxx
    ‘| Where {($_.LocalPath -like ‘**.*’)}| Remove-WmiObject)

    This results in errors…. what am I missing?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: