Diventare operativi con PowerShell nello Stack di AzureGet up and running with PowerShell in Azure Stack

Si applica a: Azure Stack integrate di sistemi Azure Stack Development KitApplies to: Azure Stack integrated systems and Azure Stack Development Kit

Questa Guida rapida consente di installare e configurare un ambiente dello Stack di Azure con PowerShell.This quickstart helps you to install and configure an Azure Stack environment with PowerShell. Lo script fornito in questo articolo ha come ambito il operatore Azure Stack solo.The script that we provide in this article is scoped to the Azure Stack operator only.

In questo articolo è una versione ridotta dei passaggi descritti nel installare PowerShell, scaricare strumenti, e configurare l'ambiente di PowerShell dell'operatore Azure Stack articoli.This article is a condensed version of the steps that are described in the Install PowerShell, Download tools, and Configure the Azure Stack operator's PowerShell environment articles. Utilizzando gli script in questo argomento, è possibile impostare per gli ambienti di Stack di Azure distribuiti con Azure Active Directory o Active Directory Federation Services (ADFS) di PowerShell.By using the scripts in this topic, you can set up PowerShell for Azure Stack environments that are deployed with Azure Active Directory or Active Directory Federation Services (AD FS).

Configurare PowerShell per le distribuzioni basate su Azure Active DirectorySet up PowerShell for Azure Active Directory-based deployments

Firmare il Kit di sviluppo dello Stack di Azure o un client esterno basato su Windows se si è connessi tramite VPN.Sign in to your Azure Stack Development Kit, or a Windows-based external client if you are connected through VPN. Aprire una sessione di PowerShell ISE con privilegi elevata e quindi eseguire lo script seguente.Open an elevated PowerShell ISE session, and then run the following script. Assicurarsi di aggiornare il TenantName, ArmEndpoint, e GraphAudience variabili necessarie per la configurazione dell'ambiente:Make sure to update the TenantName, ArmEndpoint, and GraphAudience variables as necessary for your environment configuration:

Importante

La versione del modulo PowerShell di Azure Resource Manager 1.2.11 viene fornito con un elenco di modifiche di rilievo.The release of the AzureRM 1.2.11 PowerShell module comes with a list of breaking changes. Eseguire l'aggiornamento dal 1.2.10 versione, vedere il Guida alla migrazione.To upgrade from the 1.2.10 version, see the migration guide.

# Specify Azure Active Directory tenant name.
$TenantName = "<mydirectory>.onmicrosoft.com"

# Set the module repository and the execution policy.
Set-PSRepository `
  -Name "PSGallery" `
  -InstallationPolicy Trusted

Set-ExecutionPolicy RemoteSigned `
  -force

# Uninstall any existing Azure PowerShell modules. To uninstall, close all the active PowerShell sessions, and then run the following command:
Get-Module -ListAvailable | `
  Uninstall-Module

# Install PowerShell for Azure Stack.
Install-Module `
  -Name AzureRm.BootStrapper `
  -Force

Use-AzureRmProfile `
  -Profile 2017-03-09-profile `
  -Force

Install-Module `
  -Name AzureStack `
  -RequiredVersion 1.2.11 `
  -Force 

# Download Azure Stack tools from GitHub and import the connect module.
cd \

invoke-webrequest `
  https://github.com/Azure/AzureStack-Tools/archive/master.zip `
  -OutFile master.zip

expand-archive master.zip `
  -DestinationPath . `
  -Force

cd AzureStack-Tools-master

Import-Module .\Connect\AzureStack.Connect.psm1

# For Azure Stack development kit, this value is set to https://adminmanagement.local.azurestack.external. To get this value for Azure Stack integrated systems, contact your service provider.
  $ArmEndpoint = "<Resource Manager endpoint for your environment>"

# For Azure Stack development kit, this value is adminvault.local.azurestack.external 
$KeyvaultDnsSuffix = "<Keyvault DNS suffix for your environment>"


# Register an AzureRM environment that targets your Azure Stack instance
  Add-AzureRMEnvironment `
    -Name "AzureStackAdmin" `
    -ArmEndpoint $ArmEndpoint

