Jump to content

cyber8607

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by cyber8607

  1. i think, i have a better idea. hope you can help me, to solve it with a IF Request. here the important part of the Script: Import-Module ActiveDirectory start-sleep -s 15 $DisabledAccounts = Get-User -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Where-Object { $_.UserAccountControl -match 'AccountDisabled' } $Count = $DisabledAccounts.Count Add-Content $LogFile "There are $Count disabled accounts that have active mailboxes" Foreach ($Account in $DisabledAccounts) { if ( get-aduser $Account. { $_.LastLogonTimeStamp -lt(get-date).addmonths(-12) } ) { #$EmailAddress = $Account.PrimarySMTPAddress.tostring() $Name=$Account.SamAccountName #Disable-Mailbox $Account.SamAccountName -Confirm:$false Add-Content $LogFile "$Name, Mailbox has been Disabled" } } Do you have a idea how can i make the IF request ? in the if request i would have oll disabled accounts that are longer offline than 12 months.
  2. no, i havent tried it before. i'm not really a big powershell expert i tried to use your command, but it give me the following error: Invoke-Command : Cannot bind parameter 'Filter' to the target. Exception setting "Filter": ""enabled" is not a recognized filterable property.
  3. Hi guys, this website helped me alot to make a powerschell script to disconnect mailbox for disabled User. But now i stuck to verify the LastLogonTimeStamp, here my syntax: Get-User -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Where-Object { $_.UserAccountControl -match 'AccountDisabled' -and $_.LastLogonTimeStamp -lt(get-date).addmonths(-12) } But it list all disabled Users witha Mailbox. Not only the Disabled User, that have never Logged in for 12 Months. Can someone help? thank you
×
×
  • Create New...