forked from bekimd-ms/AzureStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.ps1
More file actions
26 lines (20 loc) · 863 Bytes
/
connect.ps1
File metadata and controls
26 lines (20 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Import-Module AzureRM -RequiredVersion 1.2.11
#Import-Module .\AzureStack-Tools\Connect\AzureStack.Connect.psm1
$environment = $env:LOCATION
$endpoint = "https://" + $env:ENDPOINT + "management." + $env:LOCATION + "." + $env:DNS
Write-Host "Adding Environment: " $environment ":" $endpoint
Add-AzureRmEnvironment -Name $environment -ArmEndpoint $endpoint
if( $env:USER -eq $Null )
{
$user = ""
Login-AzureRMAccount -EnvironmentName $environment -TenantId $env:DIRECTORY
}
else
{
$secret = convertto-securestring -String $env:PASSWORD -AsPlainText -Force
$user = $env:USER + "@" + $env:DIRECTORY
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $secret
Write-Host "Logging in:" $user
Login-AzureRMAccount -EnvironmentName $environment -Credential $cred
}
Write-Host "Logged in:" $environment $user