![]() |
Articles
| About | Links2024
Deleting items from Recoverable ItemsPoshRSJob v PowerShell Core Parallel shootout Integrated App deployment issues Mailbox appears as Mail User in O365 Graph Audit Log returns 403 Mails not getting deleted from O365 Quarantine Hash versus Generic List speed test Decommission On-Prem Exchange Automate User Creation via PowerShell and Excel List Azure Virtual Machines via PowerShell Moving from PowerShell 5.1 to Core Canyon Roadlite 6 2024 Postfix Receive and Forward Installing and configuring PHPMailer Postfix routing by filtering Advanced Postfix configuration Installing Exchange 2019 in Azure Landing Zone Upgrading PHP on Windows Adding a Postfix server for relay to O365 O365 Integrated Apps troubleshooting Domino and O365 Co-existence Delegate Control in AD App mail relay via HVE Setting up Mail Relay with HVE Getting BIMI certified Orbea Occam SL H30 Installing FreeSat and Saorview Changing broadband provider Replacing a DIN timer on fuseboard Outlook Desktop Notifications stop working Outlook folders keep moving sort order Teams report uploading to SharePoint with Runbooks Teams PowerShell module can't run CS cmd as App 2023
Cannot map new Shared Mailboxes in O365Renewing an Exchange 2016 certificate Connect to Compliance PowerShell behind a Proxy Sensitivity Label not shown in Outlook Client Room Finder Error in Outlook Teams not showing Rooms Teams unable to open file Unable to review quarantined mails for shared mailbox Set Locale for various Apps Delegate Sent Items placed into external Tenant Overview of Microsoft Support cases When centralized mail sends via O365 Cleaning up your Windows DNS server Set OneDrive for Business Locale O365 Migration Tips Reporting on successful Azure logons IIS Mapi Queue full with NetScaler Secure Office365 reports with a certificate Using Graph to send emails with inline images Visualizing Graph data with Google Charts Keeping a log of NetScaler AlwaysON connections |
PoshRSJob v PowerShell Core Parallel shootout
21-Sep-24
When I first got into writing more advanced PowerShell scripts for checking computers on my network, I ran everything consecutively. I soon found out this was a pretty bad way of doing things, a 4 hour script would typically get stuck on a remote WMI command that had no timeout. Out of necessity, I looked into runspaces, which basically spawns a load of PowerShell processes to check computers in parallel. The results were brilliant, a 4-hour script went down to minutes, and as you can timeout the jobs, the script would no longer get stuck. There were a few trade-offs, CPU and memory usage can be very high, and there can be memory leaks and processes that don't get removed after the runspace completes. But, overall using runspaces is a much better way to scan a network. While Runspaces in PowerShell 5.1 are native, they are not easily set-up, so after some trial and error I settled on the excellent PS Module from Boe Prox, PoshRSJob. The module allows for easy creation of runspaces and has settings for throttle and timeout. After recently moving all my scripts to PowerShell Core (7.1) I wanted to try out the native foreach parallel option, but how does it compare? Test 1: ping 2,000 computers in parallel, throttle set to 200. PoshRSJob: 18 seconds Foreach Parallel: 19 seconds In this test, both handled memory usage well, with the Pwsh.exe hitting a max of 400MB. Test 2: ping 2,000 computers in parallel, then test the SMB port. PoshRSJob: 60 seconds Foreach Parallel: failed As soon as the scriptblock gets a bit more complicated we see major problems with ForEach Parallel. The memory usage exceeded 4.5GB and was still rising when I killed the process. No results were returned when the script finished, though I'm not exactly sure why. In comparison the PoshRSJob worked as expected with only a slight increase in memory. For now, I will continue to use PoshRSJob. Generally when I'm checking all computers on the network I'm looking for a setting in the registry or via CIM, not just to simply ping them. |