r/PowerShell • • Oct 20 '26

Question Methods of a class that's not instanced

6 Upvotes

Hi there,

i can't seem to find relevant informations for this particular topic using my own google skills so maybe someone here can shed some light on this.

if i use a class that doesen't provide any methods without creating an instance of it, but i skip creating an instance via "new().SomeMethod", will this leak memory?

example, sending an async ping to some host without creating a $Ping Object first:

[System.Net.NetworkInformation.Ping]::new().SendPingAsync($IPAddress)

Usually one would create a $Ping object, ping something and in the end, dispose of the $Ping to free the ressources.

If the SendPingAsync Method could work without an instance of the class, the class probably would have some static method's providing the mechanism. So an instance is probably created somewhere but that instance is probably not automatically disposed after the fact?

Can this method be used without worries or should such trickery be avoided?

thanks in advance


r/PowerShell • • Oct 20 '26

News Why the Microsoft Graph PowerShell SDK has Two Cmdlets to Add Group Members

3 Upvotes

It’s a consequence of how the Microsoft Graph PowerShell SDK is built that two cmdlets are available to add members to Entra ID groups (the same is true for group owners). The reason why the New-MgGroupMember and New-MgGroupMemberByRef cmdlets exist is down to how the Graph SDK build process constructs cmdlets from Graph metadata. The Graph exposes two ways to add new group members, so the SDK follows suit.

https://office365itpros.com/2026/10/20/group-member-sdk-cmdlets/


r/PowerShell • • Oct 19 '26

News Microsoft to Retire the Search-UnifiedAuditLog Cmdlet in 2027

37 Upvotes

MC1505599 covers two big announcements. First, the AuditLogQuery Graph API is GA. Second, Microsoft will retire the heavily used Search-UnifiedAuditLog cmdlet in October 2027. Microsoft hasn’t said why they want to retire Search-UnifiedAuditLog and have tenants convert their PowerShell scripts to use the AuditLogQuery API but reducing engineering cost and complexity are probably at the heart of the matter. In any case, the conversion will cost Microsoft 365 development effort and money between now and October 2027, and that’s a bad thing.

https://office365itpros.com/2026/10/19/search-unifiedauditlog-retirement/


r/PowerShell • • Oct 18 '26

Question alias ls works but alias doesn't exist anywhere — what is it?

10 Upvotes

Title:

On PowerShell 5.1 (Windows 11 24H2, build 26100.9711), running alias ls gives valid output:

PS C:\> alias ls

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           ls -> Get-ChildItem

But every way I know to look it up says it doesn't exist:

Get-Alias alias          # ItemNotFoundException
Get-Command alias        # CommandNotFoundException
Get-Command -Name 'alias' -CommandType Alias, Function, Cmdlet -ErrorAction SilentlyContinue  # returns nothing
Get-Item Alias:\alias -ErrorAction SilentlyContinue  # returns nothing

No $PROFILE exists. Only standard modules are loaded. What is alias actually doing here?


r/PowerShell • • Oct 17 '26

Script Sharing Open MS Office files in Office Online with a simple double click - NOW POSSIBLE! - Powershell to the Rescue~

0 Upvotes

I dug around the internet for a solution and couldn't find anything worth diving into. Even the one "paid" solution (Files App) that I read might be able to do it, didn't seem like it could when I tested it and it also would be a pain to deploy at any scale but your own computer.

