Tuesday, July 20, 2010

VBS script Copy from source folder to destination by date "last 1 day", remove from source after copy is performed!

All files in C:\Temp\ that are < 1 older than day will be copied to C:\Temp\1\.
in this case i consider C:\Temp\1\ a temporal transition folder should be freed after copy is done.

From_folder = "C:\Temp\"
To_Folder="C:\Temp\1\"

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim folder, file
Dim parts, file_date
Set folder = fso.GetFolder(From_folder)
For Each file in folder.Files
If DateDiff("d", file.DateCreated, Now()) < 1 Then
'MsgBox file.DateCreated
fso.CopyFile From_folder & file.name, To_Folder & file.name
fso.DeleteFile From_folder & file.name, true
End If
next

Tuesday, June 8, 2010

My Exchange PowerShell Comands



Remove disconnected mailboxes
Get-MailboxStatistics -database “GULFSIP-SRV1\"Mailbox Database"” | where {$_.disconnectdate -ne $null} | foreach {Remove-mailbox -database $_.database -storemailboxidentity $_.mailboxguid}



List by size Mailboxes:
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount





BULK IMPORT
Import-csv Big-List-of-users.csv | %{get-mailbox $_.emailAddress | set-mailbox -HiddenFromAddressListsEnabled $true/$false}

Import-Csv contacts.csv | ForEach { New-MailContact -Name $_.displayName -Firstname $_.Firstname -Lastname $_.Lastname -ExternalEmailAddress $_.Emailaddress -OrganizationalUnit "MyDomain.com/Contacts" }

CREATE CERTIFICATION :
New-ExchangeCertificate -GenerateRequest -SubjectName "c=KW, o=GULFGATE, cn=gulfgate.com" -DomainName gulfgate.com, webmail.gulfgate.com -PrivateKeyExportable $true -Path E:\Backup\Configurations\Exchange2007\certrequest2.txt
===========
Thumbprint Services Subject
---------- -------- -------
A8A645B773E790010E8A60AD12117CD086C5F9B9 ..... CN=gulfgate.com, O=GULF...
===========
Import-ExchangeCertificate -path "C:\webmail.DOMAIN.com.crt"

Enable-ExchangeCertificate -Thumbprint A8A645B774E720010E8A60AD12117CD086C5F9B9 -Services:"SMTP, IIS"
CREATING SEND CONECTOR:new-SendConnector -Name 'Send connector to Internet' -Usage 'Internet' -AddressSpaces 'smtp:*;1' -DNSRoutingEnabled $true -UseExternalDNSServersEnabled $false -SourceTransportServers 'gulfsip-01'

DYNAMIC GROUP:
new-DynamicDistributionGroup -Name 'KNPC' -IncludedRecipients 'AllRecipients' -OrganizationalUnit 'gulfsip.kw/Gulf/Gate/KNPC' -Alias 'KNPC' -RecipientContainer 'gulfsip.kw/Gulf/Gate/KNPC'


ENABLE/DISABLE IMAP/POP
==================================================================
Set-CASMailbox -Identity 'Esraa@gulf.com' -PopEnabled $false
Set-CASMailbox -Identity 'Esraa@gulf.com' -IMAPEnabled $false
==================================================================

BULK CONTACT INSERT:
New-MailContact -ExternalEmailAddress 'SMTP:moustafa@gulf.com' -Name 'Mostafa' -OrganizationalUnit 'gulfsip.kw/Gulf/ExternalContacts/GulfSip' -FirstName 'Mostafa' -LastName 'Magdy'

HIDE ALL USERS FROM ADDRESS LIST:
get-mailcontact * | set-mailcontact -hiddenfromaddresslistsenabled $true -ErrorAction SilentlyContinue -ErrorVariable +hidecontactserr;

INSTALL ANTI SPAM AGENT:
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts>.\install-AntispamAgents.ps1

KNOW SEND CONNECTOR DETAILS:Get-SendConnector |fl
Get-EventLogLevel
Set-EventLogLevel -Identity MSExchangeTransport\SmtpSend -Level expert

