Azure / Azure/azure-powershell
ResourceGroup default doesn't work properly in AzurePSDrive in Azure Cloud Shell
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
In Azure Cloud Shell's AzurePSDrive, when you try to invoke a cmdlet without specifying resourcegroup, the cmdlet errors due to multiple values defined in **PSDefaultParameterValues**
### Script/Steps for Reproduction
Navigate to a resourcegroup inside AzurePSDrive and call a **Get-AzureRM***cmdlet that takes a resourcegroup parameter
```powershell
cd Azure:\\ResourceGroups\
Get-AzureRmVpnClientPackage
#Output
WARNING: Multiple different default values are defined in $PSDefaultParameterValues for the
parameter matching the following name or alias: ResourceGroupName. These defaults have been ignored.
cmdlet Get-AzureRmVpnClientPackage at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
ResourceGroupName:
```
### Module Version
```powershell
Get-Module -Name AzureRM -ListAvailable
#Output
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.4.0 AzureRM
```
### Environment Data
```powershell
$PSVersionTable
#Output
Name Value
---- -----
PSVersion 5.1.14393.1944
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1944
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```
### Root Cause
AzurePSDrive defines a default value of **resourcegroup** parameter for *-AzureRM cmdlets
```powershell
$PSDefaultParameterValues['*-AzureRM*:ResourceGroupName']
#Output
if($pwd -like 'Azure:\*\ResourceGroups\*'){($pwd -split '\\')[3]}
```
Contributor guide
Assessment
This issue has not been assessed yet.