PoshCode Logo PowerShell Code Repository

usr mailbox in exch 07 by Pedro Genil 4 years ago
View followups from 92ABAUTISTAW7 | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/3786"></script>download | new post

Sacamos un listado de los mailbox en una organizacion exchange 2007. Y realizamos una compresion del resultado

  1. #Generamos los usuarios por buzon y comprimimos el resultado
  2. #Autor: Pedro Genil
  3. #Fecha: 2012/11/21
  4. #Version: 1.0
  5. # Aņadimos modulo
  6. If ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null)
  7. {
  8.         Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
  9. }
  10. # Creamos el alias para el 7zip
  11. if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe needed"}
  12. set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
  13. #Directorios
  14. $filePath = 'F:\Scripts\users_Acount\'
  15. $fecha = get-date
  16. $fecha= $fecha.toString("yyyyMMdd")
  17. $filedate = $fecha
  18. $info = Get-Mailbox -resultsize unlimited -ignoredefaultscope |select database,displayname,samaccountname,PrimarySmtpAddress,EmailAddresses -expandproperty EmailAddresses | out-file F:\Scripts\users_Acount\$filedate.txt
  19. $files = Get-ChildItem -Recurse -Path $filePath | Where-Object { $_.name -eq "$fecha.txt" }
  20.  
  21. #Cogemos el fichero , y creamos el zip
  22. sz a "F:\Scripts\users_Acount\$fecha.zip" "$filepath\$files"
  23. #Borramos el txt
  24. remove-item "F:\Scripts\users_Acount\$filedate.txt"
  25. #foreach ($file in $files)
  26. #{
  27.  
  28. #                    $name = $file.name
  29. #                    $directory = $file.DirectoryName
  30. #                    sz a "F:\Scripts\users_Acount\$zipfile.zip" "$directory\$name"      
  31.        
  32.  
  33. #}

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me