azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Get-AzVmRunCommand InstanceView with RunAsUser not working

Open dlkmp-a opened this issue 2 years ago • 8 comments

Description

Skipping all irrelevant parameters, the following works as expected (target is a Windows VM):

Set-AzVMRunCommand -RunCommandName "MyCmd" -SourceScript "Write-Host Test" Get-AzVMRunCommand -RunCommandName "MyCmd" -Expand "instanceView" | select -ExpandProperty instanceview

Shows the expected output:

ExecutionState   : Succeeded
ExecutionMessage : 
ExitCode         : 0
Output           : Test
Error            : 
StartTime        : 05/07/2023 10:19:22
EndTime          : 05/07/2023 10:19:22
Statuses         : 

If I run the same command under a different user:

Set-AzVMRunCommand -RunCommandName "MyCmd" -SourceScript "Write-Host Test" -RunAsUser $user -RunAsPassword $password Get-AzVMRunCommand -RunCommandName "MyCmd" -Expand "instanceView" | select -ExpandProperty instanceview

I don't see any output (and some fields are missing):

ExecutionState   : Succeeded
ExecutionMessage : 
ExitCode         : 0
Output           : 
Error            : 

Expected behaviour: Show the output of the command.

Issue script & Debug output

Nothing

Environment data

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

Module versions

ModuleType Version    PreRelease Name                          
---------- -------    ---------- ----                             
Script     2.12.4                Az.Accounts                     
Script     6.1.0                 Az.Compute                      
Script     6.5.2                 Az.Resources                        
Script     1.1.2                 Az.Tools.Predictor

Error output

No response

dlkmp-a avatar Jul 05 '23 12:07 dlkmp-a

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @TravisCragg-MSFT, @nikhilpatel909, @sandeepraichura, @hilaryw29, @GabstaMSFT.

Issue Details

Description

Skipping all irrelevant parameters, the following works as expected (target is a Windows VM):

Set-AzVMRunCommand -RunCommandName "MyCmd" -SourceScript "Write-Host Test" Get-AzVMRunCommand -RunCommandName "MyCmd" -Expand "instanceView" | select -ExpandProperty instanceview

Shows the expected output:

ExecutionState   : Succeeded
ExecutionMessage : 
ExitCode         : 0
Output           : Test
Error            : 
StartTime        : 05/07/2023 10:19:22
EndTime          : 05/07/2023 10:19:22
Statuses         : 

If I run the same command under a different user:

Set-AzVMRunCommand -RunCommandName "MyCmd" -SourceScript "Write-Host Test" -RunAsUser $user -RunAsPassword $password Get-AzVMRunCommand -RunCommandName "MyCmd" -Expand "instanceView" | select -ExpandProperty instanceview

I don't see any output (and some fields are missing):

ExecutionState   : Succeeded
ExecutionMessage : 
ExitCode         : 0
Output           : 
Error            : 

Expected behaviour: Show the output of the command.

Issue script & Debug output

Nothing

Environment data

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

Module versions

ModuleType Version    PreRelease Name                          
---------- -------    ---------- ----                             
Script     2.12.4                Az.Accounts                     
Script     6.1.0                 Az.Compute                      
Script     6.5.2                 Az.Resources                        
Script     1.1.2                 Az.Tools.Predictor

Error output

No response

Author: dlkmp-a
Assignees: -
Labels:

Compute - VM, Service Attention, bug, customer-reported

Milestone: -

ghost avatar Jul 06 '23 01:07 ghost

@vivlingaiah Can you please review it

nikhilpatel909 avatar Oct 26 '23 19:10 nikhilpatel909

Is there any workaround for this?

splitt3r avatar Mar 05 '24 16:03 splitt3r

Hi @splitt3r , Do you know what version of Run Command is being used ? Could you share resourceId of VM so that I could investigate further ?

viveklingaiah avatar Mar 06 '24 00:03 viveklingaiah

Surfacing this back up for @splitt3r. Do you know what version of Run Command is being used ? Could you share resourceId of VM so that I could investigate further ?

GabstaMSFT avatar Apr 18 '24 19:04 GabstaMSFT

@vivlingaiah, @GabstaMSFT, not sure why this question is directed at @splitt3r, but isn't the information included in the OP? I cannot share the resourceId of the VM but I can see the behavior with multiple (Windows Server 2022) VMs, it should be straight-forward to reproduce.

dlkmp-a avatar Apr 18 '24 19:04 dlkmp-a

@dlkmp-a is the user you are using a local user or a domain user?

GabstaMSFT avatar Jun 27 '24 20:06 GabstaMSFT

@dlkmp-a is the user you are using a local user or a domain user?

My original use-case involved a domain user, I'm not sure if I tested with a local user…I'll update within the next week on whether this makes a difference.

dlkmp-a avatar Jun 30 '24 10:06 dlkmp-a

@dlkmp-a have you been able to test with local user?

GabstaMSFT avatar Jul 25 '24 14:07 GabstaMSFT

Hi @GabstaMSFT, sorry for the late reply.

…but I've been able to test and the issue seems to be resolved: I tested all three cases again:

  • no user specified
  • a local user
  • a domain user

…and I now see the output in InstanceView in all three cases, as expected. Don't know when the fix happened, but now I'm using the Az.Compute module in version 8.1.0 (as opposed to 6.1.0 in the OP).

Thanks everyone!

dlkmp-a avatar Jul 26 '24 06:07 dlkmp-a