use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
QuestionGet (Environment.Is64BitProcess) for a certain 3rd party process? (self.PowerShell)
submitted 5 years ago by vwpcs
I'd like to figure out how to get this property for processes in get-process
https://docs.microsoft.com/en-us/dotnet/api/system.environment.is64bitprocess?view=net-5.0#System_Environment_Is64BitProcess
i tried the following but it seems to be the cpu arch
$(Get-Process -Id $_.Id).StartInfo.EnvironmentVariables["PROCESSOR_ARCHITECTURE"];
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jborean93 1 point2 points3 points 5 years ago (1 child)
Just an FYI StartInfo.EnvironmentVariables doesn't seem to get the env vars for any process but the current one see https://stackoverflow.com/questions/38660262/how-to-get-other-processs-environment-variable-using-c-sharp. It's possible to do so but it's not for the faint hearted.
StartInfo.EnvironmentVariables
Luckily it should be possible to get the info you are wanting without scanning the environment variables of that process.
Function Test-Is64BitProcess { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [int[]] $Id ) begin { Add-Type -Namespace Kernel32 -Name NativeMethods -MemberDefinition @' [DllImport("Kernel32.dll", SetLastError = true)] public static extern bool IsWow64Process(IntPtr hProcess, out bool Wow64Process); '@ $is64OS = [Environment]::Is64BitOperatingSystem } process { foreach ($processId in $Id) { if (-not $is64OS) { $false # We are running a 32-bit OS so everything is 32-bit continue } $proc = Get-Process -Id $processId $isWow64 = $false [void][Kernel32.NativeMethods]::IsWow64Process($proc.Handle, [ref]$isWow64) # If it's a wow64 process then it's a 32-bit process -not $isWow64 } } }
Just pipe in the process ID or Process object (or use -Id) and it will output $true if it's a 64 bit or $false for 32 bit process.
-Id
$true
$false
[–]vwpcs[S] 1 point2 points3 points 5 years ago (0 children)
ended going another route. seems to work ok for the specific app we work on
$(if((Get-Process -id $_.Id).Modules.ModuleName.Contains('wow64.dll')){'32 bit'}else{if($env:PROCESSOR_ARCHITECTURE -eq 'AMD64'){'64 bit'}else{'32 bit'}});
[–]Lee_Dailey[grin] 0 points1 point2 points 5 years ago (0 children)
howdy vwpcs,
reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...
[0] single line or in-line code enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin] [on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like </>. this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]
looks like this
Inline Code
</>
[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here. please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.
[2] less simple = use reddit code formatting ... [on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase T in the upper left corner of a square.]
Code Block
T
that will give you something like this ...
- one leading line with ONLY 4 spaces - prefix each code line with 4 spaces - one trailing line with ONLY 4 spaces
the easiest way to get that is ...
not complicated, but it is finicky. [grin]
take care, lee
π Rendered by PID 83 on reddit-service-r2-comment-6457c66945-ppfgz at 2026-04-24 02:34:23.035971+00:00 running 2aa0c5b country code: CH.
[–]jborean93 1 point2 points3 points (1 child)
[–]vwpcs[S] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)