Unable to find type [PSMemory.Native].
Closed this issue · 3 comments
Name Value
---- -----
PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
This is my powershell environment.
Unable to find type [PSMemory.Native].
At C:\Program Files\WindowsPowerShell\Modules\PSMemory\1.0.0\PSMemory.psm1:215 char:27
+ if (($processHandle = [PSMemory.Native]::OpenProcess(
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (PSMemory.Native:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
New-Object : Cannot find type [PSMemory.Native+SYSTEM_INFO]: verify that the assembly containing this type is loaded.
At C:\Program Files\WindowsPowerShell\Modules\PSMemory\1.0.0\PSMemory.psm1:224 char:19
+ $systemInfo = New-Object PSMemory.Native+SYSTEM_INFO
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Unable to find type [PSMemory.Native].
At C:\Program Files\WindowsPowerShell\Modules\PSMemory\1.0.0\PSMemory.psm1:225 char:5
+ [PSMemory.Native]::GetNativeSystemInfo([ref]$systemInfo)
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (PSMemory.Native:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
New-Object : Cannot find type [PSMemory.Native+MEMORY_BASIC_INFORMATION64]: verify that the assembly containing this
type is loaded.
At C:\Program Files\WindowsPowerShell\Modules\PSMemory\1.0.0\PSMemory.psm1:229 char:19
+ ... $memoryInfo = New-Object PSMemory.Native+MEMORY_BASIC_INFORMATION64
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "SizeOf" with "1" argument(s): "Value cannot be null.
Parameter name: structure"
At C:\Program Files\WindowsPowerShell\Modules\PSMemory\1.0.0\PSMemory.psm1:230 char:5
+ $memoryInfoSize = [Runtime.InteropServices.Marshal]::SizeOf($memo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Unable to find type [PSMemory.Native].
At C:\Program Files\WindowsPowerShell\Modules\PSMemory\1.0.0\PSMemory.psm1:330 char:12
+ [void] [PSMemory.Native]::CloseHandle($processHandle)
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (PSMemory.Native:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
I've got this error message when I trying a script below:
Get-Process notepad | Search-Memory -Values @{
Int = 1234, 5678
String = 'Notepad'
} -OutVariable notepad
Of course, I executed notepad.exe at the time.
what's the problem??
I installed this with Install-Module -Name PSMemory
and A(All to yes)
First, thank you for taking the time to open an issue and sorry for the inconvenience. This error is due to a typo in the struct definition I made earlier. I fixed that in bb69c92 but obviously forgot to update the module in the PowerShell Gallery afterwards. I did update it now so please try downloading version 1.1 and it should work then.
Nice! now it works by Install-Module -Name PSMemory -Force
PS C:\Windows\system32> Get-Process notepad | Search-Memory -Values @{
>> Int = 1234, 5678
>> String = 'Notepad'
>> } -OutVariable notepad
Count Name Group
----- ---- -----
6 12040 {@{ProcessName=notepad; ProcessId=12040; Address=2957605861420; Value=1234; Type=Int...
You're welcome. Tip: To get formatted/readable output of your search results pipe them to the Format-Memory
Cmdlet afterwards.
Get-Process notepad | Search-Memory -Values @{…} -OutVariable notepad | Format-Memory
or
$notepad | Format-Memory
Alternatively, you can use the alias fm
.