MAILBOX QUOTA:
http://www.simple-talk.com/sysadmin/powershell/managing-exchange-2007-mailbox-quotas-with-windows-powershell/
Set-Mailbox amir -IssueWarningQuota 3000MB -ProhibitSendQuota 3000MB –UseDatabaseQuotaDefaults $false
Get-MailboxStatistics "ayman@gulf.com" | fl TotalItemSize
Set-Mailbox "ayman@gulf.coM" -IssueWarningQuota 2700MB -ProhibitSendQuota 3000MB –UseDatabaseQuotaDefaults $false

NEW USER:


IF ALREADY EXISTS:

Enable-Mailbox -Identity 'gulf.kw/Users/amany' -Alias 'amany' -Database 'GULFSIP-01\First Storage Group\Mailbox Database'
basma@gulf.com Eng. B
dsadd user CN=Basma,CN=users,DC=gulfsip,DC=kw -samid "Basma" -display "Basma" -pwd BBakry -email basma@gulf.com
Enable-Mailbox -Identity 'gulf.kw/Users/basma' -Alias 'basma' -Database 'GULFSIP-01\First Storage Group\Mailbox Database'

SET SEND SIZE LIMIT:
Get-SendConnector | select gulfsip-01

Get-ReceiveConnector | select gulfsip-01


Set-SendConnector -identity "Send connector to Internet" -MaxMessageSize 30MB

Set-ReceiveConnector -identity "Send connector to Internet" -MaxMessageSize 30MB




Organizational Limits
====================
Set-TransportConfig -MaxReceiveSize 30MB

Set-TransportConfig -MaxSendSize 30MB

Set-ReceiveConnector -identity "Client GULFSIP-01" -MaxMessageSize 30MB

Set-ReceiveConnector -identity "Default GULFSIP-01" -MaxMessageSize 30MB
get-mailbox | set-mailbox -maxsendsize 30MB



OWA TIME OUT:
set-ItemProperty ‘HKLM:\SYSTEM\CurrentControlSet\Services\MSExchangeOWA’ -name TrustedClientTimeout -value 30 -type dword

---------------------------------------------------------------------------
Add a mailbox/contact/mailuser
(e.g. John Doe) to a group (e.g. AllStudents) is:
Add-DistributionGroupMember -Identity AllStudents -Member 'John Doe'
Remove a mailbox/contact/mailuser (e.g. John Doe) from a group (e.g. AllStudents) is:
Remove-DistributionGroupMember -Identity AllStudents -Member 'John Doe



*******************
Trouble Shooting
*******************
Exchange 2010 , Event ID 2501
The site monitor API was unable to verify the site name for this Exchange computer - Call=DsGetSiteNameW Error code=800703e5. Make sure that Exchange server is correctly registered on the DNS server.
---->

Run:
[PS] C:\Windows\system32>nltest /dsgetsite
Getting DC name failed: Status = 1919 0x77f ERROR_NO_SITENAME
[PS] C:\Windows\system32>nltest /server:ServerName /dsgetsite
Getting DC name failed: Status = 1722 0x6ba RPC_S_SERVER_UNAVAILABLE
if you got the above errors , then follow the below:
 
  1. Open RegEdit
  2. Browse to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters
  3. Create a REG_SZ entry with the name SiteName
  4. Set the Value to the site name of the site the Schema Masters in
  5. Restart Netlogon service
  6. Restart MSExchangeADTopology , it will restart all dependent services 
  7. Have Fun :)
 [PS] C:\Windows\system32>nltest /server:HC-01 /dsgetsite
Default-First-Site-Name
The command completed successfully
[PS] C:\Windows\system32>nltest /dsgetsite
Default-First-Site-Name
The command completed successfully
[PS] C:\Windows\system32>

Monday, June 7, 2010

Dsquery / Dsget Active directory

dsquery user -name "Ahmad Sabry El Gendi" | dsget user -title -tel -samid -Email

