Como programar una tarea en powershell

Solo disponible en BuenasTareas
  • Páginas : 3 (726 palabras )
  • Descarga(s) : 0
  • Publicado : 10 de marzo de 2011
Leer documento completo
Vista previa del texto
How To: Schedule PowerShell Script for an Exchange Task
Filed under: Exchange,Exchange 2007,PowerShell — Amit Tank @ 3:31 pm
Tags: Exchange, Exchange 2007, PowerShell
This is commonly askedquestion, How to schedule a PowerShell script to run an Exchange task automatically? Here is the procedure to get it done.
Let’s take an example, I want to schedule a PowerShell script for auditingpurpose, which scans whole environment & finds mailboxes which has some Send-As permission assigned and send the CSV formatted report to email id every Monday 9:00AM.
1. Set the PowerShell environment.
Weneed to set environment to run custom PS1 script which we created because by default PowerShell doesn’t allow to run it.
By default Execution Policy is ‘Restricted’ which means it does not loadconfiguration files to run custom scripts. We need to change it to ‘RemoteSigned’ to run locally created PS1 scripts however RemoteSigned policy requires PowerShell script that may be downloaded must besigned.
This is one time activity so if you have already set the execution policy to RemoteSigned earlier then you can skip this step.
Run below command in ESM to set the execution policy.Set-ExecutionPolicy RemoteSigned
[pic]
2. Create a Script file (.PS1 file).
Here is the script to get the Send-As report in email.
# Send-As.ps1 - Get the report of all mailboxes with Send-As permissionassigned on email.
# Created by - Amit Tank
 
#Adding Exchange Snap In to execute Exchange CmdLets in this script
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
 
#Get Send-Aspermission report to CSV file
Get-Mailbox | Get-ADPermission | where { ($_.ExtendedRights -like “*Send-As*”) -and ($_.IsInherited -eq $false) -and -not ($_.User -like “NT AUTHORITY\SELF”) } | SelectIdentity, User, Deny | Export-CSV c:\send-As.csv
 
#Send an email
$FromAddress = "amit.tank@Domain.com"
$ToAddress = "amit.tank@Domain.com"
$MessageSubject = "Send-As Audit Report"
$MessageBody =...
tracking img