Skip to content

Instantly share code, notes, and snippets.

View JanVidarElven's full-sized avatar

Jan Vidar Elven JanVidarElven

View GitHub Profile
@JanVidarElven
JanVidarElven / deploy-security-copilot.yml
Created April 5, 2024 19:22
Deploy or Destroy Copilot for Security Capacity with Bicep and DevOps Pipelines
name: CD-$(rev:r)-Deploy-Security-Copilot-$(Date:dd.MM.yyyy) # build numbering format
trigger: none
schedules:
- cron: "0 7 * * 1-5"
displayName: Morning weekdays
branches:
include:
- main
@JanVidarElven
JanVidarElven / AzureAD_SelfSignedCert_AppCreds.ps1
Last active November 20, 2023 13:04
Application Certificate Credentials
# Connecting with Azure AD PowerShell Module to Manage Application Credentials for Self Signed Certificates
# Connecting to Tenant
$tenantId = 'elven.onmicrosoft.com'
Connect-AzureAD -TenantId $tenantId
# Get an existing application and set some variables
$myApp = Get-AzureADApplication -SearchString "MyDemoCertApp"
@JanVidarElven
JanVidarElven / AddManagedIdentityMSGraphAppRoles.md
Last active March 15, 2022 09:36
ManagedIdentityAddMSGraphAppRoles

Add Microsoft Graph Applications Permissions (Roles Claim) to MSI

The following commands must be run in Windows PowerShell and with the AzureAD Module. Remember to Connect-AzureAD with Global Administrator Privileges first.

Part 1 - Get Managed Identity Service Principal

Display Name of Managed Identity

# Get SPN based on MSI Display Name
@JanVidarElven
JanVidarElven / GetTeamsAdminCenterToken.ps1
Last active March 1, 2021 20:41
GetTeamsAdminCenterToken
# Connect to Azure AD Organization as Admin
Connect-AzureAD
#region Part 1 - Azure AD App
# Create a new App Registration for Teams Admin Center
$azureAdApp = New-AzureADApplication -DisplayName "Teams Admin Center API" -ReplyUrls "https://localhost", "urn:ietf:wg:oauth:2.0:oob"
$keyStartDate = "{0:s}" -f (get-date).AddHours(-1) + "Z"
$keyEndDate = "{0:s}" -f (get-date).AddYears(1) + "Z"
@JanVidarElven
JanVidarElven / GetMyPIMAzureADRoles.ps1
Last active February 19, 2021 08:37
PIM Automation
# Requires Windows PowerShell
# Requires AzureADPreview PowerShell Module
# Connect to Azure AD
Connect-AzureAD
# Get Tenant Detail
$tenant = Get-AzureADTenantDetail
# Get User
swagger: '2.0'
info: {title: JanVidarElven Github Connector, description: GitHub API Connector for
JanVidarElven, version: '1.0'}
host: api.github.com
basePath: /
schemes: [https]
consumes: []
produces: []
paths:
/repos/{owner}/{repo}/contents/{path}:
# Azure AD PowerShell CmdLets for Managing Privileged Roles
# Connect to Azure AD
Connect-AzureAD
@JanVidarElven
JanVidarElven / AzureAutomationAuthToAzureADwithServicePrincipal.ps1
Created July 11, 2018 11:03
AzureAutomationAuthToAzureADwithServicePrincipal
<#
.SYNOPSIS
This Azure Automation runbook connects to Azure AD with a Service Principal and Connect-AzureAD.
.DESCRIPTION
This Azure Automation runbook connects to Azure AD with a Service Principal and Connect-AzureAD.
It uses an Azure Run As Account connection that must be created before.
You have to import the AzureAD module from the Automation module gallery, if it's not already there.
AUTHOR: Jan Vidar Elven [MVP]
@JanVidarElven
JanVidarElven / New-AadApp1803.1_OfflineToken.ps1
Created March 16, 2018 15:12
Offline token version for register Azure AD App for Project Honolulu 1803 when on Windows Server 1709 or other Server Core
<#########################################################################################################
File: New-AadApp.ps1
Copyright (c) Microsoft Corp 2017.
.SYNOPSIS
Creates a web app in AAD and registers it with the SME gateway.
.DESCRIPTION
@JanVidarElven
JanVidarElven / ManageAzureADAppProxyConnector.ps1
Last active April 27, 2018 11:00
AzureADAppProxyConnector
# AzureAD PowerShell CmdLets to Manage Azure AD App Proxy Connector
# Connect to Azure AD
Connect-AzureAD
# Retrieve Application Proxy Connectors
Get-AzureADApplicationProxyConnector | Select-Object Id, MachineName, ExternalIp, Status
# Get Application Proxy Connectors by Filter
Get-AzureADApplicationProxyConnector -Filter "startswith(MachineName,'ELVEN')"