共用方式為


Select-AzureStorSimpleResource

將資源設定為目前的資源。

注意

本文件中參考的 Cmdlet 用於管理使用 Azure Service Manager(ASM) API 的舊版 Azure 資源。 建立新的資源時,不建議使用此舊版 PowerShell 模組,因為 ASM 已排定淘汰。 如需詳細資訊,請參閱 Azure Service Manager 淘汰

Az PowerShell 模組是使用 PowerShell 管理 Azure Resource Manager (ARM) 資源的建議 PowerShell 模組。

語法

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

Description

Select-AzureStorSimpleResource Cmdlet 會將資源設定為目前的資源。 選取資源之後,其他 Cmdlet 會套用在該資源內容中。

範例

範例 1:第一次選取資源

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

此命令會將名為 Contoso64-Tsqa 的資源選取為目前的內容。 在此範例中,計算機先前尚未初始化此內容,因此您必須指定 RegistrationKey 參數的值。

範例 2:嘗試選取資源

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.

範例 3:選取先前選取的資源

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

此命令會將名為 Contoso64-Tsqa 的資源選取為目前的內容。 在此範例中,該內容先前已選取,因此,您不需要指定 RegistrationKey 參數的值。

參數

-Profile

指定 Azure 設定檔。

類型:AzureSMProfile
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-RegistrationKey

指定註冊金鑰。 第一次選取資源時,請指定索引鍵。 在此 Cmdlet 選取目前的資源之後,Cmdlet 會視需要使用此密鑰。 如需詳細資訊,請參閱 Microsoft開發人員網路上取得服務註冊密鑰https://msdn.microsoft.com/en-us/library/azure/dn772346.aspx)。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-ResourceName

指定要選取為目前資源的資源名稱。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

輸入

None

輸出

StorSimpleResourceContext

此 Cmdlet 會傳 回 StorSimpleResourceContext 物件,其中包含資源內容的詳細數據。