This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $DisplayName = 'My-SPN' | |
| $Domain = 'company.com' | |
| $Password = 'Password!' | |
| Function SPN-Removal ($DisplayName){ | |
| if(Get-AzureRmADApplication | ? {$_.DisplayName -eq $DisplayName}){ | |
| $app = Get-AzureRmADApplication | ? {$_.DisplayName -eq $DisplayName} | |
| Remove-AzureRmADApplication -ObjectId $app.ObjectId.Guid -Force | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ########################################################################################## | |
| ########################### Log into Azure using SPN ############################## | |
| ########################################################################################## | |
| Write-Host "`nEnter credentials for the Azure Tenant.`n" -ForegroundColor Cyan | |
| [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null | |
| $TenantID = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the Tenant ID", "Tenant ID") | |
| $creds = Get-Credential | |
| $MigrationAzure = Get-AzureRmEnvironment 'AzureCloud' | |
| $MigrationEnv = Login-AzureRmAccount -Environment $MigrationAzure -TenantId $TenantID -Credential $creds -ServicePrincipal -Verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ########################################################################################## | |
| ###################### Log into Azure using SPN (Silently) ######################### | |
| ########################################################################################## | |
| Write-Host "`nEnter credentials for the Azure Tenant.`n" -ForegroundColor Cyan | |
| [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null | |
| $TenantID = '86753c5-6f2f-8c35-6tfc-64v7g575nhb' | |
| $spnpassword = ConvertTo-SecureString "Password" -AsPlainText -Force | |
| $Cred = New-Object System.Management.Automation.PSCredential ("3f12ab75-2d13-4460-8bf5-1c7f0f591ff5", $spnpassword) | |
| $MigrationAzure = Get-AzureRmEnvironment 'AzureCloud' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| workflow StartAzurePlaylistVMs | |
| { | |
| $Cred = Get-AutomationPSCredential -Name "PowerShell SvcAcct" | |
| Login-AzureRmAccount -Credential $Cred | |
| $subscription = Get-AutomationVariable -Name "subscription" | |
| Select-AzureRmSubscription -SubscriptionName $subscription | |
| $VMs = Get-AzureRmVM | where {$_.Name -match 'playlist'} | |
| ForEach -Parallel ($VM in $VMs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| workflow StopAzurePlaylistVMs | |
| { | |
| $Cred = Get-AutomationPSCredential -Name "PowerShell SvcAcct" | |
| Login-AzureRmAccount -Credential $Cred | |
| $subscription = Get-AutomationVariable -Name "subscription" | |
| Select-AzureRmSubscription -SubscriptionName $subscription | |
| $VMs = Get-AzureRmVM | where {$_.Name -match 'playlist'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $subscription = 'Visual Studio Ultimate with MSDN' | |
| $username = "powershell@tenant.onmicrosoft.com" | |
| $password = "Password" | |
| ### Log into Azure with an organisational account | |
| $secpasswd = ConvertTo-SecureString $password -AsPlainText -Force | |
| $Cred = New-Object System.Management.Automation.PSCredential ($username, $secpasswd) | |
| Login-AzureRmAccount -Credential $Cred | |
| #Choose subscription |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -------------------------------------------------------------------------------------------------------------- | |
| # | |
| # Title : Azure_VMs_Inventory_V1.0 | |
| # Programmed by : Mark Ayre & Marc Kean | |
| # Date : December, 2017 | |
| # | |
| # -------------------------------------------------------------------------------------------------------------- | |
| # | |
| # Script to inventory the VM's (both ASM and ARM based) against all Azure subscriptions the account has access to. | |
| # Adapted from Azure Inventory.ps1 by Marc Kean: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Logon to Azure ARM | |
| $Azure = Get-AzureRmEnvironment 'AzureCloud' | |
| $Env = Login-AzureRmAccount -Environment $Azure -Verbose | |
| # Select Subscription | |
| Select-AzureRmProfile -Profile $Env | |
| $Subscription = (Get-AzureRmSubscription | Out-GridView -Title "Choose a Source Subscription ..." -PassThru) | |
| # Select Subscription Function | |
| Function Subscription { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| workflow Startup_VM | |
| { | |
| $Cred = Get-AutomationPSCredential -Name "Credential_Name" | |
| $tenant = Get-AutomationVariable -Name "tenant" | |
| Login-AzureRmAccount -Credential $Cred -ServicePrincipal -TenantId $tenant | |
| $subscription = Get-AutomationVariable -Name "subscription" | |
| Select-AzureRmSubscription -SubscriptionName $subscription | |
| $VMs = Get-AzureRmVM | where {$_.Name -match 'Virtual_Machine_Name'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| workflow Shutdown_VM | |
| { | |
| $Cred = Get-AutomationPSCredential -Name "Credential_Name" | |
| $tenant = Get-AutomationVariable -Name "tenant" | |
| Login-AzureRmAccount -Credential $Cred -ServicePrincipal -TenantId $tenant | |
| $subscription = Get-AutomationVariable -Name "subscription" | |
| Select-AzureRmSubscription -SubscriptionName $subscription | |
| $VMs = Get-AzureRmVM | where {$_.Name -match 'Virtual_Machine_Name'} |
OlderNewer