Wednesday, October 19, 2011

OpenVPN on CentOS 5

wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm

#wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

hxxp://sohonetwork.blogspot.com/2010/08/installing-openvpn-on-centos-55-x8664.html

hxxp://nuttinu.wordpress.com/2010/07/17/installing_openvpn_on_vps_centos_5_based/

yum install rpm-build autoconf.noarch zlib-devel pam-devel openssl-devel gcc make

#####################################################################################

vi /etc/openvpn/server.conf

local 172.16.x.x
port 443
proto tcp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/server.crt
key /etc/openvpn/easy-rsa/keys/server.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem
;ca ca.crt
;cert server.crt
;key server.key
;dh dh1024.pem
server 10.10.10.0 255.255.255.0
push "redirect-gateway"
;client-config-dir /etc/openvpn/ccd
;route 172.16.1.0 255.255.255.0
;push "route 172.16.1.0 255.255.255.0"
push "dhcp-option DNS 172.16.x.x"
push "dhcp-option DOMAIN mmx.com"
ifconfig-pool-persist ipp.txt
client-to-client
keepalive 10 120
max-clients 50
comp-lzo
user nobody
group users
persist-key
persist-tun
status openvpn-status.log
verb 3

############################################################

vi /etc/sysconfig/iptables

-A POSTROUTING -o eth0 -j MASQUERADE
-A FORWARD -i eth0 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i tun0 -o eth0 -j ACCEPT

############################################################

client.ovpn

client
dev tun
proto tcp
resolv-retry infinite
remote gateway.mmx.com 443
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
comp-lzo
verb 3

Exchange 2010 - PowerShell Commands - III

Remove a message from Mail Queue

Remove-message -filter {FromAddress -eq “testuser@mmx.com”} -WithNDR $false

Get-Message -queue "ny-cas-2k8\319045" | remove-message -Confirm:$false


Send an Email from PowerShell v1.0

PS C:\> $smtp = New-Object Net.Mail.SmtpClient("your-cas-server.mmx.com")
PS C:\> $smtp.Send("sender@mmx.com","recipient@mmx.com","Test Email","This is a test")

Send an Email from PowerShell v2.0

PS C:\> $PSEmailServer = "your-cas-server.mmx.com"
PS C:\> Send-MailMessage -From "exchange-reports@mmx.com" -To "zawhtet@mmx.com" -Subject "Test email" -Body "This is a test email"

----------------------------------------------------------------------------------

Get-MailboxDatabase 'Mailbox-Dbase-1' | Get-MailboxStatistics | Sort totalitemsize -desc | Export-CSV C:\Mailbox-Stat.csv

Exchange 2010 - Check ServiceHealth, Configure Message Tracking Log with PowerShell

Test-ServiceHealth your-cas-server

Test-ServiceHealth your-mailbox-server

OR

Get-ExchangeServer | Test-ServiceHealth | ft Role,RequiredServicesRunning

--------------------------------------------------------------------------------
Get-TransportServer -identity your-cas-ht-server | fl *messagetracking*

Set-TransportServer your-cas-ht-server –MessageTrackingLogEnabled $true

Set-TransportServer -id your-cas-ht-server –MessageTrackingLogMaxAge 60.00:00:00

Set-TransportServer -id your-cas-ht-server –MessageTrackingLogPath “E:MessageTrackingLogs”

Set-TransportServer -id your-cas-ht-server –MessageTrackingLogMaxDirectorySize 3GB

Set-TransportServer -id your-cas-ht-server –MessageTrackingLogSubjectLoggingEnabled $true

Make Cisco Router as WebServer and Save Config to flash:

#sh flash (check your cisco router's flash for available space) copy running-config flash:backupconfig (that will save running-config file as backupconfig in flash) copy flash:backupconfig running-config (that will copy back your backupconfig file to running-config) erase flash:. (delete everything under flash:) delete /force /recursive flash:backupconfig (that will delete file named backupconfig from flash:) =========================================================== hxxp://ardenpackeer.com/ios-features-management/how-to-set-up-a-cisco-router-as-a-webserver/ R3(config)#ip http server R3(config)#ip http path flash: R3#copy tftp flash: Address or name of remote host [192.168.1.1]? 192.168.1.1 Source filename [picture.jpg]? index.html R3#dir

