From ce77d1eef9cef80feefae9e483a4aa23c60b0f4b Mon Sep 17 00:00:00 2001 From: Luis Raul Espinoza Barboza Date: Fri, 12 Feb 2021 11:34:40 -0700 Subject: [PATCH] power shell scripts demo --- InfrastructureAsCode-IaC/demo.ps1 | 18 ++++++++++++++++++ InfrastructureAsCode-IaC/readme.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 InfrastructureAsCode-IaC/demo.ps1 create mode 100644 InfrastructureAsCode-IaC/readme.md diff --git a/InfrastructureAsCode-IaC/demo.ps1 b/InfrastructureAsCode-IaC/demo.ps1 new file mode 100644 index 0000000..e3977e9 --- /dev/null +++ b/InfrastructureAsCode-IaC/demo.ps1 @@ -0,0 +1,18 @@ +# Fill in the Name of the ServicePrincipal you just created and the subscription you want to use +$SPName = "GitHubAzureConnections" +$AzSubscriptionName = "Free Trial" + +Connect-AzureAD + +$Subscription = (Get-AzSubscription -SubscriptionName $AzSubscriptionName) +$ServicePrincipal = Get-AzADServicePrincipal -DisplayName $SPName +$AzureADApplication = Get-AzureADApplication -SearchString $SPName + +$OutputObject = [PSCustomObject]@{ + clientId = $ServicePrincipal.ApplicationId + clientSecret = (New-AzureADApplicationPasswordCredential -ObjectId $AzureADApplication.ObjectId).Value + subscriptionId = $Subscription.Id + tenantId = $Subscription.TenantId +} + +$OutputObject | ConvertTo-Json \ No newline at end of file diff --git a/InfrastructureAsCode-IaC/readme.md b/InfrastructureAsCode-IaC/readme.md new file mode 100644 index 0000000..c4e0052 --- /dev/null +++ b/InfrastructureAsCode-IaC/readme.md @@ -0,0 +1,29 @@ + + +https://www.powershellgallery.com/ +https://github.com/Azure/azure-powershell/releases + + +Download version +7 + +https://winaero.com/how-to-install-powershell-7-in-windows-10/ + +if you faced problems + +https://stackoverflow.com/questions/56238475/connect-azurermaccount-the-term-connect-azurermaccount-is-not-recognized-as + +Install-Module AzureADPreview +Install-Module AzureAD -Force + +you'll able to connect to azure + + +##To find the PowerShell version in Windows, +- Open PowerShell.Tip: You can add "Open PowerShell As Administrator" context menu. +- Type or copy-paste the following command: Get-Host | Select-Object Version. +- In the output, you will see the version of PowerShell. +- Alternatively, type $PSVersionTable and hit the Enter key. +- See the PSVersion line. + + +https://4bes.nl/2020/06/28/step-by-step-test-and-deploy-arm-templates-with-github-actions/