Get-AzVmRunCommand InstanceView with RunAsUser not working
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
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: |
|
| Milestone: | - |
@vivlingaiah Can you please review it
Is there any workaround for this?
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 ?
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 ?
@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 is the user you are using a local user or a domain user?
@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 have you been able to test with local user?
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!