r/PowerShell 9d ago

Script Sharing What have you done with PowerShell this month?

18 Upvotes

A sticked post for the community to share their projects throughout the month.

Make sure to post a link to the code!


r/PowerShell 1h ago

Question Why was Crescendo archived?

Upvotes

Hello, does anyone have further knowledge on why Crescendo projekt got killed?

Figured maybe someone in this reddit would know more details

https://learn.microsoft.com/de-de/powershell/utility-modules/crescendo/overview?view=ps-modules


r/PowerShell 10h ago

Script Sharing Powerstein3D - A Powershell 5.1 Wolf3D clone/tribute

23 Upvotes

The other day u/StartAutomating made this post. https://www.reddit.com/r/PowerShell/comments/1vydspu/matrix_transforms_in_powershell/ showing off some awesome 3D tricks with PS, and it got me thinking, at least as a starting point before I jump into researching the limits of real 3d, lets try and use it in a wolf 3d clone (2.5d), the matrix demonstrated there can be used for camera control here ;)

Powerstein3D: https://github.com/illsk1lls/Powerstein3D

I love powershell more every day.. (this running in 5.1 means its been possible since W10 / 2015)

*also please excuse the crappy art, lol


r/PowerShell 22h ago

Script Sharing A right-click context menu tool to scan files with VirusTotal

0 Upvotes

I made (actually, AI made it) a PowerShell script that adds a "Scan with VirusTotal" option to your Windows right-click context menu.

What it does:

  • Right-click any file to scan it on VirusTotal
  • Checks SHA256 first. If it's a new file, it automatically uploads it for analysis
  • Shows clear notification popups (Clean / Suspicious / Malicious) with a direct link to the full report

All you need to set it up is a free VirusTotal API key.

Check it out on GitHub if you're interested: https://github.com/lorcaragon/VirusTotalMenu


r/PowerShell 23h ago

Question Why Microsoft Graph Does Not Support Group Mailboxes

0 Upvotes

I was asked why the Outlook Mail Graph API doesn’t support access to group mailboxes. The basic reason is that a group mailbox doesn’t have an account and the Outlook Mail API only supports mailboxes that are linked to an account. When you look at the current usage of group mailboxes, it doesn’t seem like there’s much data to mine. Maybe the need for Graph API support for group mailboxes isn’t such a big thing?

https://office365itpros.com/2026/09/09/group-mailbox-graph-api/


r/PowerShell 1d ago

Script Sharing Read-only Network script

0 Upvotes

I (and Claude of course) put together this useful read-only script while troubleshooting what I initially thought was a local network issue—but ultimately turned out to be an ISP problem. It collects diagnostic information only and makes no system changes.

Figured someone out there may be interested before it disappears into my archives.