Friday, October 7, 2011

Exchange 2003 Server stop and start Services

Copy and Paste these lines to notepad. Save with ".bat" file.

net stop MSExchangeES /y
net stop MSExchangeIS /y
net stop MSExchangeMTA /y
net stop MSExchangeSA /y
net stop POP3Svc /y
net stop IMAP4Scv /y

If POP3 and IMAP4 are not used by your exchange organization, you can eliminate the last two lines.
Also you can use similar batch file script to start all those services, after the exchange server restarted.

net start MSExchangeES /y
net start MSExchangeIS /y
net start MSExchangeMTA /y
net start MSExchangeSA /y
net start POP3Svc /y
net start IMAP4Scv /y

Exchange 2010 - PowerShell Commands - II

Remove User Mailbox UID after you've deleted from the EMC

Get-MailboxStatistics -Database 'Administration' | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL DisplayName, DisconnectDate, MailboxGuid

Remove-Mailbox -Database 'Administration & Business Development' -StoreMailboxIdentity 889a9b8e-5883-42a6-a8a7-350483d34456

Get-MailboxStatistics -Server 'your-mb-svr.mmx.com'
Get-MailboxStatistics -Database "Operations"

Get-Message -Filter {FromAddress -like "*@gmail.com"} | Format-List

Restart-Service -InputObject (get-Service -ComputerName your-mb-svr -Name MSExchangeSA)

Exchange 2010 - PowerShell Commands

Restart Exchange Services

Get-Service | ? { $_.name -like "MSExchange*" -and $_.Status -eq "Running"} foreach ($service in $services) {Restart-Service $service.name -Force}


Get-wmiobject win32_service | ? {$_.name -like "MSExchange*" -and $_.StartMode -eq "Auto"} foreach ($service in $services) {Restart-Service $service.name -Force}

##########################################################################################################################################################################################3

Get-service -name "msexchange*" -dependentservices Where-Object {$_.Status -eq 'Running'} Stop-Service

Starting all exchange services could be done by following code:

Get-service -name "msexchange*" start-service

get-service -name "msexchange*" -DependentServices -exclude msexchangepop3,msexchangeimap4,msexchangeMonitoring start-service

In which we would query the services and only start services which have been set to start automatically.

Get-Service -name "msexchange*" where-object {$_.startuptype -eq "automatic"} start-service



Get-Service | Where {$_.DisplayName -Like "Microsoft Exchange*"}

=======================================================

Update OAB on Client Access Server
1. Restart "MS Exchange System Attendant Service" on (Mailbox Server)

2. Update-FileDistributionService -Identity my-cas-server-host-name -Type OAB

Testing Commands

test-mailflow your-mailbox-server -TargetEmailAddress zawhtet@mmx.com
test-servicehealth <-- check whether require services are running or not!
test-mapiconnectivity
test-outlookconnectivity

Monitoring Mail Queue and Messages
get-message
get-queue

Message Tracking and Export to HTML file

Get-MessageTrackingLog -EventID Deliver/Fail -Sender "Fazana@gmail.com" -Recipients "sandi@mmx.com" -Start 10/3/2011 -End 10/4/2011 | ConvertTo-Html Timestamp, ClientIp, EventID, Sender, {$_.Recipients}, TotalBytes, RecipientCount, MessageSubject | Set-Content c:\sandi.html

get-messagetrackinglog -EventID Fail -start "1/20/2011 12:00am" -resultsize 3000| where {[string]$_.recipients -like "*@gmail.com"}

Get-MessageTrackingLog -resultsize unlimited |where-object {$_.Recipients -like "*@gmail.com, *@yahoo.com" -AND $_.EventId -eq "Send"} |ft -auto >>d:\external.txt

get-transportserver | Get-MessageTrackingLog -ResultSize Unlimited -Start “10/17/2009 8:00AM” -End “11/17/2009 5:00PM” -eventid Send | WHERE {$_.recipients -like “*domainname.com*”} > “c:\send.xls”

If you found that mail flow for your Server is slow

Get_receiveConnector

