Having a real strange issue here everyone. I want to include a <RETURN> function at the end of line get-filehash $New -Algorithm MD5
(code shown in its entirety below).
Funny thing is: when I run the script it does exactly what I would expect. It converts the file name to whatever I choose it to be in the User Input section… but when the script continues to the MD5 Hash line… it indeed DOES apply an MD5 Hash to the newly named file but the strange part is after doing everything I expect it to do … it THEN displays the following:
Add-Type -AssemblyName PresentationFramework[System.Windows.Forms.SendKeys]::SendWait("{ENTER}") SendKeys.Send("{ENTER}") -ErrorAction SilentlyContinue, Stop
This line is the last one on the script. It carries out the <Enter Key> keystroke function, then displays the above mentioned code which should have already completed… and it did… and then when I hit enter again it throws an error. I love that it carries out the MD5 Hash but dont like seeing that same code appear again when it already completed the task. Any help to resolve would be great. I just want it to carry out the function as it does but then stop the program with no further display of the above mentioned. Here is the code. Please help!!!
<# Filename Change #> $Current = Read-Host "Please Enter Current File Name" $New = Read-Host "Please Enter New File Name" Rename-Item -Path "$Current" -NewName "$New" <# MD5 Hash Apply To New File Name #> get-filehash $New -Algorithm MD5 Sleep 1 Add-Type -AssemblyName PresentationFramework[System.Windows.Forms.SendKeys]::SendWait("{ENTER}") SendKeys.Send("{ENTER}") -ErrorAction SilentlyContinue, Stop