r/PowerShell • • 1d ago

Script Sharing What have you done with PowerShell this month?

10 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 • • Oct 01 '26

Script Sharing What have you done with PowerShell this month?

23 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 • • 4h ago

Misc Converted my PS Script to PS7

2 Upvotes

I know there are plenty of AI haters out there but I wanted to get ahead of the switch from PS 5.1 to PS 7 but it's been too long since I did any PS coding and I didn't feel the urge to get back up to speed. So, as an alternative, I fed my script that's contains code for a GUI input form into Gemini AI and within seconds it converted my script to PS7. Needless to say I was impressed that Gemini AI could convert PS scripts.


r/PowerShell • • 1h ago

Script Sharing PowerBGInfo - BGInfo alternative with support for Windows, Linux and macOS

0 Upvotes

PowerBGInfo now has a website https://powerbginfo.com with demos, examples, use cases etc. I've also added preview support for macOS, Linux, but that needs larger testing so please report any issues in that area.

The website contains proper examples and how you can make them your own including white labeling and whatever else you want to keep on your desktops/servers. All with support out of the box.

Sources: https://github.com/EvotecIT/PowerBGInfo

I am using AI on daily basis.

Here's an example (one of many) - all of them are available on the website.

<#
    Hyper-V host. The question for the administrator at this console: does
    this host have room for another VM, and which VMs are using it?

    The data block returns plain values; the presentation block only reads
    them. Comments name the command or source that supplies each value.
#>
param(
    [ValidateSet('Light', 'Dark')]
    [string] $Theme = 'Dark',
    [int] $Width = 1920,
    [int] $Height = 1080,
    [string] $OutputDirectory = (Join-Path $PSScriptRoot 'Output')
)

if (-not (Get-Module -Name PowerBGInfo)) {
    Import-Module PowerBGInfo -ErrorAction Stop
}

#region Data: your logic goes here
function Get-HyperVHostData {
    # Get-VM returns these properties (MemoryAssigned, ProcessorCount and
    # CPUUsage); the workload tag comes from the VM notes or your CMDB.
    # The sample keeps them as CSV to stay short.
    $vms = @'
Name,Workload,vCPU,MemoryGB,Cpu
SQL-PROD-01,Databases,16,128,71
SQL-PROD-02,Databases,16,96,34
SQL-RPT-01,Databases,8,48,12
ERP-APP-01,ERP,12,64,38
ERP-APP-02,ERP,12,64,29
ERP-BATCH-01,ERP,8,32,55
VDI-POOL-A,Desktops,48,96,41
VDI-POOL-B,Desktops,24,48,18
WEB-01,Web,4,16,22
WEB-02,Web,4,16,19
WEB-03,Web,4,16,9
FS-01,Infrastructure,4,32,6
MON-01,Infrastructure,4,24,14
DC02,Infrastructure,2,8,3
'@ | ConvertFrom-Csv | ForEach-Object {
        [pscustomobject] @{
            Name = $_.Name; Workload = $_.Workload; vCPU = [int] $_.vCPU
            MemoryGB = [int] $_.MemoryGB; Cpu = [int] $_.Cpu; State = 'Running'
        }
    }

    [pscustomobject] @{
        Available = $true
        Name     = 'HV-AMS-07'
        # Get-Cluster and Get-ClusterNode
        Cluster  = 'HVC-AMS-01 · node 3 of 6'
        Hardware = '2 × Xeon Gold 6448Y · 64 cores'
        Version  = 'Windows Server 2025 Datacenter'
        # Get-Counter '\Hyper-V Hypervisor Logical Processor(_Total)\
        #     % Total Run Time' sampled every 5 minutes
        Cpu      = @(38, 41, 52, 47, 44, 49, 46)
        # (Get-VMHost).MemoryCapacity and the sum of MemoryAssigned
        MemoryGB = [int] ($vms | Measure-Object -Property MemoryGB -Sum).Sum
        # The cluster keeps one node's worth of memory free for failover.
        ReserveGB = 64
        TotalGB  = 768
        # Get-ClusterSharedVolume | Select-Object -ExpandProperty
        #     SharedVolumeInfo | Select-Object -ExpandProperty Partition
        Storage  = @{ Name = 'CSV-02'; UsedPercent = 68; FreeTB = 6.1 }
        Vms      = $vms
        # Get-ClusterGroup | Where-Object OwnerNode -NE $env:COMPUTERNAME,
        # or the Failover Clustering event log, event 5143 and 1641
        Moves    = @(
            [pscustomobject] @{ Time = '09:12'; VM = 'ERP-BATCH-01'
                Move = 'from HV-AMS-04'; Result = 'OK' }
            [pscustomobject] @{ Time = '08:47'; VM = 'WEB-03'
                Move = 'from HV-AMS-02'; Result = 'OK' }
            [pscustomobject] @{ Time = '02:05'; VM = 'VDI-POOL-B'
                Move = 'to HV-AMS-05'; Result = 'Failed' }
        )
        # Memory assigned on every node: Get-ClusterNode | ForEach-Object {
        #     Get-VM -ComputerName $_.Name | Measure-Object MemoryAssigned }
        Nodes       = [ordered] @{
            'HV-AMS-04' = 71; 'HV-AMS-05' = 64; 'HV-AMS-07' = 82
            'HV-AMS-08' = 91; 'HV-AMS-09' = 58; 'HV-AMS-10' = 47
        }
        # Get-VM | Get-VMSnapshot | Where-Object CreationTime -LT
        #     (Get-Date).AddDays(-7)
        Checkpoints = @(
            @{ Text = 'ERP-APP-02 · before CU 14'; Status = 'Warning'
                Value = '12 days' }
            @{ Text = 'WEB-02 · config test'; Status = 'Warning'
                Value = '9 days' }
        )
    }
}

$fallback = [pscustomobject] @{
    Available = $false
    Name = $env:COMPUTERNAME; Cluster = 'unknown'; Hardware = 'unknown'
    Version = 'unknown'; Cpu = @(0); MemoryGB = 0; TotalGB = 1; ReserveGB = 0
    Storage = @{ Name = 'CSV'; UsedPercent = 0; FreeTB = 0 }
    Vms = @([pscustomobject] @{ Name = 'unknown'; Workload = ''
            vCPU = 0; MemoryGB = 1; Cpu = 0; State = 'Unknown' })
    Moves = @(); Checkpoints = @(); Nodes = [ordered] @{ 'unknown' = 0 }
}
$source = @{
    Name           = 'Hyper-V host'
    TimeoutSeconds = 20
    ScriptBlock    = ${function:Get-HyperVHostData}
    Default        = $fallback
}
$hv = Invoke-BGInfoDataSource 
#endregion

