Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#----------------------------------------------------------------------------------------------------------------------------
- August 2017 - Robin Beismann - Michael Wessel Informationstechnologie GmbH
- This script copys the CRLs from the different sites onto the DMZ Webserver(s)
- config.xml may look like:
- <Config>
- <source share="<to be filled>" username="<to be filled>" password="<to be filled>"/>
- <destination share="<to be filled>" username="<to be filled>" password="<to be filled>"/>
- <destination share="<to be filled>" username="<to be filled>" password="<to be filled>"/>
- </Config>
- ----------------------------------------------------------------------------------------------------------------------------#>
- $curDir = (Get-Location).Path
- $tempDir = $curDir + "\temp"
- $sourceMap = "i:"
- $destMap = "u:"
- #######################################################################################################################
- ########################################### Do not modify below #######################################################
- #######################################################################################################################
- #Define Varaibles
- [xml]$config = Get-Content -Path ($curDir + "\config.xml")
- $sources = $config.Config.source
- $destinations = $config.Config.destination
- #Check if Temp Directory exists (unclean script ending)
- if(Test-Path($tempDir)){
- Remove-Item -Path $tempDir -Force -Confirm:$false -Recurse
- }
- #Create temp directory
- New-Item -Path $tempDir -ItemType Directory
- #Retrieve source files
- foreach($source in $sources){
- #Map network drive
- $net = New-Object -ComObject WScript.Network
- $net.MapNetworkDrive($sourceMap, $source.share, $false, $source.username, $source.password)
- #Copy Items
- Get-ChildItem -Path ($sourceMap + "\*") -Include "*.crl" | ForEach-Object {
- Copy-Item -Path $_.FullName -Destination $tempDir -Force -Confirm:$false
- }
- #Unmap network drive
- $net.RemoveNetworkDrive($sourceMap,$true)
- }
- #Copy to destination(s)
- foreach($destination in $destinations){
- #Map network drive
- $net = New-Object -ComObject WScript.Network
- $net.MapNetworkDrive($destMap, $destination.share, $false, $destination.username, $destination.password)
- #Copy Items
- Get-ChildItem -Path ($tempDir + "\*") -Include "*.crl" | ForEach-Object {
- Copy-Item -Path $_.FullName -Destination ($destMap + "\") -Force -Confirm:$false
- }
- #Unmap network drive
- $net.RemoveNetworkDrive($destMap,$true)
- }
- #Remove temp directory
- Remove-Item -Path $tempDir -Force -Confirm:$false -Recurse
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement