r/PowerShell • • 14h ago

News Microsoft Graph PowerShell SDK V2.41.2

7 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 • • 13h ago

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 • • 10h ago

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

1 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 • • 14h ago

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.