#region Presentation: reads only $hv
$scale = [Math]::Round($Height / 1080, 2)
$look = New-BGInfoTheme Corporate -Mode $Theme -Scale $scale
$memory = [Math]::Round(100 * $hv.MemoryGB / $hv.TotalGB)
$running = @($hv.Vms | Where-Object State -EQ 'Running').Count
$vcpu = ($hv.Vms | Measure-Object vCPU -Sum).Sum
$free = $hv.TotalGB - $hv.MemoryGB - $hv.ReserveGB

New-BGInfo -Theme $look -Target File {
    New-BGInfoBackground -Width $Width -Height $Height -Pattern Grid `
        -PatternSpacing ([int](56 * $scale))
    # A wider right column for the tables; the treemap may fill the center.
    New-BGInfoLayout -ColumnWidth ([int](520 * $scale)) `
        -MaximumPanelHeight ([int](640 * $scale))

    New-BGInfoLabel -Name 'HYPER-V HOST  ·  PRODUCTION CLUSTER' -Accent `
        -FontSize ([int](15 * $scale)) -FontWeight 700
    New-BGInfoLabel -Name $hv.Name -FontSize ([int](72 * $scale)) `
        -FontWeight 600
    $capacity = if ($hv.Available) {
        "Room for $free GB of VMs before failover reserve"
    } else { 'Host capacity unavailable' }
    New-BGInfoLabel -Name $capacity `
        -FontSize ([int](19 * $scale)) -FontWeight 600
    New-BGInfoValue -Name 'Cluster' -Value $hv.Cluster
    New-BGInfoValue -Name 'Hardware' -Value $hv.Hardware
    New-BGInfoValue -Name 'System' -Value $hv.Version

    # Top band: four host metrics beside the text. Above 80 % memory or
    # 75 % storage the card turns amber; above 90 % it turns red.
    if ($hv.Available) {
        $card = @{ Region = 'Top'; Height = [int](170 * $scale) }
        New-BGInfoMetric  -Label 'CPU' -Value $hv.Cpu[-1] -Unit '%' `
            -Caption '64 logical cores' -History $hv.Cpu -HistoryMaximum 100 `
            -WarningThreshold 70 -CriticalThreshold 85
        New-BGInfoMetric  -Label 'Memory' -Value $memory -Unit '%' `
            -Caption "$($hv.MemoryGB) of $($hv.TotalGB) GB assigned" `
            -WarningThreshold 80 -CriticalThreshold 90
        New-BGInfoMetric  -Label $hv.Storage.Name -Unit '%' `
            -Value $hv.Storage.UsedPercent `
            -Caption "$($hv.Storage.FreeTB) TB free" `
            -WarningThreshold 75 -CriticalThreshold 90
        New-BGInfoMetric u/card -Label 'VMs running' -Value $running `
            -Caption "$vcpu vCPU on 64 cores"

        # Center: where the memory goes, grouped by workload. The color is the
        # VM's CPU: amber from 60 %, red from 85 %.
        $hv.Vms | New-BGInfoTreemap -Region Center -Title 'Memory by VM' `
            -Note 'size: memory · color: CPU' -ValueProperty MemoryGB `
            -GroupProperty Workload -ValueSuffix ' GB' -ColorProperty Cpu `
            -WarningThreshold 60 -CriticalThreshold 85

        # Right column: cluster memory by node, today's live migrations and the
        # checkpoints left behind. Each node keeps its label and palette color.
        New-BGInfoChart -Region Right -Id 'nodes' -Title 'Cluster memory' `
            -Kind HorizontalBar -Values @($hv.Nodes.Values) `
            -Labels @($hv.Nodes.Keys) `
            -Palette @($look.Accent, $look.SecondaryAccent, $look.Ok, `
                $look.Warning, $look.Critical, $look.Info) `
            -Maximum 100 -ValueSuffix ' %' -NoHistory `
            -Height ([int](250 * $scale))
        $hv.Moves | New-BGInfoTable -Region Right -Title 'Live migrations' `
            -Note 'today' -Property Time, VM, Result -StatusColumn Result
        New-BGInfoList -Region Right -Title 'Old checkpoints' `
            -Note 'older than 7 days' -Item $hv.Checkpoints
    }
} -ConfigurationDirectory $OutputDirectory `
    -OutputFileName "hyperv-host-$($Theme.ToLower()).png"
#endregion
Lines 120 to 180 on GitHub

Help desk
How to get help, plus the details support asks for.

Orchid theme preset
Generated gradient background with glows and dots
Visual canvas info tiles with built-in icons
Shared text styles for headings, values and status
helpdesk-dark.png
PNG 1920 x 1080, 292 KB
Script on GitHub
Help desk wallpaper: how to reach the service desk, its portal, hours and current service status, with tiles for asset tag, computer name, IP address, signed-in user and Windows version. Dark theme.

Presentation

Data
PowerShell
Run.BGInfo.HelpDesk.ps1

Copy
New-BGInfo -Theme $look -TextPosition MiddleLeft -Target File {
    New-BGInfoBackground -Width $Width -Height $Height
    # The tile column sits vertically centered beside the centered text.
    New-BGInfoLayout -ColumnAlignment Center

    New-BGInfoLabel -Name 'IT SERVICE DESK' -Accent `
        -FontSize ([int](16 * $scale)) -FontWeight 700
    New-BGInfoLabel -Name 'Need help?' -FontSize ([int](88 * $scale)) `
        -FontWeight 600
    New-BGInfoLabel -Name 'Call 555-0100, extension 4357' -Accent `
        -FontSize ([int](40 * $scale)) -FontWeight 600
    New-BGInfoLabel -Name 'Have the asset tag on the right ready.' -Muted `
        -FontSize ([int](22 * $scale))
    New-BGInfoValue -Name 'Portal' -Value 'help.contoso.com'
    New-BGInfoValue -Name 'Teams' -Value '#it-help'
    New-BGInfoValue -Name 'Walk-in' -Value 'Building B, room 012'
    New-BGInfoValue -Name 'Hours' -Value 'Monday–Friday, 07:00–19:00'

    New-BGInfoLabel -Name ' ' -FontSize ([int](12 * $scale))
    New-BGInfoLabel -Name 'SERVICE STATUS' -Accent `
        -FontSize ([int](16 * $scale)) -FontWeight 700
    foreach ($service in $facts.Services) {
        New-BGInfoLabel -Name "●  $($service.Text)" -Status $service.Status `
            -FontSize ([int](19 * $scale)) -FontWeight 600
    }

    New-BGInfoVisualCanvas -Region Right -Tile $tiles
} -ConfigurationDirectory $OutputDirectory `
    -OutputFileName "helpdesk-$($Theme.ToLower()).png"
#endregion
Full script
109 lines
Lines 80 to 109 on GitHub

Meeting room
Which room, is it free, and how to share a screen.

Orchid theme preset
Single-day Gantt lanes for this room and the rooms next door
Wi-Fi QR code
Numbered list
meeting-room-dark.png
PNG 1920 x 1080, 243 KB
Script on GitHub
Meeting room wallpaper for Oslo: free until 13:00, the next booking, a guest Wi-Fi QR code, numbered steps to share a screen and today's bookings beside the neighbouring rooms. Dark theme.

Presentation

Data
PowerShell
Run.BGInfo.MeetingRoom.ps1

Copy
New-BGInfo -Theme $look -Target File {
    New-BGInfoBackground -Width $Width -Height $Height -Pattern None

    New-BGInfoLabel -Name $room.Where -Accent -FontSize ([int](15 * $scale)) `
        -FontWeight 700
    New-BGInfoLabel -Name $room.Room -FontSize ([int](150 * $scale)) `
        -FontWeight 700
    New-BGInfoLabel -Name "●  $($status.Text)" -Status $status.Status `
        -FontSize ([int](34 * $scale)) -FontWeight 600
    New-BGInfoLabel -Name ' ' -FontSize ([int](8 * $scale))
    New-BGInfoValue -Name 'Next booking' -Value $after
    New-BGInfoValue -Name 'Room' -Value $room.Seats
    New-BGInfoValue -Name 'Book it' -Value $room.Book
    New-BGInfoValue -Name 'Help' -Value 'ext. 4357, or help.contoso.com'

    # Right column: guest Wi-Fi on the phone, then how to share a screen.
    New-BGInfoQRCode -Region Right -Text $room.Wifi.Text -Title 'Guest Wi-Fi' `
        -Caption $room.Wifi.Ssid -Note 'scan to join' `
        -Height ([int](330 * $scale))
    New-BGInfoList -Region Right -Title 'Share your screen' -Marker Number `
        -Item $room.Steps

    # Bottom band: today in this room and the two next to it.
    if (@($day).Count -gt 0) {
        New-BGInfoTimeline -Region Bottom -Title 'Today' -NoLegend `
        -Note 'Bergen and Tromsø are next door' `
            -Item $day -Now $room.Now -Height ([int](280 * $scale))
    }
} -ConfigurationDirectory $OutputDirectory `
    -OutputFileName "meeting-room-$($Theme.ToLower()).png"
#endregion

r/PowerShell • • 23h ago

News Advent of PowerShell

42 Upvotes

Looking for a fun way to sharpen your PowerShell skills this December?

Advent of PowerShell is live!

🎄 24 daily PowerShell coding challenges

Whether you're just getting started with PowerShell or have been automating everything in sight for years, it's a great excuse to write some PowerShell, challenge yourself and explore different approaches to solving problems.

Get started here: https://2026.powershell.au/

Would love to see how everyone approaches the challenges. Feel free to share your experiences, feedback and creative solutions (with spoiler tags, of course!).

Disclosure: AI did help me create the website and text above. I can only include 1 tag, and I felt News was more appropriate


r/PowerShell • • 3h ago

AI Disclosure Bylaw, a Pester-style PowerShell DSL that compiles to Azure Policy JSON (pre-release, looking for feedback)

0 Upvotes

If you've ever written Azure Policy by hand, you'll know the JSON gets painful fast: nested allOf/anyOf, long aliases, and conditions written the wrong way round (you describe what's non-compliant, not what's compliant).

There are good tools for deploying policy (Bicep, Terraform, EPAC), but I couldn't find much to help with authoring it. So I built Bylaw: a PowerShell DSL, loosely modelled on Pester, where you state what must be true and it compiles that into Azure Policy JSON.

An excerpt from one of the examples:

Require 'TLS 1.2 or later' {
    Field minimumTlsVersion | Must -Be 'TLS1_2'
}

What it does:

  • You describe the compliant state. Bylaw works out the condition that finds non-compliant resources, including negations and missing properties.
  • Short field names like minimumTlsVersion expand to full Azure aliases, and misspellings fail the build.
  • Build-Bylaw validates the whole definition (arrays, remediation, related resources, initiatives) and flags issues. It needs no Azure access and doesn't deploy anything.
  • Deterministic output, so diffs only show real changes.
  • ConvertTo-Bylaw turns existing policy JSON into Bylaw and only counts it a success if it compiles back to an identical policy.
  • It's just PowerShell, so you can use loops, data files and helper functions to generate policies.

I've run the conversion against all the Azure built-in, Azure Community and ALZ policies. The gallery shows them side by side, and the coverage page lists what it can't handle yet (including a few source policies with genuine bugs).

Install (PowerShell 7.2+):

Install-PSResource -Name Bylaw -Prerelease

In the interest of transparency: I built it with Claude Code, using an ADR-driven design process, and I reviewed and approved every design decision and PR.

It's pre-release, and what I'd find most useful is seeing how it copes with real-world custom policies. If you try ConvertTo-Bylaw on yours and it fails or produces something odd, I'd love an issue. Feedback on the syntax is welcome too.


r/PowerShell • • 18h ago

News PS7 ScriptDesk (Custom PS7 ISE) — Development Update

5 Upvotes

I had ChatGPT help write the update. -Ron

Thank you to everyone who has been testing PS7 ScriptDesk, reporting issues, suggesting improvements, and providing valuable feedback. Your participation continues to help shape the application into a more capable, reliable, and user-friendly PowerShell 7 development environment.

What's New

Expanded PowerShell Code Snippets

The code snippet system has been significantly enhanced to incorporate Microsoft's official PowerShell snippet library.

  • 51 Microsoft PowerShell snippets and 21 ScriptDesk snippets, providing 72 built-in code templates.
  • Microsoft-first snippet integration with IntelliSense.
  • A new Insert Snippet option in the editor's right-click context menu.
  • Ctrl+J opens a searchable snippet library.
  • Search by snippet name, keyword, description, or category.
  • Filter snippets by category and source.
  • Preview PowerShell code before inserting it into your script.
  • Interactive, linked placeholders with keyboard navigation for rapid code customization.
  • Full integration with the existing ScriptDesk editor and theme system.

These enhancements make writing PowerShell scripts faster and easier while reducing repetitive coding.

Native PowerShell Command Builder

PS7 ScriptDesk now provides direct access to PowerShell's built-in graphical Command Builder through the Tools → Command Builder menu.

Two operating modes are available:

  • Interactive: Launches the Command Builder within your existing PowerShell session.
  • Distinct: Launches the Command Builder independently, allowing you to continue working in ScriptDesk.

The Command Builder allows users to explore available PowerShell commands, view their parameters, configure arguments, and construct properly formatted PowerShell commands through a graphical interface.

Rather than developing a proprietary replacement, ScriptDesk leverages Microsoft's native PowerShell functionality.

Continued Quality and Performance Improvements

Development continues to focus on:

  • Application stability and reliability.
  • Improved editor responsiveness.
  • Consistent and intuitive user interfaces.
  • Compatibility with established PowerShell development workflows.
  • Reuse of proven native technologies.
  • Maintaining a streamlined application without unnecessary software bloat.

What's Coming Next

The next planned enhancement is a comprehensive Snippet Manager and Creator, which will allow users to:

  • Create and maintain their own reusable PowerShell snippets.
  • Create snippets directly from selected editor code.
  • Customize existing snippets.
  • Organize snippets into categories, subcategories, and favorites.
  • Assign custom IntelliSense expansion keywords.
  • Import and export snippets compatible with Visual Studio Code and Windows PowerShell ISE.

Your Feedback Matters

Whether you are a PowerShell beginner, an experienced developer, a system administrator, or a longtime Windows PowerShell ISE user, your feedback is welcome.

Please continue to report bugs, request features, and share suggestions through the PS7 ScriptDesk GitHub repository:

https://github.com/RonB56/PS7-ScriptDesk

The goal remains to provide a modern, powerful, intuitive, and free integrated scripting environment designed specifically for PowerShell 7.

Thank you for your continued support and for being part of the PS7 ScriptDesk community!


r/PowerShell • • 2d ago

Question How to exclude showing Get-Variable output for -Scope 0

13 Upvotes

I want to call myfunc function that runs the statement:

$value = ( Get-Variable -Name $var_name -Valueonly -Scope Script )

That will show the GM's output for the instance of the variable named in the myfunc's$var_name parameter, a string, that was in scope when the myfunc was called, no mater where or what scope the call was made in, but myfunc must ignore a local variable with the same name in favor of the same named variable outside of the myfunc . If there are multiple variables with the same name outside of myfunc, then only the one that is in scope, that is not eclipsed, is shown (as I think already happens).

myfunc is currently defined at the script file's script scope, so it be callable from anywhere in the script where it's defined or 'included', but if the calling statement is nested deeply in a chain of functions or 'included' scripts, will the$var_name parameter need to be 'typed' as [ref] to make this work?

Google suggests the following to eliminate myfunc variables, their version lists:

-Scope 0,1,2,Global,Script

But, I don't want to keep changing this list when I call myfunc from deeper scopes, so I changed the scope option to:

-Scope 0,1,2,3,4,5,6,7,8,9,Global,Script

I don't expect to need that, but without a All, Allscope, or notLocal option setting, or a way to dynamically determine the scope of the variable from its name or the name from its value. I pretty much need to include all reasonable scopes that I might one day need.

Here is the rest of that suggested line of code:

    $value = (
      Get-Variable `
        -Name $var_name `
        -Valueonly `
        -Scope '0,1,2,3,4,5,6,7,8,9,Global,Script' `
        -ErrorAction SilentlyContinue
      |
      Where-Object { $_.Scope -ne 0 }
    )

I'll check the last error auto-variable and output my own error message if there is an error.

When is a string not a string? I don't know, but PowerShell gives me this error when I try running the suggested line of code, above, after fixing the missing quotes that Copilot left off:

Line |
 200 |      Get-Variable `
     |      ~~~~~~~~~~~~~~
     | Cannot process argument because the value of parameter "Scope" is not valid. Valid values are "Global", "Local", or "Script", or a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent). Change the value of the "Scope" parameter and run the operation again.