Sunday, March 21, 2010

156 Useful Run Commands for windows XP

To Access… Run Command
Accessibility Controls access.cpl
Accessibility Wizard accwiz
Add Hardware Wizard hdwwiz.cpl
Add/Remove Programs appwiz.cpl
Administrative Tools control admintools
Adobe Acrobat (if installed) acrobat
Adobe Designer (if installed) formdesigner
Adobe Distiller (if installed) acrodist
Adobe ImageReady (if installed) imageready
Adobe Photoshop (if installed) photoshop
Automatic Updates wuaucpl.cpl
Bluetooth Transfer Wizard fsquirt
Calculator calc
Certificate Manager certmgr.msc
Character Map charmap
Check Disk Utility chkdsk
Clipboard Viewer clipbrd
Command Prompt cmd
Component Services dcomcnfg
Computer Management compmgmt.msc
Control Panel control
Date and Time Properties timedate.cpl
DDE Shares ddeshare
Device Manager devmgmt.msc
Direct X Control Panel (if installed)* directx.cpl
Direct X Troubleshooter dxdiag
Disk Cleanup Utility cleanmgr
Disk Defragment dfrg.msc
Disk Management diskmgmt.msc
Disk Partition Manager diskpart
Display Properties control desktop
Display Properties desk.cpl
Display Properties (w/Appearance Tab Preselected) control color
Dr. Watson System Troubleshooting Utility drwtsn32
Driver Verifier Utility verifier
Event Viewer eventvwr.msc
Files and Settings Transfer Tool migwiz
File Signature Verification Tool sigverif
Findfast findfast.cpl
Firefox (if installed) firefox
Folders Properties folders
Fonts control fonts
Fonts Folder fonts
Free Cell Card Game freecell
Game Controllers joy.cpl
Group Policy Editor (XP Prof) gpedit.msc
Hearts Card Game mshearts
Help and Support helpctr
HyperTerminal hypertrm
Iexpress Wizard iexpress
Indexing Service ciadv.msc
Internet Connection Wizard icwconn1
Internet Explorer iexplore
Internet Properties inetcpl.cpl
Internet Setup Wizard inetwiz
IP Configuration (Display Connection Configuration) ipconfig /all
IP Configuration (Display DNS Cache Contents) ipconfig /displaydns
IP Configuration (Delete DNS Cache Contents) ipconfig /flushdns
IP Configuration (Release All Connections) ipconfig /release
IP Configuration (Renew All Connections) ipconfig /renew
IP Configuration (Refreshes DHCP & Re-Registers DNS) ipconfig /registerdns
IP Configuration (Display DHCP Class ID) ipconfig /showclassid
IP Configuration (Modifies DHCP Class ID) ipconfig /setclassid
Java Control Panel (if installed) jpicpl32.cpl
Java Control Panel (if installed) javaws
Keyboard Properties control keyboard
Local Security Settings secpol.msc
Local Users and Groups lusrmgr.msc
Logs You Out Of Windows logoff
Malicious Software Removal Tool mrt
Microsoft Access (if installed) msaccess
Microsoft Chat winchat
Microsoft Excel (if installed) excel
Microsoft Frontpage (if installed) frontpg
Microsoft Movie Maker moviemk
Microsoft Paint mspaint
Microsoft Powerpoint (if installed) powerpnt
Microsoft Word (if installed) winword
Microsoft Syncronization Tool mobsync
Minesweeper Game winmine
Mouse Properties control mouse
Mouse Properties main.cpl
Nero (if installed) nero
Netmeeting conf
Network Connections control netconnections
Network Connections ncpa.cpl
Network Setup Wizard netsetup.cpl
Notepad notepad
Nview Desktop Manager (if installed) nvtuicpl.cpl
Object Packager packager
ODBC Data Source Administrator odbccp32.cpl
On Screen Keyboard osk
Opens AC3 Filter (if installed) ac3filter.cpl
Outlook Express msimn
Paint pbrush
Password Properties password.cpl
Performance Monitor perfmon.msc
Performance Monitor perfmon
Phone and Modem Options telephon.cpl
Phone Dialer dialer
Pinball Game pinball
Power Configuration powercfg.cpl
Printers and Faxes control printers
Printers Folder printers
Private Character Editor eudcedit
Quicktime (If Installed) QuickTime.cpl
Quicktime Player (if installed) quicktimeplayer
Real Player (if installed) realplay
Regional Settings intl.cpl
Registry Editor regedit
Registry Editor regedit32
Remote Access Phonebook rasphone
Remote Desktop mstsc
Removable Storage ntmsmgr.msc
Removable Storage Operator Requests ntmsoprq.msc
Resultant Set of Policy (XP Prof) rsop.msc
Scanners and Cameras sticpl.cpl
Scheduled Tasks control schedtasks
Security Center wscui.cpl
Services services.msc
Shared Folders fsmgmt.msc
Shuts Down Windows shutdown
Sounds and Audio mmsys.cpl
Spider Solitare Card Game spider
SQL Client Configuration cliconfg
System Configuration Editor sysedit
System Configuration Utility msconfig
System File Checker Utility (Scan Immediately) sfc /scannow
System File Checker Utility (Scan Once At The Next Boot) sfc /scanonce
System File Checker Utility (Scan On Every Boot) sfc /scanboot
System File Checker Utility (Return Scan Setting To Default) sfc /revert
System File Checker Utility (Purge File Cache) sfc /purgecache
System File Checker Utility (Sets Cache Size to size x) sfc /cachesize=x
System Information msinfo32
System Properties sysdm.cpl
Task Manager taskmgr
TCP Tester tcptest
Telnet Client telnet
Tweak UI (if installed) tweakui
User Account Management nusrmgr.cpl
Utility Manager utilman
Windows Address Book wab
Windows Address Book Import Utility wabmig
Windows Backup Utility (if installed) ntbackup
Windows Explorer explorer
Windows Firewall firewall.cpl
Windows Magnifier magnify
Windows Management Infrastructure wmimgmt.msc
Windows Media Player wmplayer
Windows Messenger msmsgs
Windows Picture Import Wizard (need camera connected) wiaacmgr
Windows System Security Tool syskey
Windows Update Launches wupdmgr
Windows Version (to show which version of windows) winver
Windows XP Tour Wizard tourstart
Wordpad write