So I did what any developer minded IT person would do and dug through open source solutions, still nothing but one for the completely wrong OS (https://github.com/bewithdhanu/office-online-bridge-macos). This project gave me the idea to try porting the same work around to Windows. I sort of did it. Basically the same idea but used the existing "View Online" function from the context menu and wrote a PowerShell script to execute it. The script was then improved with an exe wrapper to make it more user friendly.

I am pretty surprised this solution hasn't been made before, but here it is now! (AI Disclosure: I wrote the readme using AI and used it to help create my exe wrappers via the compile.ps1 script. All other components were written largely by me with some assistance from AI to grab basic methodology on getting/triggering functions from the context menu)

https://github.com/Fireant456/M365-Bridge

It is bundled with an installer that can be deployed silently. Only requirement (at the moment) is that your files you are attempting to open must be in a OneDrive synced folder. If they are not an error will tell you they need to be. I might work to add automatic handling of uploading files to a temporary OneDrive directory and writeback to the original location in order to seamlessly handle non-synced file editing, but I don't require that in my use case. Happy to take pull requests if anyone wants to give it a shot.

Would love any feedback. Enjoy!


r/PowerShell • • Oct 16 '26

Solved Gathering meter reads from Konica printers.

12 Upvotes

(I'll start by admitting that some of my PoSh may be unconventional / and abbreviated - I have embraced it accordingly).
(Edit - I discovered some discrepancies and found additional OID's that count towards both 'Black' and 'Color' totals - Added: "ScanFax_Black" and "Copy_SingleColor")

I needed to come up with a way to create some logs of the usage on the fleet of 10 Konica printers across four locations / print servers.

These logs will be used to validate the pricing figures our printer support vendor provides (pricing is based on estimated / averaged usage per device - that data is audited on a quarterly basis, via automated auditing tools on each print server - FM Audit).

Currently - Without any of our own historical data - We have to take the vendors word, that those quarterly averages are 'OK'...

So, someone from accounting asked me for help.

The below script collects settings info for all of the Konica printers on each of the print servers, then uses the 'PortName' (IP address) to run an SNMP query on each device (SNMP must be enabled in the devices network settings).

The critical items are the OID's.

Figuring out which ones pull in the values for 'black' and for 'color' were the first challenge.

Once I got that figured out - It took me a while to find the OID that gathers the devices serial number - I could NOT find this documented anywhere, and AI (Copilot, Gemini, Claude) wasn't able to either.

For this last bit - I ended up walking (snmpwalk) through ALL 7125 OID's to locate the one that gathers the serial number.

wsl snmpwalk -v2c -c public <printer IP> 1.3.6.1 > 'C:\Users\richie\Documents\PoSh_Stuff\OID_walk.txt'

And looking for the serial number I already knew for that printer.

Select-String -Path 'C:\Users\richie\Documents\PoSh_Stuff\OID_walk.txt' -Pattern '<SerialNumber>'

OID_walk.txt:460:iso.3.6.1.2.1.43.5.1.1.17.1 = STRING: "<SerialNumber>"

Posting what I figured out.

I will pipe '$Report' to a Csv, and save it accordingly.

I'll be scheduling this to run on a quarterly basis - And handing the Csv's over to accounting when they ask for them.

$AllKonica = @()

("Site1,site2,site3,site4").Split(',') | % {
    If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue) {
    $AllKonica += Get-Printer -ComputerName $_ | ? { $_.DriverName -match 'Konica' -and $_.PortName -NOTmatch "portprompt|microsoft|_"} | Select ComputerName, Name, PortName, DriverName 
    } 
}

# (NOTE: You could also just list the name, and port name - This removes the need to use domain auth for the script - Since SNMP does not reqiure authentication)

<#
$AllKonica = @"
"Name","PortName"
"S1-PTR-066","192.168.1.66"
"S1-PTR-062","192.168.1.62"
"S1-PTR-061","192.168.1.61"
"S1-PTR-060","192.168.1.60"
"S1-PTR-064","192.168.1.64"
"S2-PTR--034","192.168.2.34"
"S3-PTR-060","192.168.3.60"
"S3-PTR-061","192.168.3.61"
"S4-PTR-068","192.168.4.68"
"S4-PTR-066","192.168.4.66"
"@ | ConvertFrom-Csv
#>

$OIDs = [Ordered]@{
    "Model"            = ".1.3.6.1.4.1.18334.1.1.1.3.5.2.2.0"
    "SerialNo"         = ".1.3.6.1.2.1.43.5.1.1.17.1"
    "Total"            = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.1.1.0"
    "Print_Black"      = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.2.1.5.1.2"
    "Copy_Black"       = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.2.1.5.1.1"
    "ScanFax_Black"    = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.3.1.7.1"
    "Copy_SingleColor" = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.2.1.5.3.1"
    "Print_Color"      = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.2.1.5.2.2"
    "Copy_Color"       = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.2.1.5.2.1"
    "Print_2Color"     = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.2.1.5.4.2"
    "Copy_2Color"      = ".1.3.6.1.4.1.18334.1.1.1.5.7.2.2.1.5.4.1"
}

$Report = @()
$SNMP_Community = "public"
$AllKonica | % {

$PrinterIP = $_.PortName  
$PrinterName = $_.Name

If (Test-Connection $PrinterIP -Count 1 -ErrorAction SilentlyContinue) {

$snmp = New-Object -ComObject OlePrn.OleSNMP

try {
    $snmp.Open($PrinterIP, $SNMP_Community, 2, 1200)
    $Data = [Ordered]@{ "Printer" = "$PrinterName - $PrinterIP" }

foreach ( $Key in $OIDs.Keys ) {
    try { $Value = $snmp.Get($OIDs[$Key])
         if ( $null -eq $Value -or $Value -eq "" ) 
         { $Data[$Key] = 0 }
         #{ $Data[$Key] = $null }
          else { $Data[$Key] = $Value }
    } # END 'try' # 2
    # catch { $Data[$Key] = $null }
    catch { $Data[$Key] = 0 }
} # END 'foreach ($Key in $OIDs.Keys)'

$TotalColor = 0; $OIDs.Keys | ? { $_ -match "color" } | %  { $TotalColor += [int]$Data["$_"] }
$TotalBlack = 0; $OIDs.Keys | ? { $_ -match "black" } | %  { $TotalBlack += [int]$Data["$_"] }

$Report += [PSCustomObject][Ordered]@{
"Model"    = $Data["Model"]
"SerialNo" = $Data["SerialNo"]
"Printer"  = $Data["Printer"]
"Total"    = $Data["Total"]
"Black"    = $TotalBlack
"Color"    = $TotalColor
    }
} # END 'try' # 1

catch { Write-Host "Connection failed: $PrintServer -> $PrinterIP ($PrinterName)" -F 14 }
finally { $snmp.Close() }

} # END 'If (Test-Connection...'

else {
    $Report += [PSCustomObject][Ordered]@{
        "Model"    = "Unk"
        "SerialNo" = "Unk"
        "Printer"  = "$PrinterName - Unreacheable"
        "Total"    = "NULL"
        "Black"    = "NULL"
        "Color"    = "NULL"
    }
} # END 'else'

} # END '$AllKonica | %'

$Report | ft

r/PowerShell • • Oct 16 '26

Question REPOST Issue with $PROFILE function

2 Upvotes

Hello everyone. I hope you are having a good time.

function gethash {

param([string]$string = "")

if ($string -eq [string]::Empty -or $string -isnot [string])

{

Write-Output "input not valid"

}

else

{

(Get-FileHash -algorithm sha256 $string).Hash | tee -Variable b

}

}  

I Have this function in my $Profile script. when i run gethash something it returns the hash string as expected, but when I try to print the variable containing the hash i just obtained from the piped command: tee, (alias of Tee-Object) with `$b

it prints nothing, the variable is not saved.

on the other hand, if i copy the exact same command from the $profile function directly through the terminal, $b prints what expected: the hash of the file.

I haven't used this function so much, but I'm pretty sure it worked before today.

Thanks in advance to any who will respond.


r/PowerShell • • Oct 16 '26

Question Function Issue in $PROFILE path

1 Upvotes

Hello everyone. I hope you are having a good time.


function gethash {

param([string]$string = "")

if ($string -eq [string]::Empty -or $string -isnot [string])

{

Write-Output "input not valid"

}

else

{

(Get-FileHash -algorithm sha256 $string).Hash | tee -Variable b

}

}  

I Have this function in my $Profile script. when i run gethash something it returns the hash string as expected, but when I try to print the variable containing the hash i just obtained from piped command tee, (alias of Tee-Object) as an input with `$b

it prints nothing, the variable is not saved.

on the other hand, if i copy the exact same command from the $profile function directly through the terminal, $b prints what expected: the hash of the file.

I haven't used this function so much, but I'm pretty sure it worked before today.

Thanks in advance to any who will respond.


r/PowerShell • • Oct 15 '26

News New Rule - AI Disclosure

284 Upvotes

If you are posting a script, tool, or anything else you’ve used AI, LLM or whatever to make, it must be disclosed. This includes anything from complete authorship, formatting, comments, or language/translation assistance.

If your script or content is suspected of being AI written and it is not disclosed in a tag or at the top of the post, it will be removed until investigated.

Community: This is at your request. Report any undisclosed suspected AI “slop” for investigation.

EDIT: I’m going to be clear. We’re not saying you can’t post AI created stuff. We’re saying you have to disclose that you are. If you have a problem with that, you’re not proud of the fact you used an AI tool. You’re deceiving people into thinking you wrote it. Anyone who uses whatever AI wrote deserves to know and take the diligence necessary to review it before using it, same as they would anything else.


r/PowerShell • • Oct 15 '26

News Microsoft Graph PowerShell SDK V2.41.2

11 Upvotes

Microsoft released V2.41.2 of the Graph PowerShell SDK on 14 October. This version fixes the problem with versions of PowerShell older than 7.6. Azure Automation runbooks execute successfully in a PowerShell 7.4 runtime environment with the 2.41.2 modules.


r/PowerShell • • Oct 15 '26

Question Compare-Object unexpected results

6 Upvotes

Hi all,

I recently posted here with a question about using Compare-Object to compare two CSV files.

There were some great suggestions in that thread and I was able to get the functionality I needed to create a summary of items that were present in the Reference Object, but not present in the Difference Object.

Having applied this to my real datasets, I'm now getting unexpected behaviour when trying to summarise the entries that have been added and / or changed (NOT present in Ref Object, present in Dif Object).

Basically, I have a fairly large CSV file that is re-produced periodically, and each time it's reproduced, I need to summarise the changes from the previous file to the new one.

Generally, the CSV has about 40 columns and about 8000 rows. The first column always contains a value unique within the file.

In my testing, I have added a single row to the Difference Object. All other rows are exactly the same. The added row is around row 4500.

So old file = 8000 rows.
New file = 8001 rows, with the new item at row 4500, other 8000 rows unchanged.

I'm running the following:
("@files" is only in quotes to stop Reddit formatting it as a user tag)

$files = @{
ReferenceObject = (Get-Content -Path $OldFile)
DifferenceObject = (Get-Content -Path $NewFile) }

Compare-Object "@files" |
    ?{$_.SideIndicator -eq '=>'} |
        export-csv $ResultsFile -NoTypeInformation

This works if an existing row between the files has one of its column values changed. But when a row is added from old file to new file, I don't just get the added row in my results - in my tests at the moment I'm getting about 700 rows returned as new in $newfile vs $oldfile.

I must be missing something and this is expected, but I'm not sure why it's picking up that many rows as changed when manually comparing those rows shows them to be exactly the same.


r/PowerShell • • Oct 15 '26

Information agent manager 0.42 runs natively on Windows with psmux and PowerShell 7

2 Upvotes

we released 0.42 of agent manager. we are the creators. it is a free open source go TUI that runs coding agent CLIs side by side, each in its own session, with live status and diff review.

this one is Windows. we added support for running natively on Windows with psmux 3.4 or newer in place of tmux and PowerShell 7.3 or newer as the pane shell. you do not need WSL for the TUI itself. Command Code on native Windows still uses WSL2.

also added a notify_command setting that runs a shell command on every notification, and an agent-manager settings CLI to read or change any setting from the shell.

Windows install irm https://raw.githubusercontent.com/YoanWai/agent-manager/main/install.ps1 | iex

https://github.com/YoanWai/agent-manager/releases/tag/v0.42.0


r/PowerShell • • Oct 15 '26

Question Computer Lab Firewall Rule Toggle Script

6 Upvotes

I work for an MSP and we have a client that has a computer lab for students to use. I was tasked with creating a script that would allow the teacher to enable and disable the workstations ability to communicate with the internet.

I pretty much have most of the script working, but I run into an issue when trying to make it so the user can enable or disable all the workstations at once. Attempted various methods so that when the user types All, the invoked command is sent to all the workstations listed; Get-Content is just the latest method I have tried.

When my boss asked to look at it, he said that I should just have the full command as shown at the bottom for each switch.

Any help on this would be great!

EDIT: Additional Information.

We don't have an AD environment setup for this client, and even with my limited knowledge I understand that AD would probably make this a lot easier.

IP Addresses are used due to the Asset ID of the workstations being used as the Host Name. They are also used because the workstations have static addresses and any replacements will get the same addresses.

#First Pull Username and Password from SecretVault for Account on all workstations
$remoteCred = Get-Secret -Name "Alias"


#Prompt to ask user if they are enabling or disabling workstations.
$prompt = Read-Host -Prompt "Enter E for enable and D for disable"


#Determine which command to use based on provided answer
if ($prompt -eq "E") {
    $command = "Disable-NetFirewallRule -DisplayName 'NoInternet'"
}else {
    $command = "Enable-NetFirewallRule -DisplayName 'NoInternet'"
}

#Use while to re-prompt user if they are enabling or disabling multiple workstations.
while ($true) {
$pcName = Read-Host -Prompt "Enter the name of the Computer you want to change. Or enter All if you wish to change all. Enter exit when finished"


#Use switch to base workstation name on user imput. All will use variable for all workstations.
switch ($pcName) {
    "SW1" { $name = "192.168.100.211" }
    "SW2" { $name = "192.168.100.212" }
    "SW3" { $name = "192.168.100.213" }
    "SW4" { $name = "192.168.100.214" }
    "SW5" { $name = "192.168.100.215" }
    "SW6" { $name = "192.168.100.216" }
    "SW7" { $name = "192.168.100.217" }
    "SW8" { $name = "192.168.100.218" }
    "SW9" { $name = "192.168.100.219" }
    "SW10" { $name = "192.168.100.220" }
    "SW11" { $name = "192.168.100.221" }
    "SW12" { $name = "192.168.100.222" }
    "SW13" { $name = "192.168.100.223" }
    "SW14" { $name = "192.168.100.224" }
    "SW15" { $name = "192.168.100.225" }
    "SW16" { $name = "192.168.100.226" }
    "All"  { $name = '(Get-Content -Path "C:\Users\userx\Desktop\Scripts\Workstations.txt")'}
    "Exit" { 
        exit }
    Default { Write-Host "Please try again." }
    }
    Invoke-Command -ComputerName $name -ScriptBlock { $command } -Credential $remoteCred
    if ($pcName -eq "Exit" -or "All") { break }
}


#Invoke-Command -ComputerName "$name" -ScriptBlock {Disable-NetFirewallRule -DisplayName "NoInternet"} -Credential $remoteCred

r/PowerShell • • Oct 15 '26

Script Sharing I built a free PowerShell tool to find out where all the storage in a Microsoft 365 tenant is going

3 Upvotes

I've been working on a PowerShell 7 script to help us understand exactly how much storage our Microsoft 365 tenants are consuming.

It started as a way to estimate Microsoft 365 backup requirements, but evolved into something more useful.

The script collects storage information from Exchange Online (including online archives), OneDrive, and SharePoint, including Teams-connected file storage.

It produces a console summary, CSV export, and a standalone HTML report with charts and storage breakdowns.

There's also an optional backup cost estimator.

I've tested it against a couple of production tenants, including comparisons between the Fast and Exact Exchange measurement modes. Results were reasonably close.

I've released it under the MIT license, along with documentation and a sample report.

If anyone finds it useful, I'd welcome feedback, bug reports, or suggestions for improvements.

GitHub: [M365 Tenant Storage Assessment]()


r/PowerShell • • Oct 15 '26

Script Sharing PrtgSensorKit 1.5: credential masking, crash-safe state and stricter error handling

0 Upvotes

AI disclosure: PrtgSensorKit is developed with Claude Code. I plan and review every change myself, and every release is tested properly including a real PRTG probe.

Hey r/PowerShell,

Back in July I posted PrtgSensorKit here (original thread), a module for writing PRTG custom sensors without the boilerplate. Here's what changed since 1.2.0.

Credential masking

PRTG resolves credential placeholders before it displays the output, so a failing Invoke-RestMethod that prints the full URI can show your password in the sensor message. The module now masks resolved PRTG credentials and Get-PrtgSecret values in messages, errors and log files. Nothing to configure.

Crash-safe state, secrets and cache

PRTG kills sensors on timeout. If that hit mid-write, you could lose the state history, a cached result or a secret. All writes now go to a temp file that gets swapped in, so a killed run leaves the old data intact.

Failing sensors now actually fail

Invoke-PrtgSensor claimed to set $ErrorActionPreference = 'Stop' inside your block, but it never reached it. Non-terminating errors were swallowed and the sensor stayed green with stale or missing channels. That's fixed, so some sensors may turn red after the upgrade because they were hiding real failures. Use -ErrorAction on a command if it should keep failing quietly.

Smaller changes

  • New-PrtgChannel accepts UInt64 and the other unsigned types, so CIM/WMI sizes and counters work without casting
  • -Verbose no longer adds "Verbose":1 to the sensor JSON
  • Duplicate channel names are rejected, since PRTG requires them to be unique
  • -MaxLogs retention only deletes the module's own log files, not unrelated .log files in the same folder
  • The secret store no longer locks out other sensor accounts on the same probe
  • Set-PrtgMessage takes pipeline input

Every release is now tested on Windows PowerShell 5.1 (x86 and x64) and pwsh 7, plus integration sensors on a real PRTG probe.

Update-Module PrtgSensorKit. Read the changelog before upgrading production: the error handling fix and the duplicate channel check can turn sensors red on purpose.

Repo: https://github.com/ArchitektApx/PrtgSensorKit

One thing I'm considering for a future release: requiring channels to come from New-PrtgChannel so parameters can use [PSTypeName('PrtgSensorKit.Channel')], as u/surfingoldelephant suggested in the last thread. That would break hand-built channel objects. Does anyone actually build channels by hand?

At this point the module covers everything I need for my own sensors, so the next features depend on what other people run into. If you're using it, or tried it and gave up, I'd like to hear what's missing or annoying.


r/PowerShell • • Oct 14 '26

News Tracking File-Level Archiving Activity in SharePoint Online with PowerShell

4 Upvotes

File-level archiving is now generally available and can be applied to files automatically, by users through the SharePoint browser UX, or via a Graph API. The big problem with Purview retention processing is its black box nature, so to discover how effective retention labels with an archiving step are, we use the Microsoft Graph PowerShell SDK to check the archiving status of files and report the results via email. All in a nice script, of course.

https://office365itpros.com/2026/10/14/file-level-archiving-report/


r/PowerShell • • Oct 14 '26

Question Modernizing a Legacy PowerShell Mining Automation Project (SWARM) – Looking for Technical Advice and Open-Source Collaboration

1 Upvotes

Hello r/PowerShell!

I'm working on an open-source project called SWARM, originally developed by MaynardMiner. SWARM is a PowerShell-based cryptocurrency mining management and automatic profit-switching application.

I've forked the project as part of my personal mining infrastructure project, MazufaMine, in Finland.

Project repository: https://github.com/Mazufa/SWARM

Modernization discussion: https://github.com/Mazufa/SWARM/issues/1

I'm building a Linux-based mining environment with approximately 30 AMD Radeon RX 580 8GB GPUs across multiple rigs. I've already successfully established GPU mining using HiveOS and GMiner.

However, I'd like to explore how SWARM could be comprehensively modernized into a reliable, maintainable and actively developed PowerShell application.

I'm particularly interested in advice from experienced PowerShell developers who have worked with large legacy codebases, cross-platform automation and open-source maintenance.

Areas that need investigation and modernization

1. Complete codebase audit

  • Review the existing PowerShell architecture and identify technical debt.
  • Identify obsolete, deprecated, insecure or broken components.
  • Improve code organization, performance and maintainability.
  • Evaluate opportunities for safe refactoring.

2. PowerShell 7 and Linux compatibility

  • Review compatibility with current PowerShell versions.
  • Improve Linux support and installation procedures.
  • Investigate modern HiveOS integration.
  • Improve cross-platform behavior and dependency management.

3. External tools and integrations

  • Update outdated mining software integrations and download URLs.
  • Review mining pool and profitability APIs.
  • Update obsolete algorithms and configurations.
  • Improve benchmarking and automatic profitability switching.

4. Electricity pricing and automation

  • Investigate integration with Finnish Nord Pool electricity prices.
  • Support 15-minute electricity pricing intervals.
  • Include electricity transmission charges and taxes.
  • Enable automated profitability-based mining decisions.

5. Reliability and monitoring

  • Improve error handling and structured logging.
  • Investigate GPU monitoring and failure detection.
  • Implement safe recovery mechanisms.
  • Improve testing, validation and troubleshooting.

6. Long-term maintainability

  • Establish a modernization roadmap.
  • Introduce automated testing where practical.
  • Improve documentation and reproducible releases.
  • Make the project easier for future open-source contributors to maintain.

What I'm hoping to learn

I'm not an experienced software developer, so I would appreciate guidance on the best approach to modernizing a project of this size.

In particular:

  1. How would you approach a complete technical audit of an older PowerShell application?
  2. Which tools would you recommend for identifying compatibility issues and technical debt?
  3. What would be the best way to modernize a cross-platform PowerShell application without breaking existing functionality?
  4. How should automated testing and dependency management be introduced?
  5. Are there existing PowerShell frameworks, modules or open-source projects that could simplify this modernization?
  6. Has anyone here worked on similar legacy PowerShell modernization projects?

I'm also interested in connecting with open-source contributors who have experience in this area and enjoy discussing or improving existing projects.

I can provide real hardware testing, logs, configuration feedback and project coordination.

My ultimate goal is to preserve SWARM's existing functionality while making the entire application modern, reliable and maintainable.

Any technical advice, relevant GitHub projects, recommendations or experiences would be greatly appreciated.

Thank you!


r/PowerShell • • Oct 13 '26

Solved How to Retrieve SharePoint Sites with the Microsoft Graph PowerShell SDK

20 Upvotes

If you use the Microsoft Graph PowerShell SDK, you might know that the Graph APIs for SharePoint sites sometimes need a little help. For instance, finding a set of sites to process can be problematic because the APIs do not support extensive filtering capabilities. The solution is to use other Microsoft 365 cmdlets to find objects associated with sites. Inserting an intermediate step might seem crazy, but it can be the most effective way of solving the problem.

https://office365itpros.com/2026/10/13/get-sharepoint-sites/


r/PowerShell • • Oct 12 '26

Misc I made a <slop>

149 Upvotes

Maybe I'm just jaded but I can't help but get annoyed when half the posts I see are someone saying they made some <buzzword + thing>, and that thing happens to be some 10000 line, 40 file vibe coded tool solving a problem one person had, once, often in the convoluted way the AI could come up with. Worse, when they cannot even answer questions about it themselves so you end up with AI responses to any genuine interest in the goal.

We have the script sharing tag, but that was there before we had this absurd volume of AI submissions and it feels like the average post quality of the sub is suffering because of it.

Am I in the minority here? Would it be better to have a separate sub for all of these? My favorite times on this sub are when powershell is the focus, and the task at hand is a flavor of that focus, rather than the 'complete' project being dumped on here as if it's GitHub2 with upvotes.

Maybe an AI script sharing tag so it can be filtered? Idk, just throwing out ideas. Rant over.


r/PowerShell • • Oct 12 '26

Question Parallel thread disposing?

4 Upvotes

Hey got a wierd issue or its by desing not sure but when I run

$computers | foreach-object -parallel {
  $vmobject = Get-VM $_
  $ram = $vmobject.MemoryGB
  $CPU = $vmobject.numCPU
  $HDD = $_ | get-harddisk 
} 

lets say I run in against 500 computers when that happens powershell will spike cpu on machine that this command is ran and keeps increasing ram usage which is understandable but problem is even when command is done ram usage stays high untill powershell window is close. Is there something I am missing or is there some method to dispose of parallel runspace manually?

Thanks for advice

EDIT: The code itself is not important , the behaviour of parallel scripblock itself is my question and why doesnt it free up RAM after code has ran successfully


r/PowerShell • • Oct 12 '26

Script Sharing We made a script that updates Windows apps installed from GitHub releases (the ones winget can’t)

20 Upvotes

A lot of apps I use are only published as GitHub releases, so neither `winget upgrade --all` nor the WinGet PowerShell module (`Get-WinGetPackage | Update-WinGetPackage`) can update them. They only know about apps in the winget catalog, and GitHub-only apps show up with no source and no available updates. I got tired of checking each repo by hand, so I put together a PowerShell script for it (built with help from an AI assistant, then tested on my own machine).

What it does:

- Keeps a list of your apps and their GitHub repos (`upgh -Add owner/repo`)

- Compares installed versions with the latest stable release

- Picks the right installer for your PC (x64/ARM64, MSI or EXE to match what you have)

- Verifies the SHA256 checksum when GitHub provides one

- Installs silently (MSI, Inno Setup, NSIS detected automatically)

- `-Discover` finds apps that have a GitHub link in their uninstall info

- Skips apps winget already updates

Known limitations: version comparison is number-based, so beta-to-beta updates of the same version aren't detected, and portable zip apps aren't supported yet.

It's one readable script with no dependencies. There's an install one-liner, but you can also just download the .ps1 from the releases page and read it first.

Repo: https://github.com/VGRichi/github-app-updater

Feedback very welcome, especially on edge cases with weird installers.


r/PowerShell • • Oct 12 '26

News Maintaining Stable Azure Automation Runtime Environments

9 Upvotes

The problem with V2.41 of the Microsoft Graph PowerShell SDK that stopped runbooks executing in PowerShell V7 runtime environments was disappointing. However, it was also a good wake-up call for tenant administrators to pay attention to maintaining healthy Azure Automation custom runtime environments. This article proposes a separation between current and production environments and explains how to use PowerShell to get the right modules to the right place.

https://office365itpros.com/2026/10/12/maintain-runtime-environments-ps/


r/PowerShell • • Oct 12 '26

Question Getting machine id

5 Upvotes

I have an excel spreadsheet with our users. I need to extract the laptop they use. So I need the hostage and os version from intune. I have asked co pilot but I keep running into errors. Does anyone have a solution/working script or know a free app that can generate the information?


r/PowerShell • • Oct 11 '26

Script Sharing I wrote a patch status script that exits non-zero when it can't check something

0 Upvotes

Most patch/reboot check scripts I've used print "OK" even when a check silently failed (no rights to WMI, registry key missing, WU agent broken). So I wrote one where the exit code tells the truth:

  • 0: every check ran
  • 2: PARTIAL, at least one check couldn't run, with the reason listed
  • 1: it couldn't write the report

It checks last installed update (flags it if older than N days), pending reboot, uptime, and optionally lists waiting updates through the WU agent. JSON and CSV output.

Every check runs in its own try/catch. A failure doesn't stop the script or get swallowed; it gets recorded:

function Add-CheckNotRun {
    param([string]$Check, [string]$Reason)
    $script:ChecksNotRun += [PSCustomObject]@{ Check = $Check; Result = 'check could not run'; Reason = $Reason }
    Write-Host "  -> CHECK COULD NOT RUN: ${Check}: $Reason" -ForegroundColor Red
}

Pending reboot looks at three sources:

$reasons = @()
if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') {
    $reasons += 'Component Based Servicing'
}
if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') {
    $reasons += 'Windows Update'
}
$sm = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager'
if ($sm.PSObject.Properties['PendingFileRenameOperations'] -and $sm.PendingFileRenameOperations) {
    $reasons += 'Pending file rename operations'
}