Set-ReceiveConnector "your receive connector name" -MaxAcknowledgementDelay 0

Set your transport Connector to Send and Receive 20MB Emails

Set-TransportServer your-cas-svr -MaxConcurrentMailboxDeliveries 20

Get-TransportConfig
Get-TransportConfig | fl MaxSendSize,MaxReceiveSize
Set-TransportConfig -MaxReceiveSize 20MB -MaxSendSize 20MB

Get-Adsitelink DEFAULTIPSITELINK | select Maxmessagesize
Set-Adsitelink DEFAULTIPSITELINK -MaxMessageSize 20MB

Get-SendConnector
Get-Sendconnector "InternetSendConnector" | fl Name,MaxMessageSize
Set-Sendconnector "InternetSendConnector" -MaxMessageSize 20MB

Get-Receiveconnector
Get-Receiveconnector -Identity "" | fl Name,MaxMessagesize
Set-ReceiveConnector -Identity " -MaxMessageSize 20MB

Get-Mailbox zawhtet | fl MaxSendSize,MaxReceiveSize
Set-Mailbox Zaw Htet -MaxSendSize 20MB -MaxReceiveSize 20MB

Get-ForeignConnector | fl Name,MaxMessageSize
Get-SendConnector | fl Name,MaxMessageSize
Get-ReceiveConnector | fl Name,MaxMessageSize

Set Individual User's Mailbox (Send / Receive Message Size)

Get-Mailbox zaw Htet | Format-Table Name, *Max*

Set-Mailbox zaw Htet -MaxSendSize 20mb -MaxReceiveSize 20mb

Get and Set Room Mailbox to auto accept

get-Mailbox | where {$_.ResourceType -eq "Room"} | Set-MailboxCalendarConfiguration -AutomateProcessing:AutoAccept

Anti-Spam Configuration

Add-IPBlockListProvider -Name "SpamHaus IP Block List Provider" -LookupDomain "zen.spamhaus.org" -BitMaskMatch 127.0.0.1

Set-IPBlockListProvider "SpamHaus IP Block List Provider" -RejectionResponse "Your message was rejected because the IP address of the server sending your message is in the block list of SpamHaus IP Block List Provider service."

Get-IPBlockListProvider | Test-IPBlockListProvider -IPAddress xx.xx.xx.xx

Misc CMDs

Get-MailboxStatistics zawhtet | fl totalitemsize

Get-Mailbox zawhtet | fl *Quota

Update-GlobalAddressList -Identity "Default Global Adress List" -DomainController

Update-OfflineAddressBook “Name of Address Book”

Get-OfflineAddressBook | Update-OfflineAddressBook

Get-ReceiveConnector | fl Id*,Pr*

Get-SendConnector | fl Id*,Pr*

Get-TransportServer | fl Id*,*pro*log*

Get-MessageTrackingLog | fl

Remove-Message -Filter {FromAddress -like "*spammer.com*" -and SCL -gt 5} -withNDR $false

Remove-Message -Filter {FromAddress -like "*dorofej.com*" -and SCL -gt 7} -withNDR $false

Remove-Message -Server your-cas-svr.mmx.com -Filter {FromAddress -eq "zawhtet@mmx.com"} -WithNDR $false

Get-Queue -Filter {MessageCount -gt 100}

Get-Queue -Identity your-cas-svr.mmx.com\mmx.com | Format-List

Get-TransportServer your-cas-svr | fl

Get-MailboxServer your-mb1-svr | fl

nslookup

set q=mx
mail.mmx.com

This command will set the default warning quota on the database Mailbox Database on server your-mb1-svr to 975MB, and the limit at which users will no longer be able to send mail to 1000MB:

Set-MailboxDatabase your-mb1-svr\Mailbox Database -IssueWarningQuota 975MB -ProhibitSendQuota 1000MB

This command will set the warning quota for user zawhtet to 1475MB, and the limit at which the user will no longer be able to send mail to 1500MB. It will also configure the mailbox not to use the database default quotas:

Set-Mailbox zawhtet -IssueWarningQuota 1475MB -ProhibitSendQuota 1500MB -UseDatabaseQuotaDefaults $false


Command to list all messages to a specific domain for the day


