Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,24 @@ private void Process_Types_Ps1Xml(string filePath, ConcurrentBag<string> errors)
typeMembers,
isOverride: false);

newMembers.Add(@"CommandLine");
AddMember(
errors,
typeName,
new PSScriptProperty(
@"CommandLine",
GetScriptBlock(@"
if ($IsWindows) {
(Get-CimInstance Win32_Process -Filter ""ProcessId = $($this.Id)"").CommandLine
} elseif ($IsLinux) {
Get-Content -LiteralPath ""/proc/$($this.Id)/cmdline""
}
"),
setterScript: null,
shouldCloneOnAccess: true),
typeMembers,
isOverride: false);

newMembers.Add(@"Parent");
AddMember(
errors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ Describe "Get-Process" -Tags "CI" {
It "Should fail to run Get-Process with -FileVersionInfo without admin" -Skip:(!$IsWindows) {
{ Get-Process -FileVersionInfo -ErrorAction Stop } | Should -Throw -ErrorId "CouldNotEnumerateFileVer,Microsoft.PowerShell.Commands.GetProcessCommand"
}

It "Should return CommandLine property" -Skip:($IsMacOS) {
$command = "(Get-Process -Id `$pid).CommandLine"
$result = & "$PSHOME/pwsh" -NoProfile -NonInteractive -Command $command
$result | Should -BeLike "*$command*"
}
}

Describe "Get-Process Formatting" -Tags "Feature" {
Expand Down