Tuesday, February 16, 2010

Delete Scheduled files every 2 weeks in linux Centos

find /var/spool/asterisk/monitor/ -mtime +12 -type f -exec rm -rf {} \;

Saturday, February 13, 2010

Debian isn't showing all my ram! Debian can't read all RAM x32 on x64 machine

But there's a problem; you ordered your system with 4 GB of RAM but you are only able to see 2. Well this may just be an issue with the default Debian kernel.
Section 1: Checking available RAM

1. First thing's first, how much RAM does your system believe that it has available?

toystory:~# free -m
total used free shared buffers cached
Mem: 1012 44 968 0 3 22
-/+ buffers/cache: 18 994
Swap: 94 0 94

2. You can also check the server physically to see what sort of RAM is actually installed if you have lshw installed. Let's install it and take a look:

toystory:~# apt-get install lshw
. . . installation of package should go okay here . . .
toystory:~# lshw -C memory

As with any command you will receive a fair amount of information that you were not necessarily looking for. The section that you are interested in will look something like this:

*-bank:0
description: DIMM Synchronous 333 MHz (3.0 ns)
product: PartNum0
vendor: Manufacturer0
physical id: 0
serial: SerNum0
slot: DIMM0
size: 1GB
width: 64 bits
clock: 333MHz (3.0ns)
*-bank:1
description: DIMM Synchronous 333 MHz (3.0 ns)
product: PartNum1
vendor: Manufacturer1
physical id: 1
serial: SerNum1
slot: DIMM1
size: 1GB
width: 64 bits
clock: 333MHz (3.0ns)
*-bank:2
description: DIMM Synchronous 333 MHz (3.0 ns)
product: PartNum1
vendor: Manufacturer1
physical id: 1
serial: SerNum2
slot: DIMM1
size: 1GB
width: 64 bits
clock: 333MHz (3.0ns)
*-bank:3
description: DIMM Synchronous 333 MHz (3.0 ns)
product: PartNum1
vendor: Manufacturer1
physical id: 1
serial: SerNum3
slot: DIMM1
size: 1GB
width: 64 bits
clock: 333MHz (3.0ns)

