The simple answer for this is that you have an undeclared (null) variable. In this case, it is $md5 . From the comment you provided, it is necessary that this be indicated elsewhere in your code.
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
The error was that you are trying to execute a method that does not exist.
PS C:\Users\Matt> $md5 | gm TypeName: System.Security.Cryptography.MD5CryptoServiceProvider Name MemberType Definition ---- ---------- ---------- Clear Method void Clear() ComputeHash Method byte[] ComputeHash(System.IO.Stream inputStream), byte[] ComputeHash(byte[] buffer), byte[] ComputeHash(byte[] buffer, int offset, ...
.ComputeHash() of $md5.ComputeHash() was a null value. Entering into gibberish would create the same effect.
PS C:\Users\Matt> $bagel.MakeMeABagel() You cannot call a method on a null-valued expression. At line:1 char:1 + $bagel.MakeMeABagel() + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
PowerShell by default allows this to be executed as defined by StrictMode
If the Set-StrictMode parameter is disabled, it is assumed that uninitialized variables (version 1) have a value of 0 (zero) or $ zero, depending on the type. References to nonexistent properties return $ Null, and function syntax results that are invalid are modified with an error. Variables are not allowed without modification.
source share