Skip to content

Instantly share code, notes, and snippets.

View kevinblumenfeld's full-sized avatar
🎯
Focusing

Kevin Blumenfeld kevinblumenfeld

🎯
Focusing
View GitHub Profile
@kevinblumenfeld
kevinblumenfeld / Set-StandardMember.ps1
Created March 1, 2023 02:34 — forked from santisq/Set-StandardMember.ps1
sets PSStandardMember for all input objects
using namespace System.Management.Automation
function Set-StandardMember {
[CmdletBinding()]
param(
[parameter(Mandatory, ValueFromPipeline)]
[object] $InputObject,
[parameter(Mandatory)]
[string[]] $DefaultProperties
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.Collections.Hashtable</T>
<T>System.Object</T>
</TN>
<DCT>
<En>
<S N="Key">SourceApp</S>
<Obj N="Value" RefId="1">
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using DotNetCoreRazor_MSGraph.Graph;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
function Remove-GraphGroupMember {
<#
.SYNOPSIS
Removes Members from Azure AD Security Group or Microsoft 365 Group
.DESCRIPTION
Removes Members from Azure AD Security Group or Microsoft 365 Group
.PARAMETER UserID
This is the User's ID. This is the user to be removed from the group
Find-MgGraphCommand
Find-MgGraphPermission
Get-MgSecurityAction
Get-MgSecurityAlert
Get-MgSecurityAttackSimulation
Get-MgSecurityCloudAppSecurityProfile
Get-MgSecurityDomainSecurityProfile
Get-MgSecurityFileSecurityProfile
Get-MgSecurityHostSecurityProfile
Get-MgSecurityIncident
## Usage
# GUI that saves and encrypts credentials that generate Bearer Token (Run this once per app registration)
# If application-only Graph API Permision, click "Export Tenant Config" button
# If also (or only) delegate permissions click both "Export Tenant Config" and "Export Tenant Credentials" buttons
# Copy the last command output from the GUI. This is how you connect each time.
Add-GraphConfig -Tenant Contoso -workload DescribePermissions
# GUI will provide exactly what to use to connect
Connect-Graph -Tenant Contoso -Workload DescribePermissions #use -Delegated switch if needed
function Connect-GraphRefresh {
[CmdletBinding()]
param (
)
if (-not $Delegated) {
Connect-Graph -Tenant $Script:Tenant -Workload $Script:Workload -Delegated:$Script:Delegated
}
else {
function Connect-Graph {
<#
.SYNOPSIS
Connect to Graph with delegate or application only permissions
.DESCRIPTION
Connect to Graph with delegate or application only permissions
.PARAMETER Tenant
** Use NameOfTenant if the tenant domain is NameOfTenant.onmicrosoft.com **
function Add-GraphConfig {
<#
.SYNOPSIS
Create the encrypted file needed to connect to Microsoft Graph using: Connect-Graph
.DESCRIPTION
Create the encrypted file needed to connect to Microsoft Graph using: Connect-Graph
.PARAMETER Tenant
use NameOfTenant if the tenant domain is NameOfTenant.onmicrosoft.com
function Hide-PSGCalendar {
<#
.SYNOPSIS
if Owner of Calendar...
1. Remove as Owner from Calendar, if not chosen by client in PrimaryOwnerFilePath
2. Add as Editor to Calendar
3. Hide Calendar if #1 and #2 does not work
.DESCRIPTION