# Get the Active Directory tenantId that is used to deploy Azure Stack
  $TenantID = Get-AzsDirectoryTenantId `
    -AADTenantName $TenantName `
    -EnvironmentName "AzureStackAdmin"

# Sign in to your environment
  Login-AzureRmAccount `
    -EnvironmentName "AzureStackAdmin" `
    -TenantId $TenantID 

Configurare PowerShell per le distribuzioni di Active Directory basati su ADFSSet up PowerShell for AD FS-based deployments

Se si opera Stack Azure quando si è connessi a internet, è possibile utilizzare lo script seguente.You can use the following script if you are operating Azure Stack when connected to internet. Tuttavia se si opera Stack Azure senza connettività internet, utilizzare il disconnesso modalità di installazione di PowerShell e i cmdlet per configurare PowerShell rimarrà stessi, come illustrato nello script.However if you are operating Azure Stack without internet connectivity, use the disconnected way of installing PowerShell and the cmdlets to configure PowerShell will remain same as shown in this script. Firmare il Kit di sviluppo dello Stack di Azure o un client esterno basato su Windows se si è connessi tramite VPN.Sign in to your Azure Stack Development Kit, or a Windows-based external client if you are connected through VPN. Aprire una sessione di PowerShell ISE con privilegi elevata e quindi eseguire lo script seguente.Open an elevated PowerShell ISE session, and then run the following script. Assicurarsi di aggiornare il ArmEndpoint e GraphAudience variabili necessarie per la configurazione dell'ambiente:Make sure to update the ArmEndpoint and GraphAudience variables as necessary for your environment configuration:


# Set the module repository and the execution policy.
Set-PSRepository `
  -Name "PSGallery" `
  -InstallationPolicy Trusted

Set-ExecutionPolicy RemoteSigned `
  -force

# Uninstall any existing Azure PowerShell modules. To uninstall, close all the active PowerShell sessions and run the following command:
Get-Module -ListAvailable -Name Azure* | `
  Uninstall-Module

# Install PowerShell for Azure Stack.
Install-Module `
  -Name AzureRm.BootStrapper `
  -Force

Use-AzureRmProfile `
  -Profile 2017-03-09-profile `
  -Force

Install-Module `
  -Name AzureStack `
  -RequiredVersion 1.2.11 `
  -Force 

# Download Azure Stack tools from GitHub and import the connect module.
cd \
invoke-webrequest `
  https://github.com/Azure/AzureStack-Tools/archive/master.zip `
  -OutFile master.zip

expand-archive master.zip `
  -DestinationPath . `
  -Force

cd AzureStack-Tools-master

Import-Module .\Connect\AzureStack.Connect.psm1

# For Azure Stack development kit, this value is set to https://adminmanagement.local.azurestack.external. To get this value for Azure Stack integrated systems, contact your service provider.
$ArmEndpoint = "<Resource Manager endpoint for your environment>"

# For Azure Stack development kit, this value is adminvault.local.azurestack.external 
$KeyvaultDnsSuffix = "<Keyvault DNS suffix for your environment>"

# Register an AzureRM environment that targets your Azure Stack instance
Add-AzureRMEnvironment `
    -Name "AzureStackAdmin" `
    -ArmEndpoint $ArmEndpoint

# Get the Active Directory tenantId that is used to deploy Azure Stack     
$TenantID = Get-AzsDirectoryTenantId `
    -ADFS `
    -EnvironmentName "AzureStackAdmin"

# Sign in to your environment
Login-AzureRmAccount `
    -EnvironmentName "AzureStackAdmin" `
    -TenantId $TenantID

Testare la connettivitàTest the connectivity

Dopo aver configurato PowerShell, è possibile testare la configurazione tramite la creazione di un gruppo di risorse:Now that you’ve configured PowerShell, you can test the configuration by creating a resource group:

New-AzureRMResourceGroup -Name "ContosoVMRG" -Location Local

Dopo aver creato il gruppo di risorse, il lo stato di Provisioning è impostata su Succeeded.After the resource group is created, the Provisioning state property is set to Succeeded.

Passaggi successiviNext steps