Rich Rumble
asked on
Drag and drop powershell file hashing script
PowerShell drag and drop, then hash the file that was dropped onto the form.
I can't figure out where to add something like "$fileHash = Get-FileHash -path $file -A SHA256" and then append to the file path.
The code below shows the file path when dragging a file, I want to hash that same file and add it's hash to the end
c:\some\file\path\here.txt , F70363B8AE41B113AC96F9762D B46262B8F4 36B29A4B7D 1E2A3ADAB1 01E75299
I may further call a VirusTotal API call to look the hash up and append more info on the end later.
Right now all I need is the hash of the file(s) that get drug onto the form.
I can't figure out where to add something like "$fileHash = Get-FileHash -path $file -A SHA256" and then append to the file path.
The code below shows the file path when dragging a file, I want to hash that same file and add it's hash to the end
c:\some\file\path\here.txt
I may further call a VirusTotal API call to look the hash up and append more info on the end later.
Right now all I need is the hash of the file(s) that get drug onto the form.
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Form1 = New-Object System.Windows.Forms.Form
$Form1.ClientSize = "391, 190"
$Form1.TopMost = $true
$TextBox1 = New-Object System.Windows.Forms.TextBox
$TextBox1.Anchor = "Top,Bottom,Left,Right"
$TextBox1.Location = "12, 12"
$TextBox1.Multiline = $true
$TextBox1.ScrollBars = "Both"
$TextBox1.Size = "368, 166"
$TextBox1.AllowDrop = $true
$TextBox1.add_DragEnter({FNprocess($_)})
$Form1.Controls.Add($TextBox1)
function FNprocess( $object ){
foreach ($file in $object.Data.GetFileDropList()){
$TextBox1.AppendText($file+[char]13+[char]10)
}
}
[System.Windows.Forms.Application]::Run($Form1)
ASKER
That works! Seem obvious when you guys do this so quickly... if you have suggestions on improvements I'm all for it. I was looking for something simple to build from is all.
-rich
-rich
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As always, great solution, thanks! You know I'll be back soon :)
-rich
-rich
LoadWithPartialName is somewhat dated. btw:
Open in new window