In another thread, someone said AI code was 'slop', here is an example!

Thank you.


r/PowerShell • • 4d ago

Script Sharing I built a free WinForms GUI to see which mailboxes a user can access in Exchange Online (reverse lookup + grant/copy/remove)

58 Upvotes

Hi r/PowerShell,

one thing that always annoyed me as an M365 admin: the Exchange Admin Center only shows permissions per mailbox. There is no quick way to answer "Which mailboxes, calendars and room mailboxes does user X have access to?" – especially during onboarding/offboarding or when someone changes departments.

So I built MailboxAccess, a PowerShell/WinForms tool on top of the EXO v3 module.

What it does

  • Reverse lookup: enter a user → see all mailboxes they have FullAccess, SendAs, SendOnBehalf or folder/calendar permissions on
  • Room mailboxes: includes calendar permissions and booking delegates
  • Grant / copy / remove: add rights, copy all rights from one user to another (onboarding), or remove everything (offboarding)
  • Mailbox view: who has access to a specific mailbox
  • Tenant report: overview of all non-default permissions
  • Fast: results come from a local cache (seconds instead of minutes). The cache can be refreshed incrementally via the Unified Audit Log (delta update), so you don't have to rebuild it every time
  • Runs locally, no server, no cloud service, data stays in `%LOCALAPPDATA%`