get-transportserver | Get-MessageTrackingLog -ResultSize Unlimited -Start "10/29/2009 8:00AM" -End "10/29/2009 5:00PM" -eventid Send | WHERE {$_.recipients -like "*gmail.com*"} > "c:\gmail.xls"

Get-MessageTrackingLog -ResultSize Unlimited -Start “10/29/2010 8:00AM” -End “10/29/2010 5:00PM” -eventid Send | WHERE {$_.recipients -like “*gmail.com*”}

Get-Message -Filter {FromAddress -like "*@gmail.com"} | Format-List

Roles

New-ManagementRoleAssignment -Role "Message Tracking" -SecurityGroup "Exchange Message Tracking Access"
New-ManagementRoleAssignment -Role "View-Only Recipients" -SecurityGroup "Exchange Message Tracking Access"

New-ManagementRoleAssignment -Role "Message Tracking" -User zawhtet
New-ManagementRoleAssignment -Role "View-Only Recipients" -User zawhtet

Set-OrganizationConfig -ReadTrackingEnabled $true
Set-Mailbox zawhtet -MessageTrackingReadStatusEnabled $true
Get-OrganizationConfig | fl *read*

test-mailflow
test-servicehealth
test-mapiconnectivity
test-outlookconnectivity
get-mailboxstatistics -server your-mb-svr
get-mailboxstatistics -identity zawhtet
get-mailboxdatabase
get-transportpipeline
Get-ExchangeServer | Format-Table Name, *Version*
Get-ExchangeServer | Format-Table Name, Edition
Get-ExchangeServer -Status | Format-List
Get-ADSite
Get-ADSiteLink
Get-RoutingGroupConnector
Get-RoutingGroupConnector | ft Name,Cost
Set-RoutingGroupConnector -Identity “\\” -Cost 1
Get-offlineaddressbook | fl

Get-Mailbox -resultsize unlimited | Set-CasMailbox -ActiveSyncEnabled:$false

Get-User -OrganizationalUnit "mmx"


Get-WebServicesVirtualDirectory | fl
Get-AutodiscoverVirtualDirectory | fl
Get-OfflineAddressBook | fl
Get-OabVirtualDirectory | fl
Get-OabVirtualDirectory OAB* | fl

Get-ForeignConnector | fl Name,MaxMessageSize
Get-SendConnector | fl Name,MaxMessageSize
Get-ReceiveConnector | fl Name,MaxMessageSize
Get-ADSiteLink | fl Name,MaxMessageSize
Get-RoutingGroupConnector | fl Name,MaxMessageSize
Get-TransportConfig | fl MaxSendSize,MaxReceiveSize
Get-DistributionGroup | fl name,MaxSendSize,MaxReceiveSize
Get-DynamicDistributionGroup | fl name,MaxSendSize,MaxReceiveSize
Get-Mailbox | fl name,MaxSendSize,MaxReceiveSize
Get-MailContact | fl name,MaxSendSize,MaxReceiveSize
Get-MailPublicFolder | fl name,MaxSendSize,MaxReceiveSize
Get-MailUser | fl name,MaxSendSize,MaxReceiveSize

get-transportconfig | fl *

Get-AddressList | Update-Adresslist

set-transportserver you-cas-svr -ExternalPostMasterAddress spamfilter@mmx.com

set-transportconfig -externalpostmasteraddress spamfilter@mmx.com

set-OfflineAddressBook -Identity "Default Offline Address Book" -GlobalWebDistributionEnabled $true


-------------------------------------------------------------------------------------------------------------


TOP 10: Exchange Server 2010 PowerShell Commands

Here you will find a collection of the most commonly used commands I run in Exchange 2010. Enjoy!

1. Check Database Availability Group Replication Status
In some cases you may have many copies of Exchange 2010 databases and you want to view the status of them all. This command will perform that task for you but also show you a very important characteristic such as the content index state.

Get-MailboxDatabaseCopyStatus

2. Fix a Failed Content Index
In rare cases you may notice the content index has failed. Activating a database copy with a failed content index requires additional guidance but to fix the problem beforehand, run the following.

Update-MailboxDatabaseCopy -Identity [id] -CatalogOnly