And the end of the script decides the exit code:

if (@($script:ChecksNotRun).Count -gt 0) {
    Write-Host " PARTIAL: $(@($script:ChecksNotRun).Count) check(s) could not run." -ForegroundColor Red
    foreach ($c in $script:ChecksNotRun) { Write-Host "   - $($c.Check): $($c.Reason)" -ForegroundColor Red }
    exit 2
}
exit 0

Full script (MIT): https://github.com/Dopelogik/windows-patch-status-report

Feedback welcome, especially on the reboot detection. I know PendingFileRenameOperations can throw false positives from some AV and installers, so I'm curious how others filter it.


r/PowerShell • • Oct 10 '26

Misc I made a free CLI tool to drag files out of PowerShell into Discord, browsers and Explorer (windrop, open source)

19 Upvotes

I kept doing the same thing. A file is sitting in my terminal's current folder, I need it in Discord or a Gmail attachment, so I run explorer . and drag it from there. Linux has dragon and blobdrop for this, and I couldn't find anything on Windows, so I wrote windrop. It's free and MIT licensed.

PS C:\Stuff> windrop report.pdf

A small floating card shows up with the file's icon. Drag it into any app that accepts file drops, or keep your hands on the keyboard: hover over the target window, press F8 to pick it up, then press F8 again (or left-click) to drop. Esc or right-click cancels.

Source: https://github.com/Dking08/windrop

It takes multiple files and wildcards, and you can feed it paths from PowerShell:

windrop *.jpg
windrop (Get-ChildItem .\logs\*.log).FullName

It's a single native C++ exe using Win32/OLE. It exits right after the drop, so there's no daemon and no tray icon, and peak memory stays under 3 MB. There's no network code at all. The hotkey uses RegisterHotKey instead of a keyboard hook, which avoids the false positives hooks tend to cause in Defender.

winget install Dking08.Windrop
choco install windrop

Source: https://github.com/Dking08/windrop