Azure / Azure/azure-powershell

Reset-AzLabServicesVMPassword doesn't work

Open
#28,443 3 comments 0 reactions 0 assignees View on GitHub
act-codegen-extensibility-squad bug customer-reported Lab Services Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

When I run
```
Reset-AzLabServicesVMPassword -ResourceId /subscriptions/e0df76a5-ad98-482e-adad-a4b41e453333/resourceGroups/AZLabs-Sage-Preview/providers/Microsoft.LabServices/labs/2025_CSC3431/virtualMachines/1 -Password PASSword123! -Username student
```
or
```
$secureString = ConvertTo-SecureString "YourPassword123" -AsPlainText -Force
Reset-AzLabServicesVMPassword -ResourceId /subscriptions/e0df76a5-ad98-482e-adad-a4b41e453333/resourceGroups/AZLabs-Sage-Preview/providers/Microsoft.LabServices/labs/2025_CSC3431/virtualMachines/1 -Password $secureString -Username student
```
I expect the password on that VM to be updated and to get some kind of success message. Neither of those commands works. There isn't a web UI option for educators to reset a student's VM password (in order to SSH into a student's VM myself to examine it without asking the student to disclose the password to me), so `Reset-AzLabServicesVMPassword` is preventing me from doing so at all.

I tried both because [the manual](https://github.com/Azure/azure-powershell/blob/main/src/LabServices/LabServices/help/Reset-AzLabServicesVMPassword.md) describes the cmdlet as expecting a SecureString, but the example shows a cleartext string. I don't mind which of them ought to work, the problem is that neither does.

It's also rather worrying that, when I used a SecureString, the cleartext password was displayed in the error message.

### Issue script & Debug output

```PowerShell
PS H:\> $secureString = ConvertTo-SecureString "YourPassword123" -AsPlainText -Force
PS H:\> Reset-AzLabServicesVMPassword -ResourceId /subscriptions/e0df76a5-ad98-482e-adad-a4b41e453333/resourceGroups/AZLabs-Sage-Preview/providers/Microsoft.LabServices/labs/2025_CSC3431/virtualMachines/1 -Password $secureString -Username student
DEBUG: 19:02:28 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default
value [True].
DEBUG: 19:02:28 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default
value [True].
DEBUG: 19:02:28 - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 19:02:28 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet =
[Get-AzContext]. Returning default value [True].
DEBUG: 19:02:28 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default
value [True].
DEBUG: 19:02:28 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning
default value [True].
DEBUG: 19:02:28 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value
[True].
DEBUG: 19:02:28 - GetAzureRMContextCommand end processing.
Reset-AzLabServicesVMPassword : Cannot process argument transformation on parameter 'Password'. Cannot convert the
"YourPassword123" value of type "System.String" to type "System.Security.SecureString".
At line:1 char:1
+ Reset-AzLabServicesVMPassword -ResourceId /subscriptions/e0df76a5-ad9 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Reset-AzLabServicesVMPassword_ResourceId], ParameterBindingArgumentTra
nsformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Reset-AzLabServicesVMPassword_ResourceId

PS H:\> Reset-AzLabServicesVMPassword -ResourceId /subscriptions/e0df76a5-ad98-482e-adad-a4b41e453333/resourceGroups/AZLabs-Sage-Preview/providers/Microsoft.LabServices/labs/2025_CSC3431/virtualMachines/1 -Password PASSword123! -Username student
Reset-AzLabServicesVMPassword : Cannot process argument transformation on parameter 'Password'. Cannot convert the
"PASSword123!" value of type "System.String" to type "System.Security.SecureString".
At line:1 char:208
+ ... es/labs/2025_CSC3431/virtualMachines/1 -Password PASSword123! -Userna ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Reset-AzLabServicesVMPassword], ParameterBindingArgumentTransformation
Exception
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Reset-AzLabServicesVMPassword

PS H:\> Reset-AzLabServicesVMPassword -ResourceId /subscriptions/e0df76a5-ad98-482e-adad-a4b41e453333/resourceGroups/AZLabs-Sage-Preview/providers/Microsoft.LabServices/labs/2025_CSC3431/virtualMachines/1 -Password "PASSword123!" -Username student
Reset-AzLabServicesVMPassword : Cannot process argument transformation on parameter 'Password'. Cannot convert the
"PASSword123!" value of type "System.String" to type "System.Security.SecureString".
At line:1 char:208
+ ... /labs/2025_CSC3431/virtualMachines/1 -Password "PASSword123!" -Userna ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Reset-AzLabServicesVMPassword], ParameterBindingArgumentTransformation
Exception
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Reset-AzLabServicesVMPassword
```

### Environment data

```PowerShell
PS H:\> $PSVersionTable

Name Value
---- -----
PSVersion 5.1.19041.6216
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.6216
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

### Module versions

```PowerShell
PS H:\> Get-Module Az*

ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.1.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Script 0.1.2 Az.LabServices {Add-AzLabServicesUserQuota, Get-AzLabServicesLab, Get-AzL...
```

### Error output

```PowerShell
Reset-AzLabServicesVMPassword : Cannot process argument transformation on parameter 'Password'. Cannot convert the
"YourPassword123" value of type "System.String" to type "System.Security.SecureString".
At line:1 char:1
+ Reset-AzLabServicesVMPassword -ResourceId /subscriptions/e0df76a5-ad9 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Reset-AzLabServicesVMPassword_ResourceId], ParameterBindingArgumentTra
nsformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Reset-AzLabServicesVMPassword_ResourceId

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.