Advertisement
flashcat666

PS_Unzip_Reddit

Jul 22nd, 2021
1,861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Variables for network paths
  2.  
  3. $path=\\Server1\jobvite
  4. $FinalPath=\\Server1\jobvite\dailyfile
  5. $Processed=\\Server1\jobvite\processed
  6. $ProcessDate= Get-Date
  7. $directory = "$path\*.*";
  8. $wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
  9. $zipFiles = Get-ChildItem -Path $directory -Filter *.zip;
  10.  
  11. Function Create-Jobvite-Doc {
  12.  
  13. #Extracts the ZIP file from JobVite and copies it to dailyfile folder
  14. Expand-Archive -LiteralPath $newpath -DestinationPath $FinalPath -Force
  15.  
  16. #Moves the jobvite file from the extracted folder and drops it in the main dailyfile folder
  17. Move-Item -Path \\Server1\jobvite\dailyfile\dashboard-jobvite_new_employees\*.csv -Destination $FinalPath -Force
  18.  
  19. #Deletes the extracted folder
  20. Remove-Item '\\Server1\jobvite\dailyfile\dashboard-jobvite_new_employees'
  21.  
  22. #Creates a new filename and stores is NAME variable
  23. $Name= (Get-Date -F 'MM-dd-yyyy')
  24.  
  25. #applies new fileNAME to the file
  26. rename-item \\Server1\jobvite\dailyfile\jobvite_new_employees.csv -newname ("jobvite-new-employees-" + $NAME + ".csv")
  27.  
  28. #Moves the jobvite file from the extracted folder and drops it in the main dailyfile folder
  29. Move-Item -Path $newpath -Destination $Processed -Force
  30.  
  31. #Email confirmation for completed file
  32. [....]
  33.  
  34. # Process each file
  35. foreach($zip in $zipFiles) {
  36.     $newpath = "$zip";
  37.     #$wshell.Popup($newpath,0,"Hey!",48+4)
  38.     Create-Jobvite-Doc
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement