Skip to content

Instantly share code, notes, and snippets.

@Kadazz
Kadazz / Get-MgServicePrincipalPermission.ps1
Created December 5, 2022 15:34 — forked from JustinGrote/Get-MgServicePrincipalPermission.ps1
Get a list of application and delegated permissions for a service principal, similar to what the Azure Portal shows
#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)][MicrosoftGraphServicePrincipal]$ServicePrincipal
)
begin {
# Show message box popup.
Add-Type -AssemblyName System.Windows.Forms
$result = [System.Windows.Forms.MessageBox]::Show("My message", "Window Title", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::None)
# Show input box popup.
Add-Type -AssemblyName Microsoft.VisualBasic
$inputText = [Microsoft.VisualBasic.Interaction]::InputBox("Enter some value:", "Window Title", "Default value")
# Show an Open File Dialog and return the file selected by the user.
function Read-OpenFileDialog([string]$InitialDirectory, [switch]$AllowMultiSelect)
@Kadazz
Kadazz / Add-TimeSpan.sp1
Created August 11, 2022 10:33 — forked from thedavecarroll/Add-TimeSpan.sp1
Simple function to add timespan
function Add-TimeSpan {
[CmdLetBinding(DefaultParameterSetName='TimeSpan')]
param(
[Parameter()]
[datetime]$Timestamp = (Get-Date),
[Parameter(Mandatory,ParameterSetName='TimeSpan')]
[timespan]$TimeSpan,
[Parameter(ParameterSetName='TimeSlice')]
[int]$Days,
[Parameter(ParameterSetName='TimeSlice')]
@Kadazz
Kadazz / JSON_Config.ps1
Created August 1, 2022 13:54 — forked from jhochwald/JSON_Config.ps1
How to use a JSON based config file with PowerShell Modules or Scripts
<#
{
"info": {
"Statement": "Code is poetry",
"Author": "Joerg Hochwald",
"Contact": "joerg.hochwald@outlook.com",
"Link": "http://hochwald.net",
"Support": "https://github.com/jhochwald/MyPowerShellStuff/issues"
},
"Copyright": "(c) 2012-2015 by Joerg Hochwald. All rights reserved."