Manage user profiles

Home Forums Scripting PowerShell Manage user profiles

Viewing 1 post (of 1 total)
  • Author
  • Avatar

    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.