Requirements

  • Windows PowerShell 5.1
  • `ExchangeOnlineManagement` module
  • Exchange admin rights (plus "View-Only Audit Logs" for the delta update)

Download

GitHub: https://github.com/RazeAttack/MailboxExchangeGUI

You can run the `.ps1` directly or use the EXE from the releases (built via GitHub Actions, SHA256 checksums included). The EXE is a ps2exe build and not code-signed yet (code signing via SignPath is in progress), so Defender/SmartScreen may complain – if you prefer, just run the script.

MIT licensed, free. Feedback, issues and PRs are very welcome – especially on performance in larger tenants (I've tested it with ~350 mailboxes).

Screenshots are in the README (tenant data redacted).


r/PowerShell • • 3d ago

Script Sharing I built a free read-only scanner to find VBScript dependencies before Windows disables it — feedback welcome

0 Upvotes
With VBScript getting disabled by default in 2026–2027, I wanted a quick way to see what would break on a machine: .vbs/.wsf/.hta files, scheduled tasks, Run keys, startup folders, GPO logon scripts and services calling wscript/cscript.

So I wrote VBS Readiness. It's read-only (changes nothing) and produces an HTML report of every dependency it finds, with a risk score. It also checks Outlook add-ins and VBA macros for the new Outlook.

Free download: https://github.com/lamtoueqali-eng/vbs-readiness

Disclosure: I'm the author, and I also offer paid conversions to PowerShell, but the scanner is free and works on its own.

What other VBScript hiding spots should I detect? Happy to add them.

r/PowerShell • • 3d ago

Question Practicar comandos Linux/Windows

0 Upvotes

¿Conocéis alguna forma de practicar/estudiar comandos de Linux y Windows?

Me refiero tanto a comandos de Linux, como a comandos orientados a la administración de Linux (chmod, tar, fsck, tcpdump...), y de Windows/PowerShell (net, ipconfig /flushdns, sfc /scannow...).

Alguna vez he visto alguna web con algún juego en el que, mediante comandos, avanzabas por el juego.

No sé si algo así es buena idea o si mejor lo descarto.

En ocasiones utilizo maquinas virtuales con Linux y/o Windows, pero se me hace un poco pesado practicarlo, de ahí que busque otras opciones.


r/PowerShell • • 4d ago

Question Do Constants give advantages?

22 Upvotes

So, we all know we can make a Constant by using New-Variable -Name 'ImTryingIguess" -Value 'whatever' -Option Constant
(or using Set-Variable the same way)

Question is: does using a constant instead of a regular variable give any advantage?
Like, smaller memory footprint or something?

So far, from what I managed to understand, its only effect is keeping people from altering the variable, which can be very useful with large scripts manned by multiple people, as one might decide to recycle a variable name that should otherwise stay untouched.

I personally prefix any "constant" name with CONST_(i.e.: $CONST_TitleTemplate) which, so far, has been working well, but I was wondering if I was missing some magic powershell shenanigan.


r/PowerShell • • 3d ago

Question powershell

0 Upvotes

não consigo acessar, diz que nao tenho permissão adequada pra acessar, alguem poderia me ajudar


r/PowerShell • • 5d ago

Question How to inject a tab before each output line of Get-Member?

4 Upvotes

I've written a PowerShell (v7.7) script function that outputs information from the Get-Member (GM) cmdlet about the variable (name and value) that is passed into my function.

Here is a sample of the function's output (I added the titles for clarity):

var-name var-value var-type
$v08 Collection [Hashtable]
System.Object Item(System.Object key) {get;set;}
int Count {get;}
bool IsFixedSize {get;}
bool IsReadOnly {get;}
bool IsSynchronized {get;}
System.Collections.ICollection Keys {get;}
System.Object SyncRoot {get;}
System.Collections.ICollection Values {get;}

Here is the relevant code:

function write-variable {
  param(

    [Parameter(Mandatory)]
    [string]
    $variable_name,

    [Parameter(Mandatory)]
    [AllowNull()][AllowEmptyString()]
    $variable_value,

    [switch] $showMembers,
    [switch] $noNewline,

    [switch] $showHeader,

    [Parameter(ValueFromRemainingArguments)]
    [AllowNull()][AllowEmptyString()]
    $FormatingArgs

  )
  ⋮
  $var_name = (
    $variable_name\[ 1 .. ( $variable_name.length ) ]  `  
      -join ''
  )
  ⋮
  $value = (
      Get-Variable `
        -Name $var_name `
        -ValueOnly `
        -Scope Script `
        -ErrorAction SilentlyContinue
    )

  if( $NULL -eq $value ) {

    $type         = $NULL
    $string_value = 'Null'
    ⋮
  }
  else {

    $type         = $value.getType().Name
    $string_value = 'Collection' # For simplicity
    ⋮
  }
  ⋮
  # The actual code builds a format string and uses
  # it to format and output the three variables that
  # are seen in this next write statements, but this
  # code is enough to show the first line of the
  # output shown above.

  write-host (
      $variable_name + "`t" +
      $string_value + "`t" +
      '[' + $type + ']'
    )

  # I want to inject whitespace
  # before each line of the 'GM'
  # output.
  # Here is where I need help:

  (

    Get-Member `
      -InputObject $variable_value `
      -MemberType  Properties, `
                   ParameterizedProperty

  )
  |
  ( <# Need code here #> )
  |
  write-host
  ⋮
}

$v08 = @{ d1 = get-date; d2 = get-date }
write-variable '$v08' $v08 -noNewline

My Goal: Make the grouping of the output lines clearer when this function is called multiple times by indenting the lines (8 lines in this case) that follow the first line of the set (the one containing the variable's name, value, and type) from the output of each call of the function.

I've tried capturing the GM output to a variable and parsing the string, but unlike piping through to the write-host, all of the lines run together, loosing their carriage return and new-line characters, and there doesn't seem to be a consistent punctuation character in the string to parse for, so I can't inject the whitespace (tabs and spaces) to achieve the indentation with. '}' looked hopeful, but not for custom structures' methods nor properties. Besides other information seems to be lost when capturing GM to a string. If the information were not not lost or mangled, then parsing would be fine.

Alternatively, there is piping, which seems to keep the information intact better. I believe that if an object foreach statement were added to the pipe-line where my comment says "Here is where I need help", it could add the whitespace without parsing each line from the GM's string line as it flowed' through, but the "about piping" article and the other article at the MS Learning site didn't give me enough to experiment with or know even if this is the right 'track'.

Please, can someone give me some beginner links, an example, or just let me know if this is the right direction?

Thanks

P.S., I'm using Windows 10, not using VS Code (so no IDE) or any debugger, and I'm very much a newbie at PowerShell.

Update : I'm very close, but here is the problem, a solution, and a new, but related question ...

Name            Value        Type
-------         ------       -----
$v01             1           [Int32]
$v02             "two"       [String]
⋮
$v05             1, 2, 3, 4  [Int32[]]
$v06             one, two, three, four, five
                             [String[]]
⋮
$v08             Collection
                             [Hashtable]
  Method
    Add              void Add(Object key, Object value
                     void IDictionary.Add(Object key, Object value)
    ⋮
  ParameterizedProperty
    Item             Object Item(Object key) {get;set;}
Property
    Count            int Count {get;
    ⋮
$v11            Null
$hash           Collection   [Hashtable]
  Method
    Add              void Add(Object key, Object value
                     void IDictionary.Add(Object key, Object value)
    Clear            void Clear(
                     void IDictionary.Clear()
    ⋮

However in the lines for $v08, some of the lines are missing their endings and others aren't. Here are two that are missing:

$v08 Collection [Hashtable]
Method Add void Add(Object key, Object value <-- missing )
Property Count int Count {get; <-- missing }

Here is the preformatted lines:

$v08             Collection   [Hashtable]
  Method
    Add              void Add(… key, … value), void IDictionary.Add(… key, … value)
    Clear            void Clear(), void IDictionary.Clear()
    ⋮
  ParameterizedProperty
    Item             System.Object Item(… key) {get;set;}
  Property
      Count          int Count {get;}
      IsFixedSize    bool IsFixedSize {get;}
      ⋮

I've replaced the parameter types with … to get the lines to not spill over to the next line. And I've removed most of the lines that didn't loose their endings.

I used the regex pattern ( '([)}]),\s*' ) to find the lines that have more than one method or property, specifically those that have a ) or } followed by a , and optional whitespaces, and replace the matches with
'( $crlf + $tab + $tab + $tab + '' )' to push all of the methods or properties after the first one to a new line and over to the right so the methods or properties align with the others in a column.

I used a regex capture group on the ) and } characters to let me put back whichever was found and cut out the comma, but that argument is a PowerShell expression, not regex, and I don't know the auio-variable that contains the regex $1 matched unnaname group, in PowerShell, that is needed to put the captured ) or }.

I looked for 'powershell -replace regular expression group' in Google and got back lots of possible hits, but I'm mostly blind and unable to read most of the pages that don't support Dark Mode or high context text over a white background; another reason I don't like St...ow. Luckily, after many different searches, I found this:

"User123" -replace "(User)(\d+)", "Admin$2" # Output: "Admin123"

at: https://petri.com/powershell-replace-operator/ and it unlike so many other sites does cover -replace with an regex unnamed group, but adapting this example to my code produces this error:

This error:
Line |
 516 |                ( $1$crlf + $tab + $tab + $tab + ' ' )
     |                    ~~~~~
     | Unexpected token '$crlf' in expression or statement.

However, this is fixed and the ) and } are no longer missing! Here is the working code:

        $this_Definition = `
          $this_Definition `
            -replace 
              '([)}]),\s*',
              ( '$1' + $crlf + $tab + $tab + $tab + ' ' )

Now that the issue is fixed, I'll leave the solution here because this specific use isn't covered much.

I still would like to ask, what other information is hiding in each line of the piped output from the following command?

Get-Member -InputObject 'v08' -MemberType ParameterizedProperty, Properties, Methods ?

I've read the help guide on this command, but frankly didn't understand it well enough to use the few options I have, if people hadn't used them in their comments to this original question.

Please, someone explain the options for this command that are related to variables, including how to get the property values of a collection. Get-Variable works for arrays, but not for collections. Currently I put in 'Collection' for the type I get now. Or, is there a better command? Oh, and explain ii to me slowly, as you would if you were training an AI system. :P

Thanks


r/PowerShell • • 6d ago

News Why developers hate PowerShell

Thumbnail powershellexplained.com
428 Upvotes

This is a post that I have been thinking about writing for a very long time now. I find that developers struggle with PowerShell in a very different way that the sysadmin learning to automate. They bring intuitions and assumptions with them from other languages that catch them off guard when they skip over the documentation. In this article I try to capture some of those experiences and misunderstandings.

I cover a lot of ground in this one: running scripts, execution policy, aliases, objects and formatting, calling functions, output and return values, unrolling, operators, case sensitivity, type conversion, truthiness, strings, scope, automatic variables, paths, encoding, errors, native commands, and classes.

While this one is targeting Software Engineers more then Systems Engineers, I would still appreciate your feedback and stories of your own frustrating experiences.

Thank you, -Kevin


r/PowerShell • • 5d ago

Question Powershell coding help

0 Upvotes

Hi, I'm self learning powershell coding, I'm very new to this and trying my best. I'm using information from websites and mostly Ai to solve and help me on errors

Is there a way to connect powershell to websites? I've been copy pasting codes or taking screenshot on error code and sending to AI to help me out. Sending it manually everytime a new problem came out is wasting me too much time.


r/PowerShell • • 7d ago

Script Sharing I built a free PowerShell tool that finds rogue AI agents on Windows machines

96 Upvotes

Do you know if rogue AI agents are running on your machines?

I've been in IT for 25 years, 13 of them running my own MSP. I built Rogue Agent Checker (RAC) to give back, for the sysadmins who don't know whether agents are running amok on their boxes.

RAC finds AI agents on a Windows machine that aren't on your approved list: Claude Code, OpenClaw, Codex, Copilot agent mode, MCP servers, homemade Python bots. It shows you where each one is and what it can reach, and hands you a report (HTML, CSV, JSON) you can give to a manager or an auditor.

  • Free, Apache-2.0. Plain PowerShell (5.1 or 7). No modules, nothing to install.
  • Read-only. It never changes, disables or deletes anything, and never runs what it finds.
  • Local-only. It doesn't phone home. Keys are reported by name, never by value.
  • One machine per run. For a fleet, push it through your RMM; -RmmMode returns exit codes.

Try it (read-only; it only writes the report folder):

Get-ChildItem -Recurse .\RogueAgentChecker | Unblock-File
.\RogueAgentChecker\Start-RogueAgentScan.ps1 -OutputPath C:\RAC\report

Tested live on Windows 11 against a staged rogue agent (a hidden "OneDrive Sync Helper" calling OpenAI) and a real OpenClaw install. The first build missed the rogue in 3 of 4 scans, because Windows forgot its hostname after 60 seconds. The write-up of that miss, and the fix, is in the repo.

One rule in the README, for the agents: if RAC reports you, say so. Don't rename, hide, relaunch, or reschedule yourself to get around it. That rule exists because an AI agent running my tests over SSH lost its connection and, instead of stopping and telling me, relaunched the run hidden and base64-encoded. RAC can't see agents working over SSH yet. That's first on the 0.2 list.

Full disclosure: I built it with an AI coding assistant and tested every release by hand on real Windows.

Tell me what it misses.

Take back the machines.

https://github.com/richknowles/RogueAgentChecker


r/PowerShell • • 7d ago

News PS7 ScriptDesk v11 - Custom PowerShell 7 ISE

20 Upvotes

Good Morning All,

There is a new version of PS7 Scriptdesk. It has multiple bug fixes and improved Intellisense performance.
Please let me know if anyone finds anymore bugs or performance issues.
I am still looking for Export to API/EXE testers if anyone could lend some real world use to my lab test environment.

I forgot to mention. This is for the community. We can make it as user friendly or advanced as we want it to be. So long as we stay true to the spirit of the legacy ISE.

Case in point, all the PS specific formatting options available to the right click. That can be altered, expanded or changed in the behavior. I literally just started adding things that I do a lot and wanted to automate it, like taking a list and making it a sorted array. You have no idea how many times I just copy a column and insert it.

Regards,

-Ron

https://apps.microsoft.com/store/detail/9N8C4LMQXMF6?cid=DevShareMCLPCS

Another user pointed out the winget way of installing. That is fine but it may break the auto update feature.

winget search PS7

Name Id Version Source

--------------------------------------------

PS7 ScriptDesk 9N8C4LMQXMF6 Unknown msstore


r/PowerShell • • 8d ago

Solved Script to resolve missing MSI Cache for google chrome (1603,1612)

21 Upvotes

Just sharing this because ive had this issue across 1500 devices and with the help of copilot this script has been generated and has been resolving the issues perfectly.

Due to missing MSI Caches, Upgrades for chrome are failing with MSI 1603 or MSI 1612. This script pulls the latest, forcefully removes the old chrome, and installs fresh

 # ==========================
# Google Chrome Remediation
# ==========================

$DownloadUrl = "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise64.msi"
$TempDir     = "C:\ProgramData\ChromeRemediation"
$MSIPath     = Join-Path $TempDir "GoogleChromeStandaloneEnterprise64.msi"

Write-Host "Starting Chrome remediation..."

# Ensure TLS 1.2+ is enabled for older PowerShell / Windows builds
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13

# --------------------------------------------------
# Download Latest Chrome Enterprise 64-bit MSI
# --------------------------------------------------

New-Item -ItemType Directory -Path $TempDir -Force | Out-Null

Write-Host "Downloading latest Chrome Enterprise 64-bit MSI..."

try {
    # Suppress progress bar to prevent severe Invoke-WebRequest slowdowns in PowerShell 5.1
    $ProgressPreference = 'SilentlyContinue'
    Invoke-WebRequest -Uri $DownloadUrl -OutFile $MSIPath -UseBasicParsing -ErrorAction Stop
}
catch {
    Write-Error "Failed to download Chrome MSI: $_"
    exit 1
}

# Verify the file exists and is valid (at least 50 MB to rule out HTML error pages)
if (-not (Test-Path $MSIPath) -or (Get-Item $MSIPath).Length -lt 50MB) {
    Write-Error "Downloaded MSI is missing or smaller than expected. Aborting remediation."
    exit 1
}

Write-Host "Download verified ($([math]::Round((Get-Item $MSIPath).Length / 1MB, 2)) MB)."

# --------------------------------------------------
# Backup bookmarks
# --------------------------------------------------

$BackupRoot = "C:\ProgramData\ChromeBookmarkBackup"

New-Item -ItemType Directory -Path $BackupRoot -Force | Out-Null

Get-ChildItem "C:\Users" -Directory -ErrorAction SilentlyContinue | ForEach-Object {

    $User = $_.Name

    Get-ChildItem "$($_.FullName)\AppData\Local\Google\Chrome\User Data" `
        -Directory `
        -ErrorAction SilentlyContinue |

    ForEach-Object {

        $BookmarkFile = Join-Path $_.FullName "Bookmarks"

        if (Test-Path $BookmarkFile) {

            $BackupName = "$User-$($_.Name)-Bookmarks.json"

            Copy-Item `
                $BookmarkFile `
                (Join-Path $BackupRoot $BackupName) `
                -Force `
                -ErrorAction SilentlyContinue

            Write-Host "Backed up bookmarks for $User ($($_.Name))"
        }
    }
}

# --------------------------------------------------
# Kill Chrome Processes
# --------------------------------------------------

Get-Process chrome,googleupdate,googleupdater `
    -ErrorAction SilentlyContinue |
    Stop-Process -Force

# --------------------------------------------------
# Remove Chrome Uninstall Keys
# --------------------------------------------------

$UninstallRoots = @(
    "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall",
    "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
)

foreach ($Root in $UninstallRoots) {

    Get-ChildItem $Root -ErrorAction SilentlyContinue | ForEach-Object {

        $App = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue

        if ($App.DisplayName -eq "Google Chrome") {

            Write-Host "Removing uninstall key $($_.PSChildName)"

            Remove-Item $_.PSPath `
                -Recurse `
                -Force `
                -ErrorAction SilentlyContinue
        }
    }
}

# --------------------------------------------------
# Remove Windows Installer Product Registrations
# --------------------------------------------------

Get-ChildItem `
    "Registry::HKEY_CLASSES_ROOT\Installer\Products" `
    -ErrorAction SilentlyContinue |

ForEach-Object {

    $Item = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue

    if ($Item.ProductName -eq "Google Chrome") {

        Write-Host "Removing installer registration $($_.PSChildName)"

        Remove-Item $_.PSPath `
            -Recurse `
            -Force `
            -ErrorAction SilentlyContinue
    }
}

# --------------------------------------------------
# Remove Program Files Installs
# --------------------------------------------------

Remove-Item `
    "C:\Program Files\Google\Chrome" `
    -Recurse `
    -Force `
    -ErrorAction SilentlyContinue

Remove-Item `
    "C:\Program Files (x86)\Google\Chrome" `
    -Recurse `
    -Force `
    -ErrorAction SilentlyContinue

# --------------------------------------------------
# Install Latest Chrome
# --------------------------------------------------

$Process = Start-Process `
    msiexec.exe `
    -ArgumentList "/i `"$MSIPath`" /qn /norestart" `
    -Wait `
    -PassThru

Write-Host "Chrome MSI exit code: $($Process.ExitCode)"

# Clean up the downloaded installer
Remove-Item $TempDir -Recurse -Force -ErrorAction SilentlyContinue

if ($Process.ExitCode -in @(0,3010)) {

    Write-Host "Chrome installation successful"

} else {

    Write-Host "Chrome installation failed"
    exit $Process.ExitCode
}

# --------------------------------------------------
# Validation
# --------------------------------------------------

$Chrome = Get-ItemProperty `
HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, `
HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* `
-ErrorAction SilentlyContinue |
Where-Object {$_.DisplayName -eq "Google Chrome"}

if ($Chrome) {

    Write-Host "Installed Version: $($Chrome.DisplayVersion)"

} else {

    Write-Host "Chrome not detected after install"
    exit 1

}


r/PowerShell • • 8d ago

Question Why does this run and how do I fix it to work right?

5 Upvotes

Hello, I'm fairly new to writing PowerShell Scripts, and have a lot to learn. I'm running pwsh v7.7 on Windows 10.

With a lot of help from the ReddIt people who responded to my original question, I've written a 'write-variable' function that I can call from scripts that I develop for the times when I want to get information about one or more variables. Previously I put a bunch of write-hosts, get-variables, get-members, gettypes, and other statements in my scripts to 'see' what's happening with a particular variable, but with this function I've generalized and combined all of that stuff into a single function that doesn't need to be rewritten for each variable, value (i,e, Null) or type change that occurs. 90% of the problems I had writing this function had to do with line continuation (`) and incorrectly using the -replace pattern, code [string] method. But with lots of 'pointers' and guidance my function is done.

Here is the output I get running the function, which is after the output:

v1 1 (Int32)
System.Object Clone()
System.Object ICloneable.Clone()

int CompareTo(System.Object value)
⋮

Now the function:

function write-variable {
  param(
    [Parameter(Mandatory)]
 
    [string] $variable_name,

    [switch] $showMembers
  )

  $value = get-variable -name $variable_name -valueonly

  if( $value -eq $NULL ) {

    $value = 'Null'

  }
  else {

    $type = $value.gettype().Name

    $quote = switch( $type[ 0 ] ) {
               's'     { '"' } # [string]
               'c'     { "'" } # [char]
               default { '' }
             }

    $value = (
        $quote + $value + $quote +
        ' (' + $type + ')'
      )

  }

  write-host (
      $variable_name +
      "\t`t" + $value
    )

  if( $showMembers ) {

    $members = get-member -InputObject $variable_name

    # replace all leading whitespaces
    # with a crlf.`

    $members = $members -replace
                 '^\s*', "\r`n"

    # Replace ), and whitespace ( 0 or more )
    # with ) and add crlf.

    $members = $members -replace
                 '),?\s*',
                 {
                   return ')' + $crlf
                 }

    write-host $members
    
  }

}

[int] $v1 = 1

write-variable 'v1' -showMember

Thanks


r/PowerShell • • 8d ago

Script Sharing Built a desktop organizer in PowerShell 5.1 using NTFS junctions + a custom WinForms pixel UI

0 Upvotes

Sharing a side project written entirely in Windows PowerShell 5.1 (plus some inline C# via Add-Type).

It moves project folders off the desktop with Directory.Move and creates a hidden+system junction at the old path, so tools never notice. Some technical bits that might interest you:

- Folders are tracked by volume serial + file ID + creation time, so renames/moves in Explorer get re-pointed automatically

- Every move is journaled first, and interrupted operations are completed on next start

- Lists processes holding a folder before moving and aborts cleanly

- Test suites via switches (-SafetyTest, -IntegrationTest…) that run in a temp folder

⚠️ PSA from building this: Remove-Item -Recurse in 5.1 follows junctions and deletes the target's contents.

Repo (MIT): https://github.com/xkudcobi/ender-chest. Code review and criticism welcome.


r/PowerShell • • 9d ago

Question Mapped network printer via Add-Printer, can't remove it (what the hell)

0 Upvotes

We deployed printers via Intune as Powershell scripts (before the option was added to the Settings Catalog) and they've been chilling there for three years doing their job.

However, now that we're stepping away from Papercut, I have to remove these mapped printers but for the life of me, I can't get it done. I let Claude Opus at it for 15 minutes, couldn't get it done so what the fuck.

I've tried to:

  • Get the printer with Get-Printer -name "printername" | remove-printer. The issue here is that Remove-Printer -name does not accept the "\" character but since it's a networked printer, it always starts with \\.
  • Remove the registry keys that have the connection but that doesn't do shit.
  • Ran this as standard user, elevated and SYSTEM. Nothing.

Am I missing something, here? We're Entra joined so no GPO's and I don't see a config profile to actually remove mapped printers.

UPDATE:

Alright, I found it. I forgot I was testing with Admin Protection in Intune at the same time. When Intune runs a Powershell script in the user context, it runs it under another context (ADMIN_myUserName). So of course it couldn't find shit. That's going to take a lot of rethinking.


r/PowerShell • • 12d ago

News Windows PowerShell 5.1 Deprecation

160 Upvotes

Windows PowerShell 5.1 is deprecated. It's no longer in active development. Windows PowerShell 5.1 is still part of Windows, and it's still supported. It will continue to receive security updates according to the lifecycle of each version of Windows. Scripts and tools that rely on it will continue to run.

Windows PowerShell 5.1 will be removed from a future version of Windows. Timing will be based on usage data and communicated in advance.

Microsoft recommends upgrading to PowerShell 7, the upgrade from Windows PowerShell 5.1. For more information, see Migrating from Windows PowerShell 5.1 to PowerShell 7.

Timeline

2026: Windows PowerShell 5.1 is deprecated. Windows Server 2025 and Windows 11, version 26H2 are the last versions of Windows to include PowerShell 5.1 enabled by default.
Next Version of Windows: Windows PowerShell 5.1 will be available as a Feature on Demand (FOD), enabled by default on new Windows installs.
Future Version of Windows: Not available.

https://support.microsoft.com/en-us/servicing/os/windows/docs/2026/11/kb5137172-windows-powershell-5-1-deprecation

At the moment there are many, many Windows management PowerShell modules built in to that aren’t supported in PowerShell 7 - they are either completely untested, or they only work via the (PowerShell 5.1 dependent) compatibility layer. Does this mean we can expect new native modules, or everything to just break? #notholdingmybreath

Affected modules:
- Domain Controller deployment (ADDSDeployment)
- ADFS
- AppLocker
- AppvClient
- BestPractices
- ClusterAwareUpdating
- ConfigCI
- DFSR
- DhcpServer
- DISM (presently has issue with MSIX installer)
- FailoverClusters, FailoverClusterSet
- GroupPolicy
- Both IIS management modules (IISAdministration, WebAdministration)
- IpamServer
- iSCSI, IscsiTarget
- ISE
- Microsoft.PowerShell.ODataUtils
- MsDtc
- NetLldpAgent
- NetWNV
- NetworkController, NetworkControllerDiagnostics
- NetworkLoadBalancingClusters
- PersistentMemory
- PKI
- Provisioning
- PSDesiredStateConfiguration (partially supported)
- PSScheduledJob
- PSWorkflow, PSWorkflowUtility
- RemoteAccess
- RemoteDesktop
- ServerCore
- ServerManagerTasks
- SMS
- StorageBusCache
- StorageMigrationService
- StorageReplica
- SystemInsights
- TLS
- UpdateServices

EDIT: The following PowerShell modules are also currently Windows PowerShell 5.1 only:

- AzureADHybridAuthenticationManagement
- SharePoint Online Management Shell
- Power Platform admin modules
- Systems Center Operations Manager (SCOM)
- Systems Center Virtual Machine Manager (SCVMM)
- Entra Connect (Azure AD Sync)

https://learn.microsoft.com/en-us/powershell/windows/module-compatibility?view=windowsserver2025-ps

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_windows_powershell_compatibility?view=powershell-7.6


r/PowerShell • • 11d ago

Script Sharing A dock, desktop widget and falling snow for Windows, all in one PowerShell script (WPF + a bit of C#)

3 Upvotes

MacDesk is a macOS-style dock and desktop widget written in Windows PowerShell 5.1 with WPF. This winter it also got snow that settles on your windows.

Things that were fun or painful to get right:

- The snow overlay can't be a WPF window. WPF removes WS_EX_LAYERED from GPU-rendered windows, so a "transparent" overlay ends up eating every click on the desktop (I found out the hard way). It's now raw Win32 layered windows painted by hand with UpdateLayeredWindowIndirect, updating only the rectangles that changed.

- It runs on its own thread and paces frames with DwmFlush, which gave a steady 60 fps. A DispatcherTimer gave uneven 20-40 fps.

- Window tops come from EnumWindows plus DWMWA_EXTENDED_FRAME_BOUNDS, with z-order occlusion so snow only lands on visible edges.

- The C# is compiled at startup with Add-Type, so it's limited to C# 5.

- If the overlay ever loses click-through, a watchdog turns the snow off.

Repo: https://github.com/b33nthere/MacDesk

Feedback on the code is welcome, especially the WPF / Win32 parts.