Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS v7.4.1 breaks passing credentials to start-process #21073

Closed
5 tasks done
RaZz85 opened this issue Jan 15, 2024 · 15 comments · Fixed by #21393
Closed
5 tasks done

PS v7.4.1 breaks passing credentials to start-process #21073

RaZz85 opened this issue Jan 15, 2024 · 15 comments · Fixed by #21393
Labels
7.4-regression Regression in 7.4 In-PR Indicates that a PR is out for the issue Resolution-Fixed The issue is fixed.

Comments

@RaZz85
Copy link

RaZz85 commented Jan 15, 2024

Prerequisites

Steps to reproduce

Since updating to 7.4.1, it is no longer possible to pass credentials through to start-process. Running as admin makes no difference.

$credentials = get-credential
start-process -FilePath "C:\Windows\System32\mstsc.exe" -ArgumentList "/v:myrdpserver" -Credential $credential

Expected behavior

mstsc connects to myrdpserver with the provided credentials

Actual behavior

Start-Process: Access is denied.

Error details

Exception             :
    Type            : System.ComponentModel.Win32Exception
    NativeErrorCode : 5
    ErrorCode       : -2147467259
    TargetSite      :
        Name          : OpenProcess
        DeclaringType : System.Diagnostics.ProcessManager, System.Diagnostics.Process, Version=8.0.0.0, Culture=neutral
, PublicKeyToken=b03f5f7f11d50a3a
        MemberType    : Method
        Module        : System.Diagnostics.Process.dll
    Message         : Access is denied.
    Source          : System.Diagnostics.Process
    HResult         : -2147467259
    StackTrace      :
   at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetOrOpenProcessHandle()
   at System.Diagnostics.Process.get_Handle()
   at Microsoft.PowerShell.Commands.StartProcessCommand.BeginProcessing()
   at System.Management.Automation.Cmdlet.DoBeginProcessing()
   at System.Management.Automation.CommandProcessorBase.DoBegin()
CategoryInfo          : NotSpecified: (:) [Start-Process], Win32Exception
FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.StartProcessCommand
InvocationInfo        :
    MyCommand        : Start-Process
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 5
    Line             : start-process -FilePath  "C:\Windows\System32\mstsc.exe" -ArgumentList "/v:myrdpserver" -Credent
ial $credential
    Statement        : start-process -FilePath  "C:\Windows\System32\mstsc.exe" -ArgumentList "/v:myrdpserver" -Credent
ial $credential
    PositionMessage  : At line:1 char:1
                       + start-process -FilePath  "C:\Windows\System32\mstsc.exe" -ArgumentLis …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : start-process
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@RaZz85 RaZz85 added the Needs-Triage The issue is new and needs to be triaged by a work group. label Jan 15, 2024
@RaZz85 RaZz85 changed the title PS v7.4.1 breaks passing credentials via start-process PS v7.4.1 breaks passing credentials to start-process Jan 15, 2024
@jlapchuk
Copy link

Confirmed I'm experiencing the same issue after upgrading to v7.4.1. Attempting to Start-Process with -Credential fails with an 'Access is denied' error.

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

image

NativeErrorCode : 5
ErrorCode       : -2147467259
TargetSite      : Microsoft.Win32.SafeHandles.SafeProcessHandle OpenProcess(Int32, Int32, Boolean)
Message         : Access is denied.
Data            : {}
InnerException  :
HelpLink        :
Source          : System.Diagnostics.Process
HResult         : -2147467259
StackTrace      :    at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean
                  throwIfExited)
                     at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
                     at System.Diagnostics.Process.GetOrOpenProcessHandle()
                     at System.Diagnostics.Process.get_Handle()
                     at Microsoft.PowerShell.Commands.StartProcessCommand.BeginProcessing()
                     at System.Management.Automation.Cmdlet.DoBeginProcessing()
                     at System.Management.Automation.CommandProcessorBase.DoBegin()

@bartvermeersch
Copy link

@CodeCyclone could this be introduced by the code changes in 20749 or 20866 ? Thanks!

@aproposts
Copy link

