- Short link to this Gist: timw.info/bicep2022
- Tim's website
- Tim's Twitter
- Tim's "Frankenstein" repository
This file contains 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
#requires -version 7 | |
using namespace Microsoft.Graph.PowerShell.Models | |
using namespace System.Collections.Generic | |
function Get-MgServicePrincipalPermission { | |
param( | |
[Parameter(ParameterSetName='Id',ValueFromPipelineByPropertyName)][Alias('Id')][string]$ServicePrincipalId, | |
[Parameter(ParameterSetName='Object',ValueFromPipeline)][Microsoft.Graph.PowerShell.Models.MicrosoftGraphServicePrincipal]$ServicePrincipal | |
) | |
begin { |
This file contains 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
Get Permissions | |
# MS Graph Permissions | |
(Get-AzAdServicePrincipal -ApplicationId 00000003-0000-0000-c000-000000000000).AppRole | Select * | |
(Get-AzAdServicePrincipal -ApplicationId 00000003-0000-0000-c000-000000000000).Oauth2PermissionScope | Select * | |
# Azure AD Graph | |
(Get-AzAdServicePrincipal -ApplicationId 00000002-0000-0000-c000-000000000000).AppRole | Select * | |
(Get-AzAdServicePrincipal -ApplicationId 00000002-0000-0000-c000-000000000000).Oauth2PermissionScope | Select * |
This file contains 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
using namespace system.collections.generic | |
function Get-ParamBlock ([String[]]$Name) { | |
[hashset[string]]$params = $PSCmdlet.MyInvocation.MyCommand.Parameters.Keys | |
$params.ExceptWith([string[]]([PSCmdlet]::CommonParameters + [PSCmdlet]::OptionalCommonParameters)) | |
$result = @{} | |
if ($Name) {$params = $params -in $Name} | |
foreach ($name in $params) { | |
$result.$name = $PSCmdlet.GetVariableValue($name) | |
} | |
return $result |
This file contains 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
using namespace System.Threading.Tasks | |
using namespace System.Collections.Generic | |
filter Receive-Task { | |
#Wait on one or more tasks in a cancellable manner | |
[CmdletBinding()] | |
param( | |
[parameter(Mandatory, ValueFromPipeline)][Task]$Task, | |
#How long to wait before checking for a cancellation in milliseconds | |
[int]$WaitInterval = 500 | |
) |
This file contains 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
#requires -version 7 | |
#You can load this script with $(iwr https://tinyurl.com/TraceAICommand | iex) | |
using namespace Microsoft.ApplicationInsights | |
using namespace Microsoft.ApplicationInsights.Extensibility | |
using namespace Microsoft.ApplicationInsights.DataContracts | |
using namespace System.Management.Automation | |
using namespace System.Collections.Generic | |
using namespace System.Net | |
#Reference: https://docs.microsoft.com/en-us/azure/azure-monitor/app/console |
This file contains 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
$daysToExpire = 30 | |
$SoonToBeExpiredList = @() | |
$AlreadyExpiredList = @() | |
# Connect to AzureAD | |
Write-Output "Connecting to AzureAD..." | |
$connection = Get-AutomationConnection -Name AzureRunAsConnection | |
Connect-AzureAD -TenantId $connection.TenantID -ApplicationId $connection.ApplicationID -CertificateThumbprint $connection.CertificateThumbprint |
This file contains 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
# THIS HASN'T BEEN ADDED TO THE KBUPDATE REPO YET BUT WILL BE WHEN I GET A MOMENT | |
function Install-KbPatch { | |
<# | |
.SYNOPSIS | |
Installs KBs on local and remote servers on Windows-based systems | |
.DESCRIPTION | |
Installs KBs on local and remote servers on Windows-based systems | |
PowerShell 5.1 must be installed and enabled on the target machine and the target machine must be Windows-based |
This file contains 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
[CmdletBinding()] | |
param ( | |
$authorisation, | |
$pathFilter, | |
$collectionUri, | |
$project, | |
$buildId | |
) | |
$changesUrl = "$collectionUri/$project/_apis/build/builds/$buildId/changes?api-version=6.0" |
This file contains 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
function Open-GHWebEditor { | |
<# | |
.SYNOPSIS | |
Opens the GitHub web editor on a repo. | |
.EXAMPLE | |
Open-GHWebEditor powerShell/powerShell | |
#> | |
param( | |
[Parameter(Mandatory)] |
NewerOlder