Skip to content

Instantly share code, notes, and snippets.

View jorgeasaurus's full-sized avatar

Jorge Suarez jorgeasaurus

View GitHub Profile
@jorgeasaurus
jorgeasaurus / Get-StoicQuote.ps1
Created January 26, 2025 03:15
Fetches a random Stoicism quote from a free API.
function Get-StoicQuote {
<#
.SYNOPSIS
Fetches a random Stoicism quote from the Stoic API.
.DESCRIPTION
This function retrieves a random Stoicism quote from the API and displays the
author and quote to the user. The API does not require authentication.
.EXAMPLE
@jorgeasaurus
jorgeasaurus / Update-Modules.ps1
Created January 1, 2025 21:25
Update PowerShell modules to their latest versions using PowerShell 7 parallel processing.
#Requires -Version 7.0
<#
.SYNOPSIS
Updates PowerShell modules to their latest versions.
.DESCRIPTION
Updates all or specified PowerShell modules to their latest versions, with options for
prerelease versions and parallel processing. Automatically removes older versions after update.
.PARAMETER AllowPrerelease
If specified, allows updating to prerelease versions.
.PARAMETER Name
# Output
Write-Output "Hello, World!" # Outputs: Hello, World!
# Variables
$x = 5 # Integer variable
$name = "Alice" # String variable
$a, $b, $c = 1, 2, 3 # Multiple assignments
# Data Types
$integer = 10 # [int]
@jorgeasaurus
jorgeasaurus / Find-MgGraphPermissions
Last active August 31, 2024 18:13
Powershell tip: Quickly find required Microsoft Graph API permissions for a list of graph cmdlets.
"Get-MgBetaUser",
"Get-MgBetagroup",
"Sync-MgBetaDeviceManagementDepOnboardingSettingWithAppleDeviceEnrollmentProgram",
"Get-MgBetaDeviceAppManagementMobileApp",
"Sync-MgBetaDeviceAppManagementVppTokenLicense",
"Get-MgBetaDeviceAppManagementVppToken" | % {
$cmdlet = $_
Find-MgGraphCommand $cmdlet | select -ExpandProperty Permissions
} | Sort-Object Name -Unique
@jorgeasaurus
jorgeasaurus / Get-PSModuleUpdates.ps1
Created August 31, 2024 17:35
Check installed PowerShell modules against latest versions in a repository. Outputs detailed update status for easy management of outdated modules.
function Get-PSModuleUpdates {
param
(
[Parameter(ValueFromPipelineByPropertyName, Mandatory)]
[string]$Name,
[Parameter(ValueFromPipelineByPropertyName, Mandatory)]
[version]$Version,
[Parameter(ValueFromPipelineByPropertyName)]