Not sure if subscribing counts as a 'vote', so I'll add that I recently upgraded and am experiencing the same:

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
$cred = Get-Credential someValidCredential
Start-Process -Credential $cred -FilePath notepad.exe
Start-Process: Access is denied.
Get-Error
Exception             : 
    Type            : System.ComponentModel.Win32Exception
    NativeErrorCode : 5
    ErrorCode       : -2147467259
    TargetSite      : 
        Name          : OpenProcess
        DeclaringType : System.Diagnostics.ProcessManager, System.Diagnostics.Process, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
        MemberType    : Method
        Module        : System.Diagnostics.Process.dll
    Message         : Access is denied.
    Source          : System.Diagnostics.Process
    HResult         : -2147467259
    StackTrace      : 
   at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetOrOpenProcessHandle()
   at System.Diagnostics.Process.get_Handle()
   at Microsoft.PowerShell.Commands.StartProcessCommand.BeginProcessing()
   at System.Management.Automation.Cmdlet.DoBeginProcessing()
   at System.Management.Automation.CommandProcessorBase.DoBegin()
CategoryInfo          : NotSpecified: (:) [Start-Process], Win32Exception
FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.StartProcessCommand
InvocationInfo        : 
    MyCommand        : Start-Process
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 22
    Line             : Start-Process -Credential $cred -FilePath notepad.exe
    Statement        : Start-Process -Credential $cred -FilePath notepad.exe
    PositionMessage  : At line:1 char:1
                       + Start-Process -Credential $cred -FilePath notepad.exe
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Start-Process
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

@Peter-76
Copy link

Peter-76 commented Feb 14, 2024

Same here - please fix!
In the meantime I go back to 7.4.0 :-(

@LucaCamporotondo
Copy link

I confirm, I too am having the same problem.

@ChrisLynchHPE
Copy link

I just ran into this issue as well.

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I tried using PowerShell 7.5-Preview2 and had the same Access Denied error. I removed 7.4.1, installed 7.4.0 and can successfully launch another process with Start-Process -Credential $OtherAccount. Hope this gets resolved.

@Peter-76
Copy link

It is really disappointing that nothing is happening here 😞

@jlapchuk
Copy link

It is really disappointing that nothing is happening here 😞

SAME! I was hoping this would be a quick and easy .2 fix, but I guess not? This is starting to impact our daily workloads as we have PS modules that require PowerShell 7 to function, but not being able to pass credentials to Start-Process is breaking all of that.

@TechNinja-PS
Copy link

It is really disappointing that nothing is happening here 😞

SAME! I was hoping this would be a quick and easy .2 fix, but I guess not? This is starting to impact our daily workloads as we have PS modules that require PowerShell 7 to function, but not being able to pass credentials to Start-Process is breaking all of that.

+1

@bartvermeersch
Copy link

It is impacting our workflows as well. After 2 months not even a bug tag is assigned on this issue.

@RaZz85
Copy link
Author

RaZz85 commented Mar 20, 2024

Still no progress, this is halting our workflows quite badly.

@Peter-76
Copy link

What makes things worse for me is that with 7.4.1 this bug is fixed:
#20400

So both versions, 7.4.0 and 7.4.1, have a bug that is impacting my daily work 😒
Maybe downgrading to 7.3.x is the best option for me.

@mmseng
Copy link

mmseng commented Mar 29, 2024

Same issue here. I used this functionality on a daily basis, so pretty impactful.

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR Indicates that a PR is out for the issue label Mar 30, 2024
@jborean93
Copy link
Collaborator

jborean93 commented Mar 30, 2024

I've opened #21393 which will treat the exception as a warning allowing people to still continue to use the Process object with methods like WaitForExit(). From what I've investigated this problem should only apply when

  • You are not running as admin, and
  • You are using a -Credential that is not your current user

If you are seeing this exception but do not fit into the above conditions please let me know and I'll have to do some further investigation to see what is happening.

A workaround is to use the Process type directly which should support pretty much all of the same scenarios that Start-Process does except for using -Wait to wait for that process and it's descendants. If you only need to wait for the direct process to end then that should work fine.

If you are interesting in 3rd party modules I've written ProcessEx which exposes a few more features not found in Start-Process and works around a few known bugs that you might be interested in.

@daxian-dbw daxian-dbw added 7.4-regression Regression in 7.4 and removed Needs-Triage The issue is new and needs to be triaged by a work group. labels Apr 1, 2024
Copy link
Contributor

microsoft-github-policy-service bot commented Apr 15, 2024

📣 Hey @RaZz85, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@daxian-dbw daxian-dbw added Resolution-Fixed The issue is fixed. and removed In-PR Indicates that a PR is out for the issue labels Apr 15, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR Indicates that a PR is out for the issue label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7.4-regression Regression in 7.4 In-PR Indicates that a PR is out for the issue Resolution-Fixed The issue is fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

12 participants