Select-AzureStorSimpleResource

Sets a resource as the current resource.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

Select-AzureStorSimpleResource
      -ResourceName <String>
      [-RegistrationKey <String>]
      [-Profile <AzureSMProfile>]
      [<CommonParameters>]

Description

The Select-AzureStorSimpleResource cmdlet sets a resource as the current resource. After you select a resource, other cmdlets apply within that resource context.

Examples

Example 1: Select a resource for the first time

PS C:\>Select-AzureStorSimpleResource -ResourceName "Contoso64-Tsqa" -RegistrationKey "<your registration key>"
ResourceId           ResourceName
----------           ------------
1909806764156522689  Contoso64-Tsqa

This command selects the resource named Contoso64-Tsqa as the current context. In this example, the computer has not had this context initialized previously, and, therefore, you must specify a value for the RegistrationKey parameter.

Example 2: Attempt to select a resource

This command gets the current context for this computer by using the **Get-AzureStorSimpleResourceContext** cmdlet. The current selected resource is Contoso64-Tsqa. This is consistent with the previous example. 
PS C:\>Get-AzureStorSimpleResourceContext
ResourceId           ResourceName
----------           ------------
1909806764156522689  Contoso64-Tsqa 

This command attempts to reset the resource to be Contoso02-Resource. For this example, this resource has not been previously selected. The registration key is not saved or included in the command. The command cannot select the resource. 
PS C:\>Select-AzureStorSimpleResource -ResourceName "Contoso02-Resource"
Select-AzureStorSimpleResource : Could not find the persisted secret. Please use Select-AzureStorSimpleResource and
provide the Registration key once again.

Example 3: Select a previously selected resource

PS C:\>Select-AzureStorSimpleResource -ResourceName "Contoso64-Tsqa"
ResourceId           ResourceName
----------           ------------
1909806764156522689  Contoso64-Tsqa

This command selects the resource named Contoso64-Tsqa as the current context. In this example, that context has previously been selected, and, therefore, you do not need to specify a value for the RegistrationKey parameter.

Parameters

-Profile

Specifies an Azure profile.

Type:AzureSMProfile
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RegistrationKey

Specifies a registration key. Specify a key the first time that you select a resource. After this cmdlet selects the current resource, cmdlets use this key, as required. For more information, see Get the service registration key (https://msdn.microsoft.com/en-us/library/azure/dn772346.aspx) on the Microsoft Developer Network.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ResourceName

Specifies the name of the resource to select as the current resource.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

None

Outputs

StorSimpleResourceContext

This cmdlet returns a StorSimpleResourceContext object that contains details for the resource context.