3. Move a Mailbox in a Batch
There may be cases where you need to keep track of mailbox moves both those which are in progress and to clear them afterward.

New-MoveRequest -Identity [id] -BatchName

4. Check Move Progress
The following command simply gets all the move requests and their statistics.

Get-MoveRequest | Get-MoveRequestStatistics

4. Clear a Move Request
In order to move a mailbox after a move request has completed or failed, you need to remove the request which can be done in bulk, individually, or by a batch name.

Get-MoveRequest | Remove-MoveRequest

or to remove a batch of requests already labeled...

Get-MoveRequest -BatchName [name] | Remove-MoveRequest

5. Determine Unified Messaging Enablement of a User
To check if a user is enabled for Unified Messaging, run the following.

Get-Mailbox | fl UME*

6. View Queues of all Hub Transport Servers
In some cases you may want to quickly view the queue status of all HT servers to determine if you have significant blockage along the transport pipeline.

Get-TransportServer | Get-Queue

7. Determine Active Calls on a UM Server
I find this one helpful as you can quickly see if a server is in use before performing a UM service reset or else use it for troubleshooting to see the status of a test call.

Get-UmServer | Get-UMActiveCalls

8. Determine Exchange Server 2010 Service Status
This command is helpful in quickly seeing which services are running particularly after a reboot.

Get-Service | Where {$_.DisplayName -Like "Microsoft Exchange*"}

9. Get Mailbox Sizes and Sort by Size

Get-Mailbox | Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto

10. Check Autodiscover Settings

Get-WebServicesVirtualDirectory | fl InternalUrl,ExternalUrl
Get-EcpVirtualDirectory | fl InternalUrl,ExternalUrl
Get-OwaVirtualDirectory | fl InternalUrl,ExternalUrl
Get-OabVirtualDirectory | fl InternalUrl,ExternalUrl

Get-ClientAccessServer | fl AutoDiscoverServiceInternalUri

---------------------------------------------------------------

Get-Queue -id Submission | Get-Message | Remove-Message -WithNDR $false

Retry-Queue Submission -Resubmit $true

---------------------------------------------------------------------

How to clear corrupted Messages from the Hub or Edge Submission Queues

If you have ever tried to delete messages stuck in an overflowing Exchange 2007 submission queue you will notice that you can not simply delete the messages as you can for other queues.
In order to clear the Exchange 2007 submission queue you will have to create a new queue database from scratch. This may cause some mail loss but will allow you to get your mail queues functioning properly again.
First you need to be member of the apropriate Security Groups: Local Administrator for Edge Transport Server and Local Administrator+Server Administrator for Hub Transport Server.

Step 1 Stop the Microsoft Exchange Transport service like this:
Computer Management -->Services-->Locate and stop the Microsoft Exchange Transport Service
or from Exchange Managemet Shell type: Stop-Service MSExchangeTransport

Step 2 Navigate to the Queue folder location. By default the folder is located here:
C:\Program Files\Microsoft\Exchange Server\Transport Roles\Data\
Here you will find a folder named Queue .Rename this folder give it a name like Queue2.Create a new empty folder named Queue.

Step3 start the Microsoft Exchange Transport service like this:
Computer Management -->Services-->Locate and start the Microsoft Exchange Transport Service
or from Exchange Managemet Shell type: Start-Service MSExchangeTransport
Confirm mail flows both inbound and out of your server.(In other words the messages from the queues are disappearing.)
--------------------------------------------------------------

Add Position Email Account and Send As in "Outlook"

Add-MailboxPermission -Identity "IT Support" -User "Zaw Htet" -AccessRights FullAccess -InheritanceType All

Add-ADPermission -Identity "IT Support" -User "Zaw Htet" -AccessRights ExtendedRight -ExtendedRights "Send As" 
 


--------------------------------------------------------------
Get-IPBlockListProvider | Test-IPBlockListProvider -IPAddress 24.167.247.129 
--------------------------------------------------------------

Select top 30 mailboxes by totalitemsize

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,TotalItemSize -First 30 


C:\>Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | 
Sort-Object TotalItemSize -Descending | 
Select-Object DisplayName,TotalItemSize -First 100 | Export-CSV top100mailboxes.csv