Question : Powershell script to identify todays created Users/groups/Computers and email using Outlook as a client.

Hi,

Powershell script to identify todays created Users/groups/Computers and email using Outlook as a client.
I want help with a script that i can use as a scheduled task and run dail. I want a report of users/Computers/Groups created with the OU path in an email sent to 3 persons.

Regards
Sharath

Answer : Powershell script to identify todays created Users/groups/Computers and email using Outlook as a client.


> And how can i schedule this code to run each day

Save it as a .ps1 file, set up a scheduled task to run the version below like this:

PowerShell.exe C:\wherever\script.ps1

I've added a line to the top to ensure the Quest CmdLets load, they will need to be installed on the system running the script.

Chris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Get-PsSnapIn -Reg | Add-PsSnapIn -ErrorAction 0

$Recipients = "[email protected]", "[email protected]", "[email protected]"

$LdapFilter = "(|(&(objectClass=user)(objectCategory=person))(objectClass=computer)(objectClass=group))"

$Content = [String](Get-QADObject -LdapFilter $LdapFilter `
    -SearchRoot "OU=somewhere,DC=domain,DC=com" `
    -CreatedAfter $((Get-Date).AddDays(-1)) | 
  Select-Object Name, Type, DN | 
  Sort-Object Type, Name | 
  ConvertTo-Html)

Send-MailMessage -To $Recipients -Body $Content -BodyAsHtml `
  -From "[email protected]" -Subject "New Objects Today" `
  -SmtpServer "someserver"
Random Solutions  
 
programming4us programming4us