Estou usando esse script com o Exchange 2010, mas tive que fazer algumas pequenas novidades. Também certifique-se de que você está executando isso de um dos servidores de cass Primeiro, altere o PSSnapin para carregar o módulo do Exchange 2010.
“ if (-not((Get-PSSnapin) -match "Microsoft.Exchange.Management.PowerShell.E2010")){ Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 } ”
Next, edit the $SMTPClient to match this line- “ $SMTPClient = New-Object Net.Mail.SmtpClient("127.0.0.1") “
Depois de ter o script personalizado, execute esta seção do comando para criar uma chave reg.
##########################BEGIN####################
$strScriptName = $MyInvocation.MyCommand.Name
if (!(Get-ItemProperty HKLM:\Software\Innervation\$strScriptName -Name LastRun -EA SilentlyContinue)){
# this is the first time the script has run - let's create the registry key and value for future runs
New-Item -path HKLM:\Software\Innervation -EA SilentlyContinue | Out-Null
New-Item -path HKLM:\Software\Innervation\$strScriptName | Out-Null
New-ItemProperty -path HKLM:\Software\Innervation\$strScriptName -Name "LastRun" -Value (Get-Date) -propertyType String | Out-Null
write-host "Initial configuration completed." -ForegroundColor green
}
# get time stamp from registry so we know when it last ran
$LastRun = Get-Date ((Get-ItemProperty -path HKLM:\Software\Innervation\$strScriptName -Name LastRun).LastRun)
$ElapsedTime = ((Get-Date) - $lastrun).TotalSeconds
######################END####################################
Em seguida, comente a última linha para fins de teste.
#########################BEGIN###############################
Set-ItemProperty HKLM:\Software\Innervation\$strScriptName -Name "LastRun" -Value (Get-Date) | Out-Null
######################END#######################
Crie uma nova conta de usuário e teste seu roteiro até ficar feliz. Depois que ele funcionar como planejado, remova o comentário.
@Toshana