Skip to content

Instantly share code, notes, and snippets.

@JasonDTX
JasonDTX / get-userfromdevicegroup-verbose.ps1
Created May 29, 2025 17:36
Verbose/ProgressBar version - Intune Get Users from Dynamic Device Groups Powershell Function
function get-userfromdevicegroup {
<#
.SYNOPSIS
Retrieves user information for devices in a specified Azure AD group using Microsoft Graph.
.DESCRIPTION
This function connects to Microsoft Graph, retrieves all members (devices) of a specified Azure AD group,
and for each device, uses Get-MgDeviceRegisteredOwner to find the registered user(s).
It returns user and device details for reporting or automation purposes.
@JasonDTX
JasonDTX / Get-UserFromDeviceGroup.ps1
Created May 29, 2025 17:30
Intune Get Users from Dynamic Device Groups Powershell Function
function Get-UserFromDeviceGroup {
<#
.SYNOPSIS
Retrieves user information for devices in a specified Azure AD group using Microsoft Graph.
.PARAMETER GroupName
The display name of the Azure AD group containing devices.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
#region ERRORHANDLING
Try {
# Make sure scriptname exists for creating ticket subject line
If ($null -eq $scriptname -or $scriptname -notlike "*.ps1") {
If ( $null -ne $BuildScript) { $scriptName = $BuildScript }
ElseIf ($null -ne $env:scriptname) { $scriptName = $env:scriptName }
Else { $scriptname -eq "$($PSItem.InvocationInfo.ScriptName)" }
}
# Make sure the application ID and api secret are available
If ($Env:ManageEngineClientID) { $Config.ManageEngine.ClientID = $Env:ManageEngineClientID }
@JasonDTX
JasonDTX / Invoke-ManageEngineRequest.ps1
Created May 21, 2025 19:38
function Invoke-ManageEngineRequest
function global:Invoke-ManageEngineRequest {
<#
.SYNOPSIS
Creates a new ticket in ManageEngine ServiceDesk Plus
.DESCRIPTION
This function is used to create a new ticket in ManageEngine ServiceDesk Plus using a REST API Call.
.Parameter ManageEngineURI
The URI for the ManageEngine API
.PARAMETER AttachmentPath
The path to the file to upload to the ticket (optional)
@JasonDTX
JasonDTX / Microsoft.PowerShell_Profile.ps1
Created May 21, 2025 14:32
Example Powershell Profile for PSReadline, Oh-My-Posh, and auto-complete
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost') {
Import-Module PSReadLine
}
Import-Module -Name Terminal-Icons
oh-my-posh --init --shell pwsh --config $env:POSH_THEMES_PATH/jandedobbeleer.omp.json | Invoke-Expression
oh-my-posh --init --shell powershell --config $env:POSH_THEMES_PATH/jandedobbeleer.omp.json | Invoke-Expression
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
@JasonDTX
JasonDTX / function Get-RDAPWhois.ps1
Created May 15, 2025 20:08
Get-RDAPWhois, Powershell WHOIS
function Get-RDAPWhois {
[CmdletBinding()]
Param(
[Parameter(Position = 0, Mandatory, HelpMessage = "Enter an IP Address. Both IPv4 and IPv6 are supported", ValueFromPipeline, ValueFromPipelineByPropertyName)]
[ValidateScript({ $_ -as [ipaddress] })]
[string]$IP ## Mandatory variable: IP address to query.
)
try {
$rdapBaseUrl = "https://rdap.arin.net/registry" ## Set the RDAP url to query. This is the ARIN RDAP server.
@JasonDTX
JasonDTX / function Get-RDAPWhois.ps1
Last active May 15, 2025 20:14
function Get-RDAPWhois
function Get-RDAPWhois {
[CmdletBinding()]
Param(
[Parameter(Position = 0, Mandatory, HelpMessage = "Enter an IP Address. Both IPv4 and IPv6 are supported", ValueFromPipeline, ValueFromPipelineByPropertyName)]
[ValidateScript({ $_ -as [ipaddress] })]
[string]$IP ## Mandatory variable: IP address to query.
)
try {
$rdapBaseUrl = "https://rdap.arin.net/registry" ## Set the RDAP url to query. This is the ARIN RDAP server.
@JasonDTX
JasonDTX / Function Get-MGUserCalendarEvents.ps1
Last active May 15, 2025 20:14
Function Get-MGUserCalendarEvents.ps1
#Requires -Version 5.0
Function Get-MGUserCalendarEvents {
<#
.SYNOPSIS
This script will connect to the Microsoft Graph API and retrieve all calendar events for a list of users.
.DESCRIPTION
This script will connect to the Microsoft Graph API and retrieve all calendar events for a list of users.
.PARAMETER ClientID
The Client ID of the Azure AD Application
We couldn’t find that file to show.
@JasonDTX
JasonDTX / DoMSOLLicenseServicePlanstuff.psm1
Last active November 4, 2021 19:54
Microsoft MSOL License Plan Option functions - for enabling or disabling one or more options in a 365 License
function Get-MsolLicenseServicePlan {
<#
.SYNOPSIS
Enables service plans from MSOnline licenses applied to users.
.DESCRIPTION
Will enable one or more service plans from a user's MSOnline account or specific MSOnline license on an account.
.EXAMPLE
Get-MsolLicenseServicePlan -UserPrincipalName user@domain.com
List all service plans from all licenses for a single user
.EXAMPLE