Skip to content

Instantly share code, notes, and snippets.

@joegasper
joegasper / Remotely-Install-RSAT-with-PowerShell.md
Last active July 26, 2024 18:36
RSAT apps - How to Remotely Install RSAT with PowerShell

How to remotely install RSAT tools with PowerShell

How to get around Access Denied COM object issue

Access is denied.

    + CategoryInfo          : NotSpecified: (:) [Add-WindowsCapability], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.AddWindowsCapabilityCommand
@joegasper
joegasper / Send-SyslogMessage.ps1
Last active July 8, 2024 22:24
Send Syslog Message in PowerShell
function Send-SyslogMessage {
#region Parameters
[CmdletBinding(PositionalBinding = $false,
ConfirmImpact = 'Medium')]
[Alias()]
[OutputType([String])]
Param
(
# The message to send
@joegasper
joegasper / Send-IpMessage.ps1
Last active July 8, 2024 22:13
Send TCP Message in PowerShell
<#
.SYNOPSIS
Sends an IP message (TCP or UDP) to a specified endpoint and port.
.DESCRIPTION
The Send-IpMessage function sends a message over the specified IP protocol (TCP or UDP) to a specified endpoint and port.
It supports sending messages with or without a CRLF (Carriage Return Line Feed) at the end of the message.
.PARAMETER EndPoint
The endpoint (IP address or hostname) to which the message will be sent.
@joegasper
joegasper / Invoke-TcpListener.ps1
Last active September 9, 2024 16:26
TCP Listener in PowerShell
function Invoke-TcpListener {
<#
.SYNOPSIS
Starts a TCP listener on a specified port.
.DESCRIPTION
This function starts a TCP listener on a specified port, accepts incoming connections,
reads messages, and writes them to the terminal. It stops listening if the received
message is "exit".
@joegasper
joegasper / Get-OneDriveFileInfo.ps1
Last active June 20, 2024 03:56
Get-OneDriveFileInfo.ps1
# Connect to the SharePoint site
Connect-PnPOnline -Url "YourSiteURL" -Credentials
# Specify the name of your Document Library
$DocLib = 'Documents'
# Retrieve all items from the Document Library in batches
$ListItems = Get-PnPListItem -List $DocLib -PageSize 2000 -ScriptBlock {
Param($items)
@joegasper
joegasper / Update-AfsStorageSyncAgent.ps1
Last active February 16, 2024 12:22
PowerShell function to update Azure File Sync (AFS) Storage Agent on computer(s).
<#
.SYNOPSIS
Updates the Azure Files Storage Sync Agent on specified computers.
.DESCRIPTION
This cmdlet updates the Azure Files Storage Sync Agent on the specified computers by retrieving the installation directory from the registry, importing the update agent module DLL, and running the update process.
.PARAMETER ComputerName
Specifies the computer name on which the Azure Files Storage Sync Agent will be updated.
@joegasper
joegasper / Get-M365GroupsForUser.ps1
Created October 31, 2023 02:14
Microsoft 365 Group memberships for a user or summary report using ActiveDirectory module
<#
.Synopsis
Microsoft 365 Group memberships for a user or summary report
.DESCRIPTION
Output a list of a user's modern group memberships (Teams, Engage, Planner, Groups) or summary report
.EXAMPLE
Get-M365GroupsForUser -UserName pvenkman | sort DisplayName | select DisplayName,Description
.EXAMPLE
Get-M365GroupsForUser -UserName pvenkman -Report | where Owners -like "*rsantz*"
.EXAMPLE
@joegasper
joegasper / Get-M365GroupsOwned.ps1
Created October 31, 2023 02:10
Display Microsoft 365 Groups owned by a user using the ActiveDirectory module and msExchCoManagedByLink attribute
<#
.Synopsis
Display Microsoft 365 Groups owned by a user.
.DESCRIPTION
Display modern groups (Microsoft 365 Group, Microsoft Teams, Planner, Viva Engage, etc.)
of which the user is an owner. Script requires synchronization of modern groups to the
operator's Active Directory and the operator has permissions to read user object attributes.
The script requires the PowerShell module "ActiveDirectory".
.EXAMPLE
Get-M365GroupsOwned -UserName pvenkman | select DisplayName,Name
@joegasper
joegasper / PS-BGInfo.ps1
Created October 31, 2023 01:36 — forked from dieseltravis/PS-BGInfo.ps1
update wallpaper background image with powershell (like Sysinternals BGInfo)
# PS-BGInfo
# Powershell script that updates the background image with a random image from a folder and writes out system info text to it.
# run as a lower priority task
[System.Threading.Thread]::CurrentThread.Priority = 'BelowNormal'
# Configuration:
# Font Family name
$font="Input"
@joegasper
joegasper / GPU-P-Partitioning.ps1
Last active September 19, 2023 15:57
GPU-P Partitioning Script
# Name of Hyper-V VM
$vm = "MyVMName"
# Total VRAM of physical GPU (GPU-P)
$TotalGPUpVram = 6Gb
# Percent of physical GPU resources to allocate to virtual GPU in the VM
[int]$GPUpAllocationPercent = 25
# Calculate the high memory mapped IO value based on total GPU-P VRAM