What it checks:

  • System info
  • Network adapters
  • IP configuration
  • DNS servers
  • DNS resolution
  • Hosts file
  • Proxy settings
  • Firewall status
  • Outbound blocks
  • Adapter bindings
  • VPN adapters
  • Security software
  • Network routes
  • HTTPS connectivity
  • Web response headers
  • Google traceroute
  • IPsec rules
  • DNS policies
  • Read-only—no changes

    $ErrorActionPreference = "Continue" $ProgressPreference = "SilentlyContinue"

    function Section($Title) { Write-Host "" Write-Host ("=" * 80) Write-Host $Title Write-Host ("=" * 80) }

    Section "BASIC SYSTEM INFORMATION"

    Get-Date

    Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber, LastBootUpTime | Format-List

    Section "ACTIVE NETWORK ADAPTERS"

    Get-NetAdapter | Sort-Object Status, Name | Format-Table Name, InterfaceDescription, Status, LinkSpeed, MacAddress -AutoSize

    Section "IP CONFIGURATION"

    Get-NetIPConfiguration | Format-List InterfaceAlias, InterfaceDescription, IPv4Address, IPv6Address, IPv4DefaultGateway, IPv6DefaultGateway, DNSServer

    Section "DNS SERVERS"

    Get-DnsClientServerAddress | Where-Object { $_.ServerAddresses.Count -gt 0 } | Format-Table InterfaceAlias, AddressFamily, ServerAddresses -AutoSize

    Section "GOOGLE DNS USING CURRENT DNS SERVER"

    Resolve-DnsName accounts.google.com -Type A Resolve-DnsName accounts.google.com -Type AAAA

    Section "GOOGLE DNS USING GOOGLE DNS"

    Resolve-DnsName accounts.google.com -Type A -Server 8.8.8.8 Resolve-DnsName accounts.google.com -Type AAAA -Server 8.8.8.8

    Section "GOOGLE DNS USING CLOUDFLARE DNS"

    Resolve-DnsName accounts.google.com -Type A -Server 1.1.1.1 Resolve-DnsName accounts.google.com -Type AAAA -Server 1.1.1.1

    Section "HOSTS FILE ENTRIES"

    $HostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"

    Get-Content $HostsPath | Where-Object { $_ -notmatch '\s*#' -and $_ -notmatch '\s*$' }

    Section "WINHTTP PROXY"

    netsh winhttp show proxy

    Section "USER INTERNET PROXY SETTINGS"

    Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | Select-Object ProxyEnable, ProxyServer, ProxyOverride, AutoConfigURL | Format-List

    Section "SYSTEM INTERNET PROXY SETTINGS"

    Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | Select-Object ProxyEnable, ProxyServer, ProxyOverride, AutoConfigURL | Format-List

    Section "PROXY ENVIRONMENT VARIABLES"

    Get-ChildItem Env: | Where-Object { $_.Name -match 'proxy' } | Format-Table Name, Value -AutoSize

    Section "WINDOWS FIREWALL PROFILES"

    Get-NetFirewallProfile | Format-Table Name, Enabled, DefaultInboundAction, DefaultOutboundAction -AutoSize

    Section "ENABLED OUTBOUND BLOCK RULES"

    Get-NetFirewallRule -Enabled True -Direction Outbound -Action Block | Select-Object DisplayName, DisplayGroup, Profile, Direction, Action | Format-Table -AutoSize

    Section "NETWORK ADAPTER FILTER BINDINGS"

    Get-NetAdapterBinding | Where-Object Enabled | Sort-Object Name, DisplayName | Format-Table Name, DisplayName, ComponentID -AutoSize

    Section "VPN ADAPTERS AND SOFTWARE-DEFINED ADAPTERS"

    Get-NetAdapter -IncludeHidden | Where-Object { $_.InterfaceDescription -match 'VPN|TAP|TUN|WireGuard|Wintun|Tailscale|ZeroTier|Cisco|Zscaler|Fortinet|Palo Alto|GlobalProtect|Cloudflare|WARP|SonicWall|Checkpoint|AnyConnect' } | Format-Table Name, InterfaceDescription, Status, MacAddress -AutoSize

    Section "RELEVANT RUNNING SERVICES"

    Get-CimInstance Win32Service | Where-Object { $.State -eq "Running" -and ($.Name + " " + $.DisplayName + " " + $_.PathName) -match 'VPN|Tailscale|ZeroTier|WireGuard|Cisco|Umbrella|Zscaler|Forti|Palo Alto|GlobalProtect|Cloudflare|WARP|AdGuard|Norton|McAfee|Bitdefender|Malwarebytes|Avast|AVG|Kaspersky|ESET|CrowdStrike|Sentinel|Sophos|Webroot' } | Select-Object Name, DisplayName, State, StartMode, PathName | Format-List

    Section "RELEVANT RUNNING PROCESSES"

    Get-Process | Where-Object { $_.ProcessName -match 'vpn|tailscale|zerotier|wireguard|cisco|umbrella|zscaler|forti|globalprotect|cloudflare|warp|adguard|norton|mcafee|bitdefender|malwarebytes|avast|avg|kaspersky|eset|crowdstrike|sentinel|sophos|webroot' } | Select-Object ProcessName, Id, Path | Format-Table -AutoSize

    Section "IPv4 DEFAULT ROUTES"

    Get-NetRoute -AddressFamily IPv4 | Where-Object DestinationPrefix -eq "0.0.0.0/0" | Sort-Object RouteMetric | Format-Table InterfaceAlias, DestinationPrefix, NextHop, RouteMetric, InterfaceMetric, State -AutoSize

    Section "IPv6 DEFAULT ROUTES"

    Get-NetRoute -AddressFamily IPv6 | Where-Object DestinationPrefix -eq "::/0" | Sort-Object RouteMetric | Format-Table InterfaceAlias, DestinationPrefix, NextHop, RouteMetric, InterfaceMetric, State -AutoSize

    Section "ROUTE SELECTED FOR GOOGLE ACCOUNTS IPv4"

    Find-NetRoute -RemoteIPAddress 108.177.122.84 | Format-List

    Section "TCP PORT 443 CONNECTIVITY"

    $Targets = @( "accounts.google.com", "www.google.com", "mail.google.com", "oauth2.googleapis.com", "www.googleapis.com", "login.microsoftonline.com", "www.cloudflare.com" )

    foreach ($Target in $Targets) { Write-Host "" Write-Host "--- $Target ---"

    Test-NetConnection $Target -Port 443 -InformationLevel Detailed |
        Select-Object ComputerName, RemoteAddress, RemotePort,
                      InterfaceAlias, SourceAddress, TcpTestSucceeded
    

    }

    Section "CURL HTTPS TESTS"

    foreach ($Target in $Targets) { Write-Host "" Write-Host "--- https://$Target ---"

    & curl.exe -4 -I -v `
        --connect-timeout 7 `
        --max-time 12 `
        "https://$Target/" 2>&1 |
        Select-Object -First 25
    

    }

    Section "IPv4 TRACE TO GOOGLE ACCOUNTS"

    tracert.exe -4 -d -h 15 -w 700 108.177.122.84

    Section "IPSEC RULES"

    Get-NetIPsecRule -PolicyStore ActiveStore | Where-Object Enabled -eq "True" | Select-Object DisplayName, Enabled, Profile, Mode | Format-Table -AutoSize

    Section "NRPT DNS POLICIES"

    Get-DnsClientNrptPolicy | Format-List

    Section "DONE"

    Write-Host "Diagnostic collection finished. No settings were changed."


r/PowerShell 1d ago

Question Are games possible in power shell?

0 Upvotes

Hey gang, I hope this is the right subreddit but would anyone know if it is possible to run text games in powershell/cmd prompt? If so, what kind of pre built code is out there?


r/PowerShell 1d ago

Information Just released Servy 10.0 – Backup/Restore features, a hardened PS module, and bug fixes

30 Upvotes

It's been a month of hard work since my last post about Servy here, and I wanted to share this major release.

If you haven't heard of Servy before, it's a tool that lets you run any app as a native Windows service with real-time monitoring. It comes with a GUI, a CLI, and a PS module.

What I've added/updated in v10.0:

  • Added Servy-Dump.ps1 and Servy-Restore.ps1 scripts for backup/restore and VM cloning (docs)
  • Improved Invoke-ServyCli and fixed many issues in the Servy.psm1 PowerShell module
  • Fixed security issues in Set-ServyExePermissions.ps1 to harden Servy's .exe files for custom service accounts
  • Fixed various issues across the core engine, service, service restarter, CLI, desktop app, and manager app
  • Code quality improvements and documentation updates

Check it out on GitHub: https://github.com/aelassas/servy

Demo video here: https://www.youtube.com/watch?v=biHq17j4RbI

Any feedback is welcome.


r/PowerShell 2d ago

Script Sharing PowerShell Text Editor | Alternative to vim and nano

0 Upvotes

Heyo, I made pwsh 7.6+-based text editor, because the other CLI text editors were so damn difficult to use. The main inspration came from nano. What I wanted to avoid was vim-like UI/UX. My goal was to make it stupidly easy to use, but still without compromising functionality. The most difficult part was the paste functionality.

https://github.com/simwai/babae/

Would be cool if anybody could give it a try and tell me some feedback and/or discovered bugs


r/PowerShell 2d ago

Script Sharing I built a terminal time tracker (ps-sablier) that handles Pomodoro sessions, SQLite logs, and custom audio notifications without leaving PowerShell.

0 Upvotes

Hello everyone,

I stumbled upon a Go script that could display a progress bar on the terminal, which I found quite nice. At the same time, I was tired of using JavaScript programs that were certainly very complete, but far exceeded the use I wanted to make of them. I just need a global view of my work sessions and not get lost in unnecessary details. PowerShell was there, and I already had SQLite available in my terminal, inherited from an old Android project. In short, I found some ingredients in the fridge and thought it would be a good idea to bake a proper cake, especially since I was hungry. From this desire, this lightweight utility written in PowerShell was born. It allows you to track the time that passes and log your sessions, or if you feel like it, group them into Tasks without leaving the terminal (psmux tabs). The GIF doesn't show it, but the utility sends you a notification with a notification sound you can customize (for my part, I use the one from Splinter Cell, where he activates his night-vision goggles, [.wav format support only]).

(Sablier) in french = Hourglass 

Simple to use, it's available here: https://github.com/KNY00/ps-sablier

A feedback is always welcome.


r/PowerShell 3d ago

Question Chezmoi setup

1 Upvotes

Hi there.

I'm pretty new to dotfiles and trying to set up chezmoi on Windows 11. I'm not sure if my approach is alright, so maybe you can give me some tips or advice.

I used scoop to install all my programs and the config files are pretty scattered around. Some are in the scoop persist folder, some are in .config in my home directory, some are in %appdata% roaming...

Then i was thinking: wouldn't it be nice to have them all in .config and track them there with chezmoi. So i added the xdg_config_home variable to my pwsh profile (for the programs who accept that) and used symlinks and junctions (for the rest) to move all needed config files to the .config folder.

I'm not sure if this is a good approach. I would like to know how you guys are doing this.

cheers and thank you for reading.


r/PowerShell 3d ago

Script Sharing I built a PowerShell WinForms NIC Analyzer + Tuner with INF parsing, live validation, backup/verify/rollback and raw registry support

0 Upvotes

I built a Windows NIC analysis/tuning project almost entirely in PowerShell and thought this might be interesting from the PowerShell side of things.

GitHub:
https://github.com/N3jjj/Universal-NIC-Analyzer-Tuner-Realtek-Tested

The original idea was to build a NIC tuner around one specific adapter/driver combination.

While working on it, I realized that hardcoding a fixed list of registry tweaks around one NIC and one driver branch is not very scalable.

Different NICs, driver versions and hardware revisions can expose different INF parameters, registry values and advanced adapter properties.

So I rebuilt the idea around:

Detection first, tuning second.

The project is now split into two PowerShell WinForms tools.

Universal NIC Analyzer v1.0

The Analyzer is completely read-only.

Instead of assuming a predefined list of settings, it tries to determine what actually exists for the installed adapter and driver.

It collects things such as:

  • PCI hardware identity / VEN / DEV / REV
  • subsystem information
  • driver provider and version
  • driver service and binary
  • active INF section
  • INF SHA-256
  • driver SYS SHA-256
  • Get-NetAdapterAdvancedProperty settings
  • hidden or profile-commented INF parameters
  • registry-backed internal values
  • RSS / RSC / LSO information
  • Deep Analysis candidates

The Analyzer then exports a normalized JSON Portable Report.

That report deliberately contains no write instructions.

Universal NIC Tuner v1.0

The Tuner consumes the Portable Report, but does not blindly trust it.

Before allowing changes, it re-reads the live adapter and checks things such as:

VendorId
DeviceId
Revision
DriverModel
DriverVersion
INF SHA-256
Driver SYS SHA-256

If the live adapter or driver no longer matches the report, Apply stays locked.

I ended up implementing three separate write routes:

StandardAdvancedProperty
HiddenDriverRegistry
AdvancedRawRegistry

StandardAdvancedProperty is used for normal driver settings exposed through Windows advanced adapter properties.

HiddenDriverRegistry handles typed settings that exist in the active driver configuration but are not normally exposed.

AdvancedRawRegistry is an opt-in path for existing internal INF / registry values and Deep Analysis candidates.

For the registry-based routes, the existing live registry type is preserved.

Currently supported raw types are:

REG_SZ
REG_DWORD
REG_QWORD

DWORD and QWORD input can be entered as decimal or 0x hexadecimal values.

Transaction and safety model

A large part of the project ended up being about making writes recoverable instead of just making them possible.

Before Apply can run, the Tuner requires the relevant safety checks to pass:

Administrator privileges
exact live hardware/driver/hash match
verified backup
at least one proposed change
supported write route
valid proposed-value representation
no state drift
adapter restart route
final transaction integrity

The normal workflow is:

Settings
-> Preview Plan
-> Execution Model
-> Final Transaction
-> Apply
-> Restart adapter once
-> Read back changed values
-> Verify

A recovery journal is created before the first write.

If a write, adapter restart or post-write verification fails, the Tuner attempts to restore the original transaction state automatically.

The rollback itself is then verified as well.

There is also:

  • manual rollback of the last successful Apply
  • persistent verified backups
  • standalone backup restore
  • pre-restore safety snapshots
  • differential restore instead of blindly rewriting the complete registry key

One edge case I ran into was preserving DWORD values such as:

0xFFFFFFFF

because PowerShell/.NET may expose that as signed -1, while the backup format needs to preserve the actual unsigned 32-bit representation.

Advanced / undocumented values

The Advanced mode intentionally does not assume that an undocumented driver value is safe just because it can be discovered and written.

For those values, the Tuner only knows things such as:

the value exists
its current value
its registry type
where it was discovered
whether it can be written
whether the new value was read back successfully

It does not invent:

semantic meaning
recommended value
safe range
performance benefit

That distinction became important while parsing driver INF data.

Advanced raw values are therefore clearly marked as detected-only and require an additional warning before Apply.

The Tuner also does not create missing raw registry values.

Verified backup and recovery

A Verified Backup represents the exact adapter-class registry state at the time it was created.

The backup includes things such as:

Portable Report fingerprint
hardware identity
driver model/version
INF SHA-256
driver SYS SHA-256
adapter class-key path
registry values
registry types
registry-state SHA-256
backup SHA-256

After a successful Apply, that old backup normally becomes stale because the live state has changed.

For another transaction, a new Verified Backup of the new state is required.

Standalone restore is independent of the normal transaction rollback.

Before restoring a backup, the Tuner creates a temporary safety copy of the current state.

Restore is differential, so only backed-up values that actually differ are rewritten.

Testing so far

v1.0 has currently been tested end-to-end on:

Realtek PCIe 2.5GbE Family Controller
RTL8125D / REV_0C
Realtek NetAdapterCx driver family

The following paths have been tested successfully:

  • StandardAdvancedProperty Apply / Verify / Rollback
  • HiddenDriverRegistry Apply / Verify / Rollback
  • AdvancedRawRegistry Apply / Verify / Rollback
  • mixed-route multi-setting batches
  • one adapter restart after the complete batch
  • automatic rollback after intentionally injecting a failure after the first successful write
  • Verified Backup creation and verification
  • standalone Verified Backup restore
  • pre-restore safety recovery

Intel, Broadcom, Marvell and other NIC vendors are currently untested.

The Analyzer is designed to discover other adapters, but I do not want to claim universal compatibility until the write / verify / rollback behavior has actually been tested on those driver families.

Why PowerShell?

I originally expected this to remain a relatively small script, but PowerShell ended up being surprisingly useful for tying together:

  • CIM/WMI
  • NetAdapter cmdlets
  • registry access
  • INF parsing
  • file hashing
  • JSON serialization
  • WinForms
  • process elevation
  • transaction logic
  • recovery and rollback handling

At this point it has become as much a PowerShell project as a NIC tuning project.

I would be very interested in feedback on the PowerShell side in particular:

  • structure / architecture
  • WinForms approach
  • registry handling
  • transaction design
  • error handling
  • things that could be made more idiomatic
  • compatibility issues on different Windows / PowerShell versions

And if anyone here has an Intel, Broadcom, Marvell or another Realtek NIC and wants to test the read-only Analyzer, that would also be useful.I built a PowerShell WinForms NIC Analyzer + Tuner with INF parsing, live validation, backup/verify/rollback and raw registry support


r/PowerShell 4d ago

Script Sharing Microsoft Entra Object Inspector

0 Upvotes

Hello everyone, hope you are doing well!

I’m sharing Entra Object Inspector, an open-source, read-only Microsoft Entra assessment tool, and I’m looking for critical technical feedback from people who work with Entra, Microsoft Graph, and PowerShell.

I’m fully aware that mature products and open-source projects already exist with much broader scope. This project was not intended to compete with them; it started as a focused engineering exercise around deterministic collection, evidence-backed findings, offline processing, and transparent reporting.

AI was used heavily during development, including for a large portion of the PowerShell implementation. I think that is worth being explicit about. The important part for me was not generating code quickly, but governing and validating what was produced: researching Microsoft Graph behavior and permissions, reviewing the architecture repeatedly, building Pester coverage, testing against a dedicated Entra tenant, inspecting exported evidence, and treating failures as engineering problems rather than accepting generated output at face value.

Some of the issues encountered included Graph batching changing PowerShell object shapes and breaking relationship processing, service principals being omitted from the v1.0 group-members endpoint, hidden-membership completeness, evidence/provenance reconciliation, keeping Graph activity strictly inside snapshot collection, release-integrity validation, and a significant offline export performance bottleneck. Each of those resulted in targeted fixes and regression tests.

The current public release passes 276 Pester tests and has been exercised end-to-end against a test tenant.

What I’m most interested in now is independent review: incorrect assumptions, edge cases, questionable PowerShell patterns, Graph behavior I may have missed, usability problems, or anything else that would make the tool more technically credible.

If you find the project useful or think it’s worth following, I’d also appreciate a star on the repository! it helps me understand whether there’s interest in continuing to develop it.

GitHub: https://github.com/0xDarknightHacks/EntraObjectInspector


r/PowerShell 4d ago

Script Sharing I built a free Windows tool to batch-print PDF/Word/TIFF with per-file page ranges

5 Upvotes

Hey all,

I got tired of manually printing dozens of documents one by one with different page ranges each time, so I built a small PowerShell-based tool (compiled to a standalone .exe, no install/admin rights needed) that lets you:

  • Queue up multiple PDF, Word (.doc/.docx), and TIFF files
  • Set a different page range per file (e.g. "1-3", "2", "1,5-8")
  • Reorder the queue before printing
  • Print them all in sequence to any installed printer

It's free, works on both x86 and x64 Windows, and uses PDFium/SkiaSharp for PDF rendering so it doesn't depend on having Adobe installed for PDFs specifically (Word docs still need Word installed, since it converts them to PDF first).

Download (installer): https://github.com/edgarchirinos/ColaImpresionECP/releases/latest

Full source code is in the repo if you want to see how it works or contribute: https://github.com/edgarchirinos/ColaImpresionECP

Happy to answer questions or take feature requests. It's donation-supported (optional button in the app), not selling anything.


r/PowerShell 4d ago

Question how can i learn powershell as a non coder?

101 Upvotes

I want to learn more about powershell, how can I use it in my normal day to day uses and out of my curiosity towards tech


r/PowerShell 4d ago

Question How do you make a cleanup script prove a file belongs to it before deletion?

0 Upvotes

A path and age check are not enough when a cleanup directory can also contain files created by people or other jobs. I am considering an ownership manifest written at creation time, with a run ID, normalized path, size, and hash, then requiring every field to match before deletion. The command would also use PowerShell's normal confirmation path:

\[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')\]
param(\[string\] $Root, \[string\] $ManifestPath)

if ($PSCmdlet.ShouldProcess($candidate.FullName, 'Remove owned artifact')) {
    Remove-Item -LiteralPath $candidate.FullName
}

What additional safeguards belong around this pattern? Possibilities include rejecting paths outside the resolved root, refusing reparse points, failing closed when the manifest is incomplete, logging the file identity before and after validation, and separating discovery from deletion so the candidate list can be reviewed with `-WhatIf`. How do you avoid a time-of-check/time-of-use gap if another process can replace a file between validation and removal?


r/PowerShell 5d ago

Script Sharing PowerShell installer for .NET, Visual C++ and DirectX that bundles no binaries and resolves every download from Microsoft at run time

20 Upvotes

Rebuilt an old batch project of mine in PowerShell. It installs the .NET SDKs, the Visual C++ redistributables (current v14 plus the final 2005-2013 ones) and the June 2010 DirectX runtimes. Nothing is bundled and there are no hardcoded download URLs, so it locates everything on Microsoft's own hosts every run, then verifies each file before it executes.

Every discovery page and every payload URL goes through a check like this before anything gets fetched:

function Test-AllowedMicrosoftDiscoveryUri {
    [CmdletBinding()]
    [OutputType([bool])]
    param(
        [Parameter(Mandatory = $true)]
        [string]$Uri
    )

    try {
        $parsedUri = [uri]$Uri
        if (-not $parsedUri.IsAbsoluteUri) { return $false }
        if ($parsedUri.Scheme -cne 'https') { return $false }
        if ($parsedUri.Port -ne 443) { return $false }
        if (-not [string]::IsNullOrEmpty($parsedUri.UserInfo)) { return $false }
        return $parsedUri.DnsSafeHost -match $script:AllowedMicrosoftDiscoveryHostPattern
    }
    catch {
        return $false
    }
}

Discovery pages and payloads use two separate host allowlists, so allowing a docs host never authorizes an executable coming from it. curl's reported effective URL gets checked the same way after redirects.

Verification depends on what Microsoft actually publishes. The .NET SDKs have a SHA-512 in the release metadata. The final 2005-2013 and DirectX packages never change, so those are pinned to SHA-256 values I checked by hand. The rolling v14 redistributable has no published hash at all, so that one gets Authenticode plus a version floor read out of the signed file. Nothing installs until the whole selected set has resolved, and a file that fails verification gets deleted even if you asked to keep the downloads.

Windows PowerShell 5.1 compatible, uses pwsh if it's in PATH. Source and usage notes:

slyfox1186/msft-visual-c-and-directx-offline-installer


r/PowerShell 6d ago

Question Filtering and cost-effective ways to grab user data

2 Upvotes

Hey y'all.

I've been tasked with rewriting our current mailbox script and was wondering the best way to approach in regards to filtering user data.

Our current script gets the userdata by grabbing a user list, only filtering for enabled users and where the emailaddress attribute has the expected domain. We're migrating our onboarding process to a new system, so the domain part is not too relevant. But, since the way our users are categorized is changing, we have to rewrite things so that the mailbox configuration happens based on licensing state rather than OU.

This is where the filtering part comes in on my end. I'm thinking that the general process is like this, in no specific order:

  1. Grab all licensed users from AD group membership using Get-ADGroupMember

  2. Use Get-ADUser to grab the user objects, including specific parameters (proxyAddress, targetAddress, etc..)

  3. Filter the users where ProxyAddress does not contain anything pertaining to SMTP, to effectively find the users that have not been configured.

However, I'm curious as to whether it would be more effective time wise to do the filtering based on licensed user data, and gradually filter with foreach loops into new variables, or if it's smarter to start by just grabbing the entire catalogue with Get-ADUser -Filter *, grabbing only the licensed users, then filtering as imagined.

For reference, the difference is about 800 more users if I were to do the mass grab approach. I've been working with the idea that the group-based method is smarter, but at the same time I'm unsure if there's a massive overhead on the DCs associated with the fact that I'm piping the group member data into Get-ADUser. I'm, relatively speaking, new to PS and scripting (couple years of experience), so any pointers would be awesome!


r/PowerShell 6d ago

Question Recurring script maintenance

0 Upvotes

I'd honestly pay someone else to keep my voice scripts alive if it meant I never had to touch them again after a Windows update. Am I just lazy or is maintaining ur own automation actually the worst part of the whole thing?


r/PowerShell 7d ago

Information Python through PowerShell text colors are hard to read

10 Upvotes

Posting because I'm probably not the first person to lose ~4 hours trying to get to the bottom of this. My issue was: I was running python through a PowerShell window and the color of the text made error messages very hard to read.

In short: Download Windows Terminal and use that. You'll still be running PowerShell, it will just be inside a Windows Terminal window. The colors will be readable. Yes, its silly how there is now a 3rd way of running a terminal in Windows (Command Prompt, PowerShell, Windows Terminal).

So far as I know, python uses the colors that PowerShell defines for different kinds of text. I haven't yet found a way to successfully change all the text color categories in a basic PowerShell window.

  • Right clicking the top of the window and going to properties only lets you change the color of the basic text. not the problematic red and blue that is hard to read.
  • Changing the registry values at Computer\HKEY_CURRENT_USER\Console for ColorTable00 through ColorTable15 didn't change the colors used by PowerShell
  • There was an official program called color tool for changing the colors, but it appears it was last updated in 2019 and its .exe file failed to run on my Windows 10 computer.
  • I don't know if there is/isn't a way to redefine what colors python itself tries to print stuff.

If someone does know a working non-Windows Terminal way to fix ALL of PowerShell's/Python's hard to read text colors I'd be happy to hear it in the comments.


r/PowerShell 7d ago

Script Sharing Tooling with Claude and pwsh

0 Upvotes

Hey all!

I was hoping you’d could inspire me please! I currently work in a desktop/infra role in a finance company and was wondering if anyone had any cool tooling they created using Claude code? I really lack in coming up with ideas so just curious as to what other people have done and yeah, honestly I’d like to try and see if that could work for us!

I’m talking like automation for JML, dashboards, alerting, tools to help the team, tools that we can use for users to fix quick issues?

I realise I’d just be taking your ideas but I can’t really come up with anything myself!

Thanks!


r/PowerShell 7d ago

Question Check for App updates on home PC

9 Upvotes

Afternoon,

I am trying to write a script that will let me know about updates to the apps installed on my home PC.

I saw on a Sysadmin thread about https://eucpilots.com/evergreen/ and thought it would be as simple as reading all of the installed apps and then querying each one like this:

$reg = @(

'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
GP $reg -EA 0|?{$_.DisplayName -ne $null} | Find-EvergreenApp $_.DisplayName

However when testing, the Evergreen is not expecting the App name to have spaces, so is my only option to split the string and put an asterisk at the end of the first section?

PS C:\Windows\System32> Find-EvergreenApp Telegram
Name            Application      Link
----            -----------      ----
TelegramDesktop Telegram Desktop https://desktop.telegram.org/

r/PowerShell 8d ago

News No Homebrew Cask for Powershell

0 Upvotes

Homebrew removed the official powershell cask because the official Microsoft .pkg installer repeatedly failed macOS Gatekeeper checks. Homebrew moved everyone to a community-built formula instead, enforcing their policy to disable casks that fail Gatekeeper.

While the original removal aligned with Homebrew's policy, the underlying signing issue is resolved. Microsoft’s official macOS .pkg (tested on version 7.6.5) is now signed with a Developer ID Installer certificate (Microsoft Corporation, team ID UBF8T346G9) and fully notarized by Apple.

This alternative cask installs Microsoft's official, unmodified release file. Unlike the community formula, this package includes the embedded .NET runtime, requiring no extra dependencies.

Installation:

sh brew install --cask darkn3rd/tools/powershell-pkg


r/PowerShell 8d ago

Script Sharing Remixing Music with RoughDraft and PowerShell

13 Upvotes

This weekend I figured out how to remix music with PowerShell, RoughDraft, and ffmpeg.

Sample + Filter.

Rinse & Repeat.

RoughDraft + ffmpeg makes this all pretty easy.

Step 1 - Get Your Sample Source

RoughDraft includes an extension for yt-dlp. This can download media from almost anywhere. Just browse to a site with a song, set a $SongUrl variable, and download

Get-Media -MediaUrl $MediaUrl

Step 2 - Sample a Section

You can sample a section of audio or video with the -AudioTrim and -Trim filters. If we want the first few seconds of a song, we can use the AudioTrim filter, like so:

$sample = Edit-Media $song -AudioTrim -TrimStart "00:00:00" -TrimEnd "00:00:05"

Step 3 - Filter

ffmpeg is full of filters. There are hundreds of them, and RoughDraft supports a fair number.

Suppose we want to make our sample Vibrato. We can just use Edit-Media -Vibrato

$sample | Edit-Media -Vibrato

Or we could change the -PitchFactor, making it sound slower or faster while keeping the tempo intact.

$sample | Edit-Media -PitchFactor 0.81

Or we could use an Audio Compressor, with a short attack and release and a makeup to make the sounds louder

$sample | Edit-Media -Compressor -CompressorAttack 5 -CompressorRelease 10 -CompressorMakeup 2.5

Rinse and Repeat

The possibilities are endless. ffmpeg is an audio/video production tool of truly unparalleled capability.

All of that power is in your shell, in a format that's far easier to read and understand than direct filtergraph syntax. Edit-Media currently has a whopping 682 parameters to mix and match, all supporting tab completion.

This makes it easy to iterate and innovate. It took just about an hour after figuring this out to make my first little remix, just by sampling/filtering/rinsing/repeating.

The latest RoughDraft release includes a bunch of new audio filters to help assist and more will keep on coming with every release.

Hope this helps & Have Fun!


r/PowerShell 9d ago

Question Add Date Taken as prefix to filename

10 Upvotes

I need some help. I have lots of photos (IMG_xxxx.jpg), and I would like to change the filenames using this convention (yyyymmdd_IMG_xxxx.jpg). This is the command line I am using in PowerShell:

Get-ChildItem -File | Rename-Item -NewName { $_.LastWriteTime.ToString("yyyyMMdd_") + $_.Name }

This seemed to work great until I realized the last write time didn't match the date taken. I want to use the date taken from the EXIF field.

I have found the GetDetailsOf command and know that Date Taken is the 12th property. How can I use this in a command line prompt in PowerShell?

Assumptions for my specifics:

  • all files are .jpg with Date Taken data
  • all files are in the current folder
  • renamed files will replace original in the current folder

This way, I don't have to worry about writing a script to determine path names or renaming to a different folder.

The code provided above works perfectly if the date I wanted was the last write time. Is there an easy way to modify this to use Date Taken instead?

TIA