This should list the sticks of RAM that are actually installed to the system. Looks like 4 separate sticks of 1 GB RAM installed to me. Let's move on to solving this problem.
Section 2: The Bigmem Kernel
Due to some optimizations made at the kernel level of Linux there are a few different "maximum memory" specifications that are set to achieve maximum performance, but you are probably most concerned about getting to your RAM immediately, so let's get to that. The first thing that you need to do is install the "bigmem" kernel package if it is not already installed. Our default installations of Debian come with this installed so you should not need to do this, but just in case take the following steps.
1. Check to see if the kernel is already installed. If something like linux-image-2.6-686-bigmem shows up here, then skip down to Section 3 because you're all set

toystory:~# dpkg --get-selections | grep bigmem

2. Go ahead and install the package

toystory:~# apt-get install linux-image-2.6-686-bigmem

3. Check to make sure it's installed okay.

toystory:~# dpkg --get-selections | grep bigmem
linux-image-2.6-686-bigmem install
toystory:~#

That's all there is to the installation for our purposes. Custom kernel compilation is outside of the scope of this article.
Section 3: Configuring Grub
By default our installations of Debian use the grub bootloader. If you have not made any changes, a command like this will tell you what kernels you have configured within grub.

toystory:~# grep "Debian GNU" /boot/grub/menu.lst | nl -v0
0 title Debian GNU/Linux, kernel 2.6.18-5-k7
1 title Debian GNU/Linux, kernel 2.6.18-5-k7 (single-user mode)
2 title Debian GNU/Linux, kernel 2.6.18-5-686-bigmem
3 title Debian GNU/Linux, kernel 2.6.18-5-686-bigmem (single-user mode)
4 title Debian GNU/Linux, kernel 2.6.18-4-k7
5 title Debian GNU/Linux, kernel 2.6.18-4-k7 (single-user mode)

We want to use our bigmem kernel (not in single user mode of course) so we'll need to update the "default" entry in grub's configuration file.
1. So what is the current default entry?

toystory:~# grep ^default /boot/grub/menu.lst
default 0

2. So open your favorite text editor and find the line that says "default #" and change it to the number that you found above. Here we are in vi:
3. Now all you have to do is reboot. So give it a go and reboot to see what happens!

Thursday, February 11, 2010

Install Brekeke Advanced SIP on linux Debian!

first add deb http://ftp.nl.debian.org/debian/ lenny main contrib non-free

to /etc/apt-sources.list

then follow up this simple steps:
1- wget http://mirror.cc.columbia.edu/pub/software/apache/tomcat/tomcat-5/v5.5.28/bin/apache-tomcat-5.5.28.tar.gz

2- apt-cache search java | grep jdk

3- apt-get install sun-java6-jdk

4- tar -xzvf apache-tomcat-6.0.24.tar.gz

5- mkdir /usr/local/tomcat5.5

6- gulfsip:/home/downs# mv apache-tomcat-5.5.28 /usr/local/

7- gulfsip:/usr/local/tomcat5.5# mv apache-tomcat-5.5.28/ tomcat5.5

8- export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.12
export PATH=/usr/lib/jvm/java-6-sun-1.6.0.12/bin:$PATH

9- Start tomcat /usr/local/tomcat5.5/bin/./startup.sh

10- copy the proxy.war file into: /usr/local/tomcat5.5/webapps

11- Make sure Tomcat is running: http://X.X.X.X:8080/

12- run the SIP server: http://X.X.X.X:8080/proxy