{"id":532,"date":"2021-09-04T12:23:41","date_gmt":"2021-09-04T19:23:41","guid":{"rendered":"https:\/\/aplcs.com\/?p=532"},"modified":"2024-11-07T04:01:33","modified_gmt":"2024-11-07T04:01:33","slug":"file-hashing-with-powershell","status":"publish","type":"post","link":"https:\/\/aplcs.com\/?p=532","title":{"rendered":"File Hashing with Powershell"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"532\" class=\"elementor elementor-532\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-001b537 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"001b537\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9cbbcb1\" data-id=\"9cbbcb1\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bd790e4 elementor-widget elementor-widget-text-editor\" data-id=\"bd790e4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"font-size: 14px;\">I&#8217;ve been a contractor for a long time, namely because I preferred to jump from business to business learning new things, facing new challenges.\u00a0 Early in my career when I stayed put in a single firm, I was easily bored. (Although as I get older, the idea of consistency and belonging is slowly beginning to appeal to me&#8230;but that&#8217;s another post for another time).<\/span><\/p><p>One of the issues with hopping from business to business is that I never know what systems\/applications are available to me.\u00a0 Sometimes a firm will have the best and latest bleeding edge technology, and other times (probably more often) all that&#8217;s available is whatever happens to be in the personal arsenal of the individual working on the project at the time.<\/p><p>This is why I like tools that are free or open source.\u00a0 I can have them anytime without being required to go through a committee with requisition forms in triplicate just to get a minor task completed.\u00a0 Convincing a client that the $60 he is trying to save on software would end up costing him thousands in extra labor hours, is a conversation that gets repetitive and annoying very fast.<\/p><p>PowerShell (and Python) has become part of my toolset for the simple reason that it is readily available, and the functions it provides are practically all-encompassing.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-428870fd elementor-section-content-middle elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"428870fd\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-no\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2ff13072\" data-id=\"2ff13072\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b3cbdf7 elementor-widget elementor-widget-image\" data-id=\"b3cbdf7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/aplcs.com\/wp-content\/uploads\/2021\/09\/PowerShell-01.png\" title=\"\" alt=\"\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-277a6ac elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"277a6ac\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3195be8\" data-id=\"3195be8\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4b3cceb elementor-widget elementor-widget-text-editor\" data-id=\"4b3cceb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>One of the commands in PowerShell I like to use quite often is:<\/p><pre>Get-FileHash<\/pre><p>Say I wanted to get the MD5 hash of the file cindyloh3333@gmail.com.mbox show in the screenshot above.\u00a0 All I&#8217;d have to do is type in:<\/p><pre>get-filehash -algorithm md5 cindyloh3333@gmail.com.mbox<\/pre><p>The <em>-algorithm md5<\/em> option specifies the hashing algorithm to be used and I can just as easily change it to SHA1, SHA256, or any other algorithm that may be appropriate.\u00a0 Also, by adding in the pipe | and out-file command, I can even export the information into a text file for later use:<\/p><pre>get-filehash -algorithm md5 cindyloh3333@gmail.com.mbox | out-file \"C:\\temp\\hashed.txt\"<\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-67458f3 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"67458f3\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0786c66\" data-id=\"0786c66\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4fb25e2 elementor-widget elementor-widget-image\" data-id=\"4fb25e2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/aplcs.com\/wp-content\/uploads\/2021\/09\/PowerShell-03.png\" title=\"\" alt=\"\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8cf3ad1 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8cf3ad1\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6b6da09\" data-id=\"6b6da09\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2924e8f elementor-widget elementor-widget-text-editor\" data-id=\"2924e8f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>And, with a little bit more added to the initial command, I can even have all the files within a specific path hashed and exported out to a CSV file:<\/p><pre>Get-FileHash -Algorithm MD5 -Path (Get-ChildItem \"C:\\Temp\\Hashing\\*.*\" -Recurse -force) | export-csv c:\\Temp\\allfiles_hashed.csv<\/pre><p>Though most of the time I would just go with the less elegant (but much easier to type:<\/p><pre>$name = get-filehash -algorithm md5 \"c:\\temp\\hashing\\*.*\" ; $name | out-file \"c:\\temp\\combinedhash.txt\"<\/pre><p>Though it won&#8217;t give me a CSV file, it&#8217;s easier for me to remember as it&#8217;s really just combining two simple operations (storing the hashes in a variable, and then saving that variable to a text file); plus it&#8217;s one of the first piece of &#8220;code&#8221; that I figured out on my own when I first started learning PowerShell many many moons ago \ud83d\ude42<\/p><p>The point here though, is that PowerShell obviously packs quite a bit under the hood and isn&#8217;t just for system admins to manage servers and networks.\u00a0 There are many different scenarios in Legal Tech where PowerShell is my go-to option due to the fact that 1) it&#8217;s readily available everywhere on every OS, and 2) for one-off needs, it doesn&#8217;t require huge time investment.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been a contractor for a long time, namely because I preferred to jump from business to business learning new things, facing new challenges.&nbsp; Early in my career when I stayed put in a single firm, I was easily bored. (Although as I get older, the idea of consistency and belonging is slowly beginning to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":617,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,23,28],"tags":[],"class_list":["post-532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","category-training","category-utilities"],"_links":{"self":[{"href":"https:\/\/aplcs.com\/index.php?rest_route=\/wp\/v2\/posts\/532"}],"collection":[{"href":"https:\/\/aplcs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aplcs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aplcs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aplcs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=532"}],"version-history":[{"count":2,"href":"https:\/\/aplcs.com\/index.php?rest_route=\/wp\/v2\/posts\/532\/revisions"}],"predecessor-version":[{"id":724,"href":"https:\/\/aplcs.com\/index.php?rest_route=\/wp\/v2\/posts\/532\/revisions\/724"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aplcs.com\/index.php?rest_route=\/wp\/v2\/media\/617"}],"wp:attachment":[{"href":"https:\/\/aplcs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aplcs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aplcs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}