Category Archives: Scripts

Export mailboxes to pst Exchange 2010

This little script if for export mailboxes to a pst files form an Exchange 2010 SP1 or SP2  or SP3

to change:

  • e:\exchange –>path to export pst files (\\server2k\e$\Exchange)
  • F:\Exchange\bin ->path to exe of Exchange
  • F:\backup –>path to ps script

first, assing role to users administrator

New-ManagementRoleAssignment –Role "Mailbox Import Export" –User Administrator

 the script:

</p>
'F:\Exchange\bin\RemoteExchange.ps1';
Connect-ExchangeServer -auto;
Remove-Item <a href="file:///\\murano\F\Exchange\*.pst">\\murano\F\Exchange\*.pst</a> -recurse;
Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest -confirm:$false;
Get-MailboxExportRequest | where {$_.status -eq "Failed"} | Remove-MailboxExportRequest -confirm:$false;
foreach ($i in (Get-Mailbox))
	{ New-MailboxExportRequest -Mailbox $i -FilePath "<a href="file:///\\murano\F\Exchange\$($i.Alias).pst">\\murano\F\Exchange\$($i.Alias).pst</a>"  -baditemlimit 200 -AcceptLargeDataLoss }

then, create one new scheduled task:

 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

with this parameters:

 

-version 2.0  -command “. ‘F:\Exchange\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto;. ‘F:\backup\exportmailboxes.ps1′”

{jcomments on}

Facebooktwitterredditpinterestlinkedinmail

Read More ...

Stop Exchange 2007 or 2003 and make a backup for files

An easy way to make a backup exchange 2007 or 2003 is to stop services:

<p>There are various systems to stop the services and copy the Exchange database, this method of copying is widely used, since natively Exchange 2010 and 2007 support only copies of the units through snapshots or need third-party applications.</p>
<p>The first would be a file. Bat for Exchange 2003 in this case the databases are in<strong> X:\dades exchange </strong>and copied to the location:&nbsp;<strong>x:\copia exchange\ExchangeOfflineBackup</strong>, you can adapt it to your convenience:</p>

net stop MSExchangeES
net stop IMAP4Svc
net stop POP3Svc
net stop RESvc
net stop MSExchangeIMC
net stop MSExchangeSRS
net stop MSExchangeMGMT
net stop MSExchangeMTA
net stop MSExchangeIS /Y
net stop MSExchangeSA /Y
xcopy "X:\dades exchange\*" "x:\copia exchange\ExchangeOfflineBackup" /E /D /V /C /I /F /H /R /K /O /Y
net start MSExchangeSA /Y
net start MSExchangeIS /Y
net start MSExchangeMTA
net start MSExchangeMGMT
net start MSExchangeSRS
net start MSExchangeIMC
net start RESvc
net start POP3Svc
net start IMAP4Svc
net start MSExchangeES

<p>&nbsp;</p>
<p>this one. bat, it would be for Exchange 2007 2010 is that I think works best, in this case the databases are in<strong> X:\dades exchange </strong>and copied to the location:&nbsp;<strong>x:\copia exchange\ExchangeOfflineBackup</strong>,you can adapt it to your convenience:</p>

Echo 'Stopping Microsoft Exchange Services'
net stop MSExchangeAB /Y
net stop MSExchangeADTopology /Y
net stop MSExchangeAntispamUpdate
net stop MSExchangeEdgeSync
net stop MSExchangeFBA
net stop MSExchangeFDS
net stop MSExchangeIS
net stop MSExchangeMailboxAssistants
net stop MSExchangeMailboxReplication
net stop MSExchangeMailSubmission
net stop MSExchangeProtectedServiceHost
net stop MSExchangeRepl
net stop MSExchangeRPC
net stop MSExchangeSA
net stop MSExchangeSearch
net stop MSExchangeServiceHost
net stop MSExchangeThrottling
net stop MSExchangeTransport
net stop MSExchangeTransportLogSearch
xcopy "X:\dades exchange\*" "x:\copia exchange\ExchangeOfflineBackup" /E /D /V /C /I /F /H /R /K /O /Y
<div>Echo 'Starting Microsoft Exchange Services'</div>
net start MSExchangeAB
net start MSExchangeADTopology
net start MSExchangeAntispamUpdate
net start MSExchangeEdgeSync
net start MSExchangeFBA
net start MSExchangeFDS
net start MSExchangeIS
net start MSExchangeMailboxAssistants
net start MSExchangeMailboxReplication
net start MSExchangeMailSubmission
net start MSExchangeProtectedServiceHost
net start MSExchangeRepl
net start MSExchangeRPC
net start MSExchangeSA
net start MSExchangeSearch
net start MSExchangeServiceHost
net start MSExchangeThrottling
net start MSExchangeTransport
net start MSExchangeTransportLogSearch
Facebooktwitterredditpinterestlinkedinmail

Read More ...

Delete files older than X days

this simple script ,shows how to delete files in a directory, older than 30 days old.

In this case delete the files that begin with “Backup” for more than 30 days from the directory D:\Backup

' ################################################################
' # cleanup-folder.vbs
' #
' # Removes all files older than 1 week
' # Authored by Jordi Colomé
' # Based on code by YellowShoe
' # Version 1.0 - Sept 23 2008
' ################################################################

Dim fso, f, f1, fc, strComments, strScanDir
' user variables
' —————————————————————-
strDir = "D:\Backup"
strDays = 30
' DO NOT EDIT BELOW THIS LINE
' (unless you know what you are doing)
'——————————————————————
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strDir)
Set fc = f.Files

For Each f1 in fc
      If DateDiff("d", f1.DateCreated, Date) >strDays and (Left(f1.Name, 6) = "Backup")   Then
            fso.DeleteFile(f1)
      End If
Next
'wscript.echo strComments
WScript.Quit
' eof
Facebooktwitterredditpinterestlinkedinmail

Read More ...

Export Active Directory information

Many times we want to export information from Active Directory, to such an excel. To this end a very useful tool is the command CSVDE:

to see how it works it’s best to give some examples:

CSVDE -f usuarios.csv

Exports the object type ‘user’ and ‘computer’ Active Directory to a csv file

CSVDE -d “OU=Ejemplo,dc=es” r objectCategory=person -f usuarios.csv

Exports only objects ejemplo.es domain user type

CSVDE -f usuarios.csv -r “(&(objectClass=user)(sn=Pe*))”

Export users only objects where the name starts with “Pe” the “&” indicates a start logical “AND”

CSVDE -f usuarios.csv -r” (|(useraccountcontrol=20)(useraccountcontrol=30)(useraccountcontrol=333))”

Exports only objects where the userAccountControl field is equal to 20 or 30 or 333, the operator “|” indicates the logical initial “O”

CSVDE -f usuarios.csv  -l “DN, objectclass, objectcategory, givenName, sn”

Exports only the selected columns to see all selectable attributes of an object such person, a very useful page is:

Microsoft ldap person reference

 

 

Facebooktwitterredditpinterestlinkedinmail

Read More ...

Categories

Subscribe to my Newsletter




By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close