Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. <#----------------------------------------------------------------------------------------------------------------------------
  2. August 2017 - Robin Beismann - Michael Wessel Informationstechnologie GmbH
  3.  
  4. This script copys the CRLs from the different sites onto the DMZ Webserver(s)
  5.  
  6. config.xml may look like:
  7.  
  8. <Config>
  9. <source share="<to be filled>" username="<to be filled>" password="<to be filled>"/>
  10. <destination share="<to be filled>" username="<to be filled>" password="<to be filled>"/>
  11. <destination share="<to be filled>" username="<to be filled>" password="<to be filled>"/>
  12. </Config>
  13. ----------------------------------------------------------------------------------------------------------------------------#>
  14.  
  15. $curDir = (Get-Location).Path
  16. $tempDir = $curDir + "\temp"
  17. $sourceMap = "i:"
  18. $destMap = "u:"
  19.  
  20. #######################################################################################################################
  21. ########################################### Do not modify below #######################################################
  22. #######################################################################################################################
  23.  
  24. #Define Varaibles
  25. [xml]$config = Get-Content -Path ($curDir + "\config.xml")
  26. $sources = $config.Config.source
  27. $destinations = $config.Config.destination
  28.  
  29. #Check if Temp Directory exists (unclean script ending)
  30. if(Test-Path($tempDir)){
  31. Remove-Item -Path $tempDir -Force -Confirm:$false -Recurse
  32. }
  33. #Create temp directory
  34. New-Item -Path $tempDir -ItemType Directory
  35.  
  36. #Retrieve source files
  37. foreach($source in $sources){
  38. #Map network drive
  39. $net = New-Object -ComObject WScript.Network
  40. $net.MapNetworkDrive($sourceMap, $source.share, $false, $source.username, $source.password)
  41.  
  42. #Copy Items
  43. Get-ChildItem -Path ($sourceMap + "\*") -Include "*.crl" | ForEach-Object {
  44. Copy-Item -Path $_.FullName -Destination $tempDir -Force -Confirm:$false
  45. }
  46.  
  47. #Unmap network drive
  48. $net.RemoveNetworkDrive($sourceMap,$true)
  49. }
  50.  
  51. #Copy to destination(s)
  52. foreach($destination in $destinations){
  53. #Map network drive
  54. $net = New-Object -ComObject WScript.Network
  55. $net.MapNetworkDrive($destMap, $destination.share, $false, $destination.username, $destination.password)
  56.  
  57. #Copy Items
  58. Get-ChildItem -Path ($tempDir + "\*") -Include "*.crl" | ForEach-Object {
  59. Copy-Item -Path $_.FullName -Destination ($destMap + "\") -Force -Confirm:$false
  60. }
  61.  
  62. #Unmap network drive
  63. $net.RemoveNetworkDrive($destMap,$true)
  64. }
  65.  
  66. #Remove temp directory
  67. Remove-Item -Path $tempDir -Force -Confirm:$false -Recurse
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement