Nice DOTNETZIP Integration with PowerShell

Let me share a script I built two years ago, and I just created a function for it named “New-ZipFile“. Basically, this PowerShell function script will create a blank zipped file and copy the files to it. At the same time if you run it again (after updating an existing file) will overwrite the file any existing files previously on the existing zipfile. Also, there’s no prompt.

This is an example of what PowerShell can provide at an excellent tool for providing creative solutions. Also the community is very active is helping everyone.

I agree that sometime is not easy but definitely not impossible. And there’s lots of other possible good alternative. But, using PowerShell let you customized your solution with an opportunity for enhancements giving you some level of control over what you want to accomplish.

I’m using the DOTNETZIP from Codeplex for this example. By the way, they provide good documentation on how to use the API’s. (hint: copy all the “Tools” folder to “Program Files (x86)\DotNetZip\..” folder)

You can download DOTNETZIP at the following link: http://dotnetzip.codeplex.com/

Here’s the sample script. Just change the variables values to your need, and make it your own:

[sourcecode language=”powershell”]
## – Beginning of Script:
Function New-ZipFile{
PARAM
(
[String] $SrcFolder,
[String] $DestFolder,
[string] $DestZipName,
[String] $FileExtToZip,
[string] $ZipPurpose,
[string] $StoredInZipFolder,
[string] $DeleteFiles = $null
)
#$TodaysDate = Get-Date -uformat "%Y-%m-%d-%Hh%Mm%Ss.zip";
#$ZipFileName = $ZipPurpose + "_" +$DestZipName + "_" + $TodaysDate;
$ZipFileName = $ZipPurpose + "_" +$DestZipName + ".zip";

if (Test-Path $DestFolder){
## – Create Zip file or it won’t work:
if (Test-Path ($DestFolder+"\"+$ZipFileName)) { del ($DestFolder+"\"+$ZipFileName) }
new-item ($DestFolder+"\"+$ZipFileName) -ItemType File
}
else
{
Write-Host "Destination Folder [$DestFolder] doesn’t exist" -ForegroundColor ‘Yellow’;
Break;
};

## – Loads the Ionic.Zip assembly:
[System.Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\DotNetZip\Ionic.Zip.dll") |

out-null;
$zipfile = new-object Ionic.Zip.ZipFile

## – AddSelectedFiles with source folder path:
## – ($false grab files in source folder) & ($true grab files & subfolder files)
$zipfile.AddSelectedfiles($FileExtToZip,$SrcFolder,$true) | Out-Null;
## – UseZip64WhenSaving, when needed, will create a temp file compress large number of files:
$Zipfile.UseZip64WhenSaving = ‘AsNecessary’
$zipfile.Save($DestFolder+"\"+$ZipFileName)
$zipfile.Dispose()

If ($DeleteFiles.ToUpper() -eq ‘YES’){
## – Remove all backed up files:
Write-Host "Deleting files after zip!";
get-childitem ($SrcFolder+"\"+$FileExtToZip) | remove-item
}
};

### – variables:
$DestZipName = "BackupMyTempSSIS";
$FileExtToZip = "name = *.*";
$DestFolder = "C:\MyBackupZipFolder";
$SrcFolder = "C:\TempSSIS";
$DeleteFiles = $null;
$StoredInZipFolder = "MyBackupZip\";
$ZipPurpose = "BackUp";
#or $ZipPurpose = "Save";

New-ZipFile -DeleteFiles $DeleteFiles `
-DestFolder $DestFolder -DestZipName $DestZipName `
-FileExtToZip $FileExtToZip -SrcFolder $SrcFolder `
-StoredInZipFolder $StoredInZipFolder -ZipPurpose $ZipPurpose;

## – End of Script
[/sourcecode]

This is about having flexibility over what you want to do.  This is a good example how you can use an existing API with PowerShell.  As long there’s good API documentation then the rest just follows thru.

DotNETzip_APIDoc

In the above sample script you can have is Scheduled in either Task Scheduler or in SQL Server Agent. This code becomes portable.

This script the folder for the zipped file most exist or it will display a message that the folder doesn’t exist, and has the ability to delete the files after its done. (feel free to modify)

I hope you’ll find it useful!

Maximo Trinidad (MVP – Windows PowerShell)
Mr. PowerShell

372 thoughts on “Nice DOTNETZIP Integration with PowerShell

  1. Pingback: slcshop.top
  2. Pingback: upmusic.icu
  3. Pingback: we-b-tv.com
  4. Pingback: hs;br
  5. Pingback: tureckie_serialy_na_russkom_jazyke
  6. Pingback: tureckie_serialy
  7. Pingback: 2020
  8. Pingback: kpop+star+season+6+ep+9
  9. Pingback: Video
  10. Pingback: +1+
  11. Pingback: 1 2 3 4 5 6 7 8 9 10
  12. Pingback: wwin-tv.com
  13. Pingback: pornvideo
  14. Pingback: buy cialis
  15. Pingback: cheap viagra
  16. Pingback: buy sildenafil
  17. Pingback: buy cialis
  18. Pingback: buy viagra online
  19. Pingback: ou trouver viagra sans ordonnance
  20. Pingback: buy viagra
  21. Pingback: cheap ed pills
  22. Pingback: Cheap Erection Pills
  23. Pingback: cialis online
  24. Pingback: generic cialis buy
  25. Pingback: buy cialis overnight
  26. Pingback: cialis online
  27. Pingback: generic cialis buy
  28. Pingback: buy cialis overnight
  29. Pingback: buy cialis
  30. Pingback: cialis miami
  31. Pingback: buy amoxicillin
  32. Pingback: 5mg cialis
  33. Pingback: payday loans online fast deposit
  34. Pingback: buy levitra in australia
  35. Pingback: the best custom essay writing service
  36. Pingback: personal loans
  37. Pingback: cheap cialis online pharmacy
  38. Pingback: buy viagra sydney
  39. Pingback: ed drugs cialis
  40. Pingback: cialis ordering australia
  41. Pingback: Testing60
  42. Pingback: Testing61
  43. Pingback: cialis 20mg for sale
  44. Pingback: buy cialis online europe
  45. Pingback: cheapest generic cialis australia
  46. Pingback: where can i buy cialis without a prescription
  47. Pingback: cialis 20mg low price
  48. Pingback: cialis 20mg for sale
  49. Pingback: buy cialis cheaper online
  50. Pingback: cialis 20 mg cost
  51. Pingback: where can i buy cialis without a prescription
  52. Pingback: buy cialis 36 hour
  53. Pingback: axvgcqus
  54. Pingback: buy cialis online generic
  55. Pingback: where to buy cheap viagra online
  56. Pingback: hoe vaak viagra
  57. Pingback: what is the azithromycin combination
  58. Pingback: cialis sale 20mg
  59. Pingback: generic cialis 20 mg tadalafil
  60. Pingback: cialis
  61. Pingback: viagra from canada
  62. Pingback: buy cialis without perscription
  63. Pingback: cialis 20mg low price
  64. Pingback: viagra sin receta espaГ±a
  65. Pingback: buy cialis toronto
  66. Pingback: order original cialis online
  67. Pingback: uk custom essay writing service
  68. Pingback: online research paper writer
  69. Pingback: who can write my essay
  70. Pingback: generic cialis 20 mg tadalafil
  71. Pingback: help with essay writing
  72. Pingback: find cheap cialis online
  73. Pingback: buy cialis canadian
  74. Pingback: generic cialis 20 mg tadalafil
  75. Pingback: generic cialis 20 mg tadalafil
  76. Pingback: amoxicillin 800 mg
  77. Pingback: furosemide 40mg tab without prescription
  78. Pingback: azithromycin in usa
  79. Pingback: stromectol buy
  80. Pingback: buy combivent from canada
  81. Pingback: Google
  82. Pingback: doxycycline vibramycin
  83. Pingback: prednisolone 20 mg
  84. Pingback: clomid only cycle
  85. Pingback: dapoxetine india price
  86. Pingback: diflucan pill
  87. Pingback: zoloft and synthroid
  88. Pingback: propecia 1mg online
  89. Pingback: how much neurontin
  90. Pingback: diabetes drugs metformin
  91. Pingback: paxil vs.xanax
  92. Pingback: plaquenil en espaГ±ol
  93. Pingback: buy cheap metformin
  94. Pingback: buy cialis online in canada
  95. Pingback: cialis tadalafil portugal
  96. Pingback: Zakhar Berkut hd
  97. Pingback: buy cialis insurance
  98. Pingback: payday loan yes irving
  99. Pingback: retin a cream online hong kong
  100. Pingback: cash advance usa baytown
  101. Pingback: buy canadian
  102. Pingback: where can i buy ativan in canada
  103. Pingback: buy amoxil online
  104. Pingback: lasix drug price
  105. Pingback: buy gabapentin no rx
  106. Pingback: buy plaquenil cheap
  107. Pingback: prednisone 172
  108. Pingback: avana pills
  109. Pingback: provigil online buy
  110. Pingback: buy ivermectin uk
  111. Pingback: albuterol 3 mg
  112. Pingback: azithromycin
  113. Pingback: furosemide 20 mg drug
  114. Pingback: neurontin prices
  115. Pingback: plaquenil toxicity
  116. Pingback: deltasone pill
  117. Pingback: dapoxetine usa buy
  118. Pingback: modafinil vs nuvigil
  119. Pingback: cost of ivermectin
  120. Pingback: ventolin pharmacy uk
  121. Pingback: zithromax 250 mg
  122. Pingback: canada pharmacy
  123. Pingback: india ivermectin
  124. Pingback: buy stromectol uk
  125. Pingback: best tadalafil
  126. Pingback: online generic viagra india
  127. Pingback: generic viagra online
  128. Pingback: stromectol 0 5 mg
  129. Pingback: ivermectin lice oral
  130. Pingback: history of ivermectin
  131. Pingback: buy ventolin inhaler at asda
  132. Pingback: flcc blackboard login
  133. Pingback: flcc covid protocol
  134. Pingback: olumiant 1mg
  135. Pingback: olumiant generic
  136. Pingback: generic aralen
  137. Pingback: merck antiviral
  138. Pingback: pharmacy
  139. Pingback: Anonymous
  140. Pingback: new covid drug
  141. Pingback: side effects of ivermectin in humans
  142. Pingback: moinupiravir
  143. Pingback: Anonymous
  144. Pingback: stromectol oral
  145. Pingback: ivermectin over the counter
  146. Pingback: ivermectin 3mg tab
  147. Pingback: Anonymous
  148. Pingback: ivermectin online
  149. Pingback: ivermectin
  150. Pingback: how to get ivermectin
  151. Pingback: where can i buy ivermectin
  152. Pingback: where to buy ivermectin
  153. Pingback: ignition casino sign in
  154. Pingback: ivermectin tablets for sale
  155. Pingback: order prednisone 10mg without prescription
  156. Pingback: otc cialis
  157. Pingback: tadalafil order online
  158. Pingback: ivermectin 5 mg
  159. Pingback: viagra
  160. Pingback: ivermectin pills human
  161. Pingback: generic cialis buy uk
  162. Pingback: cheapest generic viagra online
  163. Pingback: ivermectin canada
  164. Pingback: generic cialis singapore
  165. Pingback: buy cheap generic cialis online
  166. Pingback: cialis without prescription
  167. Pingback: sildenafil tablets
  168. Pingback: cialis generic medication
  169. Pingback: can i buy generic cialis
  170. Pingback: buy stromectol online
  171. Pingback: cheap sildenafil 100mg
  172. Pingback: sildenafil citrate tablets
  173. Pingback: cialis tadalafil
  174. Pingback: generic cialis walgreens price
  175. Pingback: buy prednisone liquid
  176. Pingback: tadalafil without a doctor prescription
  177. Pingback: 20 mg prednisone 20mg
  178. Pingback: meds for covid
  179. Pingback: can you buy generic cialis in canada
  180. Pingback: levitra vs cialis
  181. Pingback: ivermectin usa price
  182. Pingback: prednisone side effects in men
  183. Pingback: cialis online
  184. Pingback: sildenafil costs
  185. Pingback: online casino real money no deposit
  186. Pingback: buy tadalafil online
  187. Pingback: iver mectin
  188. Pingback: over the counter ivermectin
  189. Pingback: ivermectine et covid
  190. Pingback: real money casino games
  191. Pingback: where to buy cialis
  192. Pingback: cialis coupon
  193. Pingback: generic viagra india
  194. Pingback: cheap tadalafil
  195. Pingback: stromectol stay active
  196. Pingback: ivermectin generic name
  197. Pingback: buy stromectol
  198. Pingback: dengue ivermectin
  199. Pingback: ivermectin 0.5
  200. Pingback: luckylands
  201. Pingback: ivermectin 0.1
  202. Pingback: covid ivermectin
  203. Pingback: ivermectin for animals
  204. Pingback: ivermectin goodrx
  205. Pingback: does ivermectin work
  206. Pingback: how much does ivermectin cost
  207. Pingback: mazhor4sezon
  208. Pingback: filmfilmfilmes
  209. Pingback: gRh9UPV
  210. Pingback: buy stromectol 12mg
  211. Pingback: 9-05-2022
  212. Pingback: kinoteatrzarya.ru
  213. Pingback: TopGun2022
  214. Pingback: Xvideos
  215. Pingback: XVIDEOSCOM Videos
  216. Pingback: XVIDEOS video XVideos xv XVIDEOS
  217. Pingback: xvideos videos
  218. Pingback: xvideo
  219. Pingback: ivanesva
  220. Pingback: how much is generic cialis at walmart
  221. Pingback: Netflix
  222. Pingback: Zvezdy-v-Afrike-2-sezon-14-seriya
  223. Pingback: Krylya-nad-Berlinom
  224. Pingback: FILM
  225. Pingback: designchita.ru
  226. Pingback: YA-krasneyu
  227. Pingback: design-human.ru
  228. Pingback: designmsu.ru
  229. Pingback: vkl-design.ru
  230. Pingback: irida-design.ru
  231. Pingback: Intimsiti-v-obhod-blokirovok
  232. Pingback: stromectol order online
  233. Pingback: projectio
  234. Pingback: ivermectin 8 mg
  235. Pingback: moskva psiholog online
  236. Pingback: online moskva psiholog
  237. Pingback: online moskva
  238. Pingback: psy online
  239. Pingback: Gz92uNNH
  240. Pingback: do-posle-psihologa
  241. Pingback: uels ukrain
  242. Pingback: ivermectin buy nz
  243. Pingback: DPTPtNqS
  244. Pingback: qQ8KZZE6
  245. Pingback: D6tuzANh
  246. Pingback: http://bit.ly/odna-film
  247. Pingback: https://ria.ru/20100906/272903623.html
  248. Pingback: SHKALA TONOV
  249. Pingback: Øêàëà òîíîâ
  250. Pingback: russianmanagement.com
  251. Pingback: chelovek-iz-90-h
  252. Pingback: 3Hk12Bl
  253. Pingback: 3NOZC44
  254. Pingback: 01211
  255. Pingback: tor-lyubov-i-grom
  256. Pingback: film-tor-2022
  257. Pingback: hd-tor-2022
  258. Pingback: hdorg2.ru
  259. Pingback: ivermectin lotion for lice
  260. Pingback: Psikholog
  261. Pingback: Psychologists
  262. Pingback: netstate.ru
  263. Pingback: https://bit.ly/psikholog-muzhchina-onlayn
  264. Pingback: Link
  265. Pingback: ivermectin trial
  266. Pingback: tor-lyubov-i-grom.ru
  267. Pingback: psy
  268. Pingback: chelovek soznaniye mozg
  269. Pingback: bit.ly
  270. Pingback: cleantalkorg2.ru
  271. Pingback: bucha killings
  272. Pingback: War in Ukraine
  273. Pingback: Ukraine
  274. Pingback: Ukraine news – live
  275. Pingback: Ukraine-Russia
  276. Pingback: The Latest Ukraine News
  277. Pingback: site
  278. Pingback: stats
  279. Pingback: Ukraine-war
  280. Pingback: movies
  281. Pingback: gidonline
  282. Pingback: mir dikogo zapada 4 sezon 4 seriya
  283. Pingback: web
  284. Pingback: film.8filmov.ru
  285. Pingback: liusia-8-seriiaonlain
  286. Pingback: smotret-polnyj-film-smotret-v-khoroshem-kachestve
  287. Pingback: filmgoda.ru
  288. Pingback: rodnoe-kino-ru
  289. Pingback: confeitofilm
  290. Pingback: stat.netstate.ru
  291. Pingback: sY5am
  292. Pingback: Dom drakona
  293. Pingback: JGXldbkj
  294. Pingback: aOuSjapt
  295. Pingback: ìûøëåíèå
  296. Pingback: psikholog moskva
  297. Pingback: Usik Dzhoshua 2 2022
  298. Pingback: Dim Drakona 2022
  299. Pingback: TwnE4zl6
  300. Pingback: psy 3CtwvjS
  301. Pingback: lalochesia
  302. Pingback: film onlinee
  303. Pingback: programma peredach na segodnya
  304. Pingback: psycholog-v-moskve.ru
  305. Pingback: psycholog-moskva.ru
  306. Pingback: 3qAIwwN
  307. Pingback: video-2
  308. Pingback: sezons.store
  309. Pingback: socionika-eniostyle.ru
  310. Pingback: psy-news.ru
  311. Pingback: 000-1
  312. Pingback: 3SoTS32
  313. Pingback: 3DGofO7
  314. Pingback: wwwi.odnoklassniki-film.ru
  315. Pingback: rftrip.ru
  316. Pingback: https://bitbin.it/bn1QAiBO/
  317. Pingback: https://bitbin.it/JI5X9Xvu/
  318. Pingback: dolpsy.ru
  319. Pingback: https://clck.ru/32JaEo
  320. Pingback: kin0shki.ru
  321. Pingback: 3o9cpydyue4s8.ru
  322. Pingback: mb588.ru
  323. Pingback: history-of-ukraine.ru news ukraine
  324. Pingback: newsukraine.ru
  325. Pingback: edu-design.ru
  326. Pingback: tftl.ru
  327. Pingback: brutv
  328. Pingback: site 2023
  329. Pingback: propecia msd order
  330. Pingback: propecia tablets cheap
  331. Pingback: https://bit.ly/3Esup4r
  332. Pingback: sitestats01
  333. Pingback: 1c789.ru
  334. Pingback: cttdu.ru
  335. Pingback: 1703
  336. Pingback: hdserial2023.ru
  337. Pingback: serialhd2023.ru
  338. Pingback: matchonline2022.ru
  339. Pingback: bit.ly/3OEzOZR
  340. Pingback: bit.ly/3gGFqGq
  341. Pingback: bit.ly/3ARFdXA
  342. Pingback: bit.ly/3ig2UT5
  343. Pingback: bit.ly/3GQNK0J
  344. Pingback: bep5w0Df
  345. Pingback: www
  346. Pingback: icf
  347. Pingback: 24hours-news
  348. Pingback: rusnewsweek
  349. Pingback: uluro-ado
  350. Pingback: irannews.ru
  351. Pingback: klondayk2022
  352. Pingback: tqmFEB3B
  353. Pingback: https://bit.ly/okaybaybay
  354. Pingback: https://bit.ly/n39i18b
  355. Pingback: 2022-film
  356. Pingback: https://bitbin.it/yeCU06m7/
  357. Pingback: https://bitbin.it/X5y9A1Fd/
  358. Pingback: mangalib
  359. Pingback: https://gdznew.ru/
  360. Pingback: x
  361. Pingback: xxxx
  362. Pingback: xxx
  363. Pingback: 9xflix
  364. Pingback: 9xflix com
  365. Pingback: xnxx
  366. Pingback: free video
  367. Pingback: https://bit.ly/xnxx-xnxxcom-free-video-xnxx-com
  368. Pingback: 123movies
  369. Pingback: 123 movies
  370. Pingback: Watch Movies Online for Free on 123Movies
  371. Pingback: Watch Movies 123Movies
  372. Pingback: Movies 123Movies

Leave a Reply