r/PowerShell • • 20d ago

Script Sharing Made a simple Enigma Tui script.

0 Upvotes

Made a simple Enigma Tui script. Trying to practice using classes in PS. Still haven't added a plugboard but it can save and load so that is neat. Used AI to clean up some of the rotor logic and Tui math because my first attempt was 200% larger and math is fun. I also haven't really cleaned up any parameter validation or help documentation.

https://github.com/Ktufuathama/EnigmaShell


r/PowerShell • • 21d ago

Question PRoblems formatting SAS Drive on Win10x64

4 Upvotes

Context: SAS drive was given to me years ago but haven't gone to using it until now.

I'm trying to format a ST4000NM0023 on a Blueendless U35KS SAS/SATA Mobile Hard Disk Enclosure. I use a Dell G3 laptop to do all this.

Seagate tools are no help FYI. I don't want this drive go to waste!

I try to format with sg_format and this is what i get:

PS C:\windows>

>> sg_format --format --size=512 --fmtpinfo=0 --six -v pd2

Generic External 0157 peripheral_type: disk [0x0]

PROTECT=0

Unit serial number: 00000000000000000001

LU name: 570b3d5000000000

mode sense(6) cdb: [1a 00 01 00 fc 00]

mode sense(6):

Fixed format, current; Sense key: Vendor specific(9)

vendor specific ASC=80, ASCQ=92 (hex)

MODE SENSE (6) command: Some other sense error, try '-v' option for more information


r/PowerShell • • 22d ago

Script Sharing I made a theme picker for PowerShell and CMD with live previews

0 Upvotes

(rewritten due to strikes over artificial intelligence)
I use a spell checker when writing this text. Do I need to write that it is ai?

Hey dudes, hi everyone! I recently ran into an issue: I needed to change the colors in PowerShell. I tried doing it manually, but couldn't find any suitable solutions. I also found some cool programs for Linux, but they didn't work for this.
I found some good color palettes, but I couldn't find a solid solution specifically for PowerShell, so I adapted and improved one to suit my own needs. I hope it works for yours, too.

I built a small tool called StyleyShell to make changing colors in classic PowerShell and classic Windows console CMD easier (separate or together).

it can (or you with it also can be):

  • Browse many styles with live previews
  • Easy use a theme instantly with Enter
  • Set different themes for PowerShell and CMD
  • Update existing shortcuts and new console windows automatically
  • Restore your original colors anytime

No admin rights needed, I think it's pretty convenient.
AND source just TWO scripts u can analyze it easy

Github: https://github.com/kolandor/StyleyShell

Hope someone finds it useful! If you like it, I'd appreciate a ⭐ on Github, or as a cool dude. Feedback here welcome, we can talk

Please be understanding and, I ask, do not issue any strikes; this article might prove useful to others. To those from the future reading this post: please have a laugh at how absurd the world once was, and at the things people were forced to justify.


r/PowerShell • • 24d ago

Question Best book or YouTube to take my PS skills to the next level

33 Upvotes

Hello, I’m familiar with the basics and would like to learn more about PS. Any resources is appreciated


r/PowerShell • • 24d ago

Daily Post My first PowerShell module – I built a local NoSQL-style database on top of SQLite

8 Upvotes

Hey everyone!

I wanted to share my first PowerShell module, PSLocalBase, a local database engine I've been working on.

The idea came from wanting a simpler way to store, manage, and query structured data in PowerShell without constantly reading and writing large JSON files or dealing with long, complex SQL queries.

I ended up building a lightweight, NoSQL-style document database on top of Windows' native SQLite engine (winsqlite3.dll), using SQLite's built-in JSON functions to handle document storage, filtering, and queries.

The goal was to combine the simplicity of working with JSON documents and collections with SQLite's performance, reliability, and ACID transactions, without requiring external dependencies or a separate database server.

Some of the features I've implemented:

  • Local database storage using collections and JSON documents
  • Filtering, sorting, indexing, and advanced queries
  • Support for nested JSON objects and arrays
  • ACID transactions and persistent storage
  • Native PowerShell objects (PSCustomObject)
  • Compatibility with Windows PowerShell 5.1 and PowerShell 7+
  • No external dependencies on modern Windows systems
  • A WPF Playground for exploring and testing local databases

Here's a quick example:

$db = [PSLocalBase]::new("./mydata.db")

$db.collection("users").doc("user1").set(@{
    name   = "John"
    role   = "Admin"
    active = $true
})

$admins = $db.collection("users").
    where("role", "=", "Admin").get()

$db.close()

Everything runs locally, with no database server or external service required.

One of the most interesting parts of building this has been working directly with SQLite's native API through C# and P/Invoke, while keeping the interface simple for PowerShell users.

It's been a great learning experience, especially figuring out compatibility between Windows PowerShell 5.1 and PowerShell 7.

Since this is my first PowerShell module, I'd really appreciate feedback from the community, especially on the API design, performance, and potential use cases.

AI Disclosure: I used AI coding assistants throughout the development of PSLocalBase for implementation, debugging, testing, and documentation. I have over 12 years of PowerShell experience and directed the project's architecture, design, and technical decisions.

GitHub: https://github.com/cmartineztech/PSLocalBase

Thanks for checking it out!


r/PowerShell • • 25d ago

Script Sharing Made a modern WPF & PowerShell GUI toolkit for Windows/Gaming optimization (WinOptiKit v3.15) — looking for feedback on code structure

0 Upvotes

Hi everyone!

I've been working on a personal open-source project called **WinOptiKit** (v3.15). It's a lightweight Windows optimization and diagnostic utility built entirely using PowerShell and a custom modern dark-mode WPF GUI.

The main goal was to move away from messy scripts and create a clean, responsive interface that handles hardware specs reporting, dynamic app removal, startup management, and safe system maintenance (SFC/DISM wrappers) with proper elevated console handling (`-Verb RunAs`).

Here is what the tool handles under the hood:

- Custom XAML-based WPF dark theme layout with dynamic view switching.

- Hardware & Storage reporting via CIM instances.

- Dynamic AppX package scanner & uninstaller.

- Registry-based startup items manager.

- Safe execution wrappers for network flush and repair utilities.

You can check out the source code, XAML implementation, and structure on GitHub here:

👉 https://github.com/GabiHng/WinOptiKit

I'm mainly looking for constructive feedback on how I structured the WPF event handlers and PowerShell functions. Let me know what you think or if you spot any improvements!

Note: AI tools (like Gemini) were used to assist in structuring code, refactoring WPF XAML, and writing project documentation.


r/PowerShell • • 25d ago

Question How do you keep a PowerShell 7 profile useful without slowing down startup?

3 Upvotes

I’m setting up a PowerShell 7 environment on Windows and using Windows Terminal, Oh My Posh, and PSFzf.

I want a useful prompt and better command history, but I don’t want every new terminal tab to load a long list of modules.

The basic setup I’m considering looks like this:

oh-my-posh init pwsh | Invoke-Expression
Import-Module PSFzf

Would you put both directly in $PROFILE, or keep the profile minimal and load some tools only when needed?

Have you noticed a meaningful difference in startup time? I’d be interested in seeing how you organize your profiles in practice.


r/PowerShell • • 26d ago

Question What kind of work are people actually getting paid to do with PowerShell these days?

114 Upvotes

What are people actually getting paid to do with PowerShell these days?

I'm genuinely curious what people in this sub are doing with PowerShell professionally, particularly those who've found interesting or lucrative niches.

I'm fluent in PowerShell and love it for rapid prototyping, exploring unfamiliar APIs, discovering how services work, and building CLI tooling quickly. Its cross-platform capabilities are great, and the tooling, packaging, and module ecosystem are hard to beat compared to something like Python.

Historically, I've done a lot of operational automation: ticket ninjaing, reporting, and gluing enterprise systems together. But as I've moved toward higher-level engineering, I find myself reaching for other languages once projects grow beyond scripts.

AI makes generating decent-to-great sysadmin cmdlets almost trivial now. But when you start building platforms around those scripts, exposing them through APIs, abstracting execution for other users, or orchestrating workflows, I often find myself wondering why I didn't just build the whole thing in another language from the start.

I'm not saying PowerShell can't do those things. I'm curious where people are finding its real value in the market.

A few things I'd love to hear about:

  • Have you found a niche where deep PowerShell expertise translates into particularly good compensation or interesting work?
  • Are there industries, specialties, or types of automation where PowerShell expertise is especially valuable?
  • As you've progressed in your career, has PowerShell itself remained your main specialization, or has its value been more as part of a broader skill set?

I'm genuinely curious what people are getting paid to solve with PowerShell beyond the usual enterprise and small-business automation, reporting, and cleanup work. Not knocking that stuff; I've done plenty of it myself, hell if there is a massive market for it I'd love to hear that too. Just wondering what else is out there.


r/PowerShell • • 27d ago

Question Is using PowerShell on Linux a reasonable choice, or should I stick with Bash?

54 Upvotes

I'm currently using Windows and learning PowerShell with Learn PowerShell in a Month of Lunches, Fourth Edition. I'm about halfway through the book, and honestly, I'm really enjoying PowerShell so far. I find it much more intuitive and enjoyable to work with than Bash.

I'm considering using PowerShell on Linux as well, but I'm wondering how practical that would be.

  • How much of PowerShell's functionality is available on Linux compared to Windows?
  • Are there any significant limitations or compatibility issues?
  • Is PowerShell a good choice for everyday Linux administration and automation, or is Bash still the more practical option?
  • Would it make sense to focus on PowerShell, or should I invest time in learning Bash too?

I'd appreciate hearing from people who actually use PowerShell on Linux. Is it worth going down this path, or am I making things unnecessarily complicated?


r/PowerShell • • 27d ago

Script Sharing Syntax highlighting for PS7's null operators in VS Code

Thumbnail github.com
13 Upvotes

I saw a comment on here earlier today about VS Code's syntax highlighting for PowerShell not being able to properly color PowerShell 7's null operators: ??, ??=, ?., and ?[]. I had never noticed this before because I've never even tried to do that, but it turns out that there is not built-in tokenization for these operators despite a 7 year old issue on the topic. I'd never written a VS Code extension before and this seemed like a fairly easy first task, so I wrote a small MIT-licensed extension that allows you to add syntax highlighting to these operators. Source code on GitHub here, install it from the VS Marketplace here.

Was pretty fun to build, though I don't know how practical it'll be for me since I use pretty minimal syntax highlighting personally. But I got to learn how to build and publish a VS Code extension and I'm considering tackling that GitHub issue and getting this functionality into the official highlighter. No promises though lol


I did use an LLM to help me find documentation, fix some errors in my JSON, and remind me how to write regex lookbehinds. I didn't use any agent system to write or publish the extension or documentation for me.


r/PowerShell • • 26d ago

Question Annoying notifications in Windows PowerShell

1 Upvotes

Hello everyone, I hope you’re having a good day. I’ve been dealing with an issue for a while now: three types of notifications (from Qualcomm, HP, and Adobe) keep appearing—notifications that definitely don’t relate to anything I have installed on my laptop (an Asus). They use Windows PowerShell and present themselves as certificates claiming to represent the companies I mentioned. It’s quite frustrating; I get 2 or 3 windows popping up, all asking for the same thing. At one point, about 30 windows appeared at once, which caused my laptop to freeze up. Sometimes, a window will appear for just 2 or 3 seconds and then vanish. These are very bothersome, as they cause my video games to freeze whenever I try to play. Do you know how I can fix this? Thank you so much!

P.D: I would like to attach an image, but the platform doesn’t allow it; apologies for not being able to show you a visual example.


r/PowerShell • • 26d ago

AI Disclosure Cleaning up old user profiles on shared PCs: 5 gotchas I hit (orphaned SIDs can wipe a live user's folder)

0 Upvotes

AI disclosure: I used an AI assistant (Claude) to help review my script and tidy up this post. The testing and findings are from my own machines.

I look after a pool of loaner laptops and meeting-room PCs. Each machine ends up with dozens of stale profiles, and disks fill up fast. Here's what I learned automating the cleanup:

1. Don't just delete C:\Users\<name>. The registry entry under ProfileList stays behind, and the next login gets a temporary profile. Remove the profile properly through Win32_UserProfile.

2. LastUseTime lies. AV scans and services touch profiles and update it. I even saw it update on a profile whose account no longer exists.

3. Check Robocopy exit codes. 0-7 count as success, and 8 or above means failure. Verify the backup before you delete anything.

4. Skip loaded profiles, special accounts and your own admin account. Sounds obvious until a scheduled task runs while someone is logged in.

5. Two profile records can point at the same folder. On my test machine, a deleted-and-recreated account left an orphaned SID still pointing at C:\Users\<admin>, the same folder the logged-in admin was using. A naive "remove every unloaded profile" would have wiped the live admin's folder. Now I skip any record whose LocalPath is shared with a loaded profile:

$profiles    = Get-CimInstance Win32_UserProfile | Where-Object { -not $_.Special -and $_.LocalPath -like 'C:\Users\*' }
$loadedPaths = ($profiles | Where-Object Loaded).LocalPath

$profiles | Where-Object { -not $_.Loaded -and $_.LocalPath -notin $loadedPaths } |
    Remove-CimInstance -WhatIf

How do you handle this? GPO "delete profiles older than X days", DelProf2, or something custom?


r/PowerShell • • 26d ago

Script Sharing Ctrl+V in PowerShell types the path of a screenshot instead of pasting the image

0 Upvotes

A console cannot paste a picture. I wanted Win+Shift+S, then Ctrl+V, to type a file path the CLI can open.

The helper listens for Ctrl+V while Windows Terminal, PowerShell, or CMD is in front. It saves the clipboard image as a JPEG and types the path, for example C:\ToSnip\a1b2c3.jpg. The file stays on this PC. It is not uploaded. It is deleted after 5 minutes.

Install once:

irm https://tosnip.com/install.ps1 | iex

Read it before you run it. The source is MIT:

https://github.com/tana360/tosnip/blob/main/public/install.ps1

https://github.com/tana360/tosnip/blob/main/public/tosnip-paste.ps1

I built this. There is also a browser page at https://tosnip.com/web/ that makes a link instead of a local path. That link expires after 5 minutes too.


r/PowerShell • • 27d ago

Script Sharing PowerShell script for the Windows/app telemetry settings I could actually document

0 Upvotes

Been working on a PowerShell script for shutting off the Windows/app telemetry settings I could actually document.

Repo is here: https://github.com/quinnted/schizo

It keeps the rules in .psd1 files, journals the old state before changing anything, and has a separate restore script. Runs on 5.1 and 7.

I've tested the full apply/restore cycle in 26H2 Home/Pro VMs and now on my own 25H2 Home machine. 266 Pester tests currently pass on both PS versions.

plz test it and critique it https://github.com/quinnted/schizo/issues/1

Some of the code was written with Claude Code. I created all the architecture, and this wasn't oneshotted slop.


r/PowerShell • • 27d ago

Question Are Get-CimInstance and sc.exe query safe native Windows commands? Can they download malware or steal data?

0 Upvotes

Hi everyone, I'm feeling a bit anxious and need some reassurance.

I recently ran these two commands in PowerShell/CMD:

  • Get-CimInstance
  • sc.exe query ...

I didn't download anything from the internet or run any external scripts, but now I'm overthinking and worrying if these built-in commands could somehow connect to the internet, download a stealer, or compromise my Steam account.

Can these native Windows commands access the web or steal data on their own, or are they completely local and safe? I already ran a Malwarebytes scan and it came back clean, but my anxiety is acting up. Thanks for any clarification!

Used Ai because I am not very good at English


r/PowerShell • • 28d ago

Question InstallAnywhere logging with PS?

7 Upvotes

Hey All,

Does anyone have any experience with InstallAnywhere installers? Weve got some agent upgrades to do, and during our pilot group we ran into some strange failures. We tried to setup logging, but were pretty crunched for time so decided it was a next week problem.

The issue weve found is that InstallAnywhere doesnt advertise its processes the same way an MSI does, so you have to do some janky stuff.

Ive tried passing -RedirectStandardOutput and StandardError to a log file, but theyre either empty, or dont generate at all.

If anyone has any advice or any documentation they can point to thatd be awesome.

Thanks!


r/PowerShell • • 28d ago

AI Disclosure build-lab: one command from a Windows Server ISO to a lab AD domain, in Windows PowerShell 5.1 with no modules

12 Upvotes

I rebuild AD labs a lot, and I got tired of the lab build taking longer than the thing I actually wanted to test. So I wrote build-lab.

It takes a Windows Server 2025 ISO and gives you back a promoted domain controller, optional domain-joined member servers, and a lived-in directory (OUs, users, groups, an Enterprise CA, GPOs) staged to populate itself at your first Administrator logon. No GUI, no answer-file editing, no clicking Next. Nothing to install beyond what Microsoft and VMware already ship.

It's an orchestrator. It drives two sibling projects of mine, one that builds the VM in VMware Workstation and one that promotes the forest and populates the directory, and stitches them together over vmrun guest operations. The current version is 2.0. It has been on GitHub for a while, but this is the first time I've posted it here.

Quick start

$pw = ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force
.\build-lab.ps1 -IsoPath 'C:\ISOs\WS2025.iso' -AdminPassword $pw `
    -VmStoragePath 'C:\VMs' -StaticIpAddress '192.168.220.50' -DefaultGateway '192.168.220.2' `
    -MemberServerCount 2

That builds the DC, verifies the promotion, then builds SRVR-01 and SRVR-02 and joins them. (Leave -AdminPassword off the command line and PowerShell will prompt for it masked, which keeps it out of your history.) On the default VMware NAT network, your static IP has to land in .3 to .127 and the gateway is always .2. The script refuses anything outside that range and pings every address before using it. A DC takes about 25 minutes on a reasonably quick host, and each member adds roughly 12 to 15.

Already have a DC from an earlier run? -AddMemberServers adds members to it without touching the DC. -MoveMemberServers files them into OU=Servers once directory population has created it.

The fun part

Promotion reboots the guest, and the reboot tears down the vmrun guest-operations channel mid-call. A blocking call hung across that reboot and never came back, so the promotion is launched fire-and-forget with -noWait. That means there is no exit code to read at all.

My first version decided promotion had worked when ntds.dit appeared on disk, waited a bit, and called it good. Typical v1.0 logic. A database file on disk is a long way from a working DC. Now it checks three things from the outside, in order. ntds.dit has to appear. The guest has to reboot. Then the rebooted guest has to report itself as a DC in the domain you configured. Miss any of them and the run fails and tells you which check it missed.

The reboot check is the bit I'd like opinions on. Just before launching anything that should reboot, build-lab creates HKLM\SOFTWARE\BuildLabBootMarker in the guest as a volatile key. Volatile keys live only in memory and are never written to disk, so if the key is gone, the guest restarted. That holds however long the guest has been up, which mattered here. A freshly built member reboots for its domain join barely a minute after first boot, and anything uptime-based gets confused.

A few other things that came out of live runs.

  • Every vmrun call has a host-side time limit, and a call that overruns is killed, so one stuck call can't hold the run open forever
  • vmrun output is read as UTF-8 whatever the console code page is
  • Commands run in the guest report back through a small result file, so a failure comes back with the guest's own error text
  • The password is scrubbed from anything vmrun returns before it hits the logs
  • Logs from the orchestrator, the VM builder and the guest all land in one folder, and key events go to the Application event log if you want a SIEM to see them

Known limitations and lab-grade trades

  • You have to log in once as Administrator to start directory population. That's deliberate. Running it unattended would mean storing a domain admin password under a startup task. I'm still thinking about this one.
  • vmrun takes the guest password on the command line, so it's visible in the host's process list while guest operations run. Don't reuse a real credential.
  • It's Windows PowerShell 5.1 only, enforced with #Requires. Write-EventLog is the right API there and deprecated in 7. I'll probably port to PowerShell 7 eventually, but this is where I' most comfortable today.
  • Tested on a Windows 11 host with VMware Workstation 26H1 and Windows Server 2025 Standard Evaluation media. Other editions and VL media are unverified, because the unattended install matches on exact edition name strings.

Links

All three need to sit next to each other on disk. Feedback is welcome. I'm sure I made some interesting choices without even thinking about it. If you have a better way to tell from the host side that a guest has restarted, I'd like to hear it.

AI disclosure

I used AI to help write some of the code. The design and architecture are all mine, including any questionable choices, and it was built up over many reviews and live runs, not generated as one shot slop.


r/PowerShell • • 28d ago

Solved Converting PowerShell Scripts from Search-UnifiedAuditLog

9 Upvotes

Investigating the work necessary to convert PowerShell scripts based on the Search-UnifiedAuditLog cmdlet to use the AuditLogQuery Graph API shows that it’s not easy. Running audit jobs is a multi-stage process rather than running a simple cmdlet. Parameter values are now passed in a request body or different named parameters, and the properties output in the AuditData payload use a different format. This is definitely not a drop-in exercise, so it’s time to get ready by finding scripts that need to be converted.

https://office365itpros.com/2026/10/27/auditlogquery-conversion/


r/PowerShell • • 29d ago

Question Retiring Powershell ISE

44 Upvotes

I really don't like VS Code for Powershell but PS 5.1 and PS ISE is starting to get long in the tooth. Anybody have tips, tricks, custom configs, or other recommendations?

Funny enough I really like VS code for everything else except PowerShell.


r/PowerShell • • 29d ago

Question Beginner looking for help in a sea of Regex

10 Upvotes

So I discovered how useful Powershell is about 3 weeks ago and have been playing with it and tweaking my PC with all manner of useless changes. I have reached something that has left me rather stumped even after a fair bit of Googling (AI results disclosure?) and several hundred changes of my 'script'. Posting here is probably like whacking a mole with a warhead but hey why not!

I have been attempting to change a subtitle file with several thousands of lines of text, they all follow the following pattern:

Dialogue: 0,0:00:12.92,0:00:17.34,Default,,0000,0000,0000,,{\pos(540*,420)}Hello world!\N*

I would like to add 140 to all of the first numbers after "{\pos(" (e.g 540 becomes 680.)

Dialogue: 0,0:00:12.92,0:00:17.34,Default,,0000,0000,0000,,{\pos(680*,420)}Hello world!\N*

I have been attempting to do this by loading the .ass text file in (this'll be part of a batch file so I am calling Powershell from CMD), then using the -replace function as follows:

powershell -Command "((Get-Content -path <path to sub.ass> -Raw) -replace '\{\\pos\(\d+,','\{\pos\(${140 + \d+},') | Set-Content -Path <path to sub.ass>"

However this results in the following results for all lines of dialogue:

Dialogue: 0,0:00:12.92,0:00:17.34,Default,,0000,0000,0000,,\{\pos\(,420)}Hello world!\N

This is one of the more promising results where {140 + \d+} simply vanished. Without the $ in front of {140 + \d+} Powershell will simply repeat whatever code I put into into it back at me in place of \d+ like so: {\pos\({140 + \d+},420)}

I suspect that because I am attempting to isolate a number by using the surrounding punctuation the program is reading \d+ as a string rather than an integer.

TLDR: I am attempting to increase the value of the same integer on every line of text by 140 using \d+. \d+ could be any number from 0 to 1540. Not using \d+ is fine but I have no idea what other options are available.

Pointing me in the direction of what I should learn to get this to work could also be great as this is actually a pretty enjoyable program - I just think I went a little too deep too fast with this one.


r/PowerShell • • Oct 25 '26

News PowerShell ISE

4 Upvotes

After a month of refinement, I have a new version of my App in the MS Store.
I received some feedback and a lot suggestions, plus more than a few bug issues.

It is now more like a true PowerShell console than the emulator it was before. There should not be any more unrecognized PS commands. It is still a WIP but it is definitely close to a Daily Driver for running scripts and debugging.

I actually prefer it now than opening a PWSH console.

The debugging sub-system has been hardened and more responsive. I am adding output options to make automated script running easier. The save as EXE works, I am going to be adding .NET level options to the executable next.

Once again. If anyone would like to give it a try and provide feedback, it is most welcome.

It can be found by searching for PS7ScriptDesk in the MS store.

Regards,

-Ron


r/PowerShell • • Oct 22 '26

Information Struggling to learn Microsoft Graph PowerShell for IAM-how did you guys learn it

66 Upvotes

Hi everyone,

I’m currently learning PowerShell with Microsoft Graph because my goal is to become a Junior IAM / Microsoft Entra ID Administrator.
I’ve been practising in my own Microsoft Entra ID lab, and so far I’ve managed to learn some basics, such as:
1)Connecting to Microsoft Graph using PowerShell
2)Creating, updating and deleting users
3)Creating and managing security groups
4)Adding and removing users from groups
5)Retrieving and filtering users
6)Working with variables, arrays, hashtables and loops

However, I’m starting to struggle and slowly losing interest, not because I don’t want to learn, but because sometimes I feel like I’m just memorising commands without fully understanding how to use them in real-world situations.
I can follow tutorials and complete exercises, but when I try to do something on my own, I sometimes get stuck and don’t know which commands to use or where to start.
My goal isn’t just to memorise PowerShell commands. I want to understand how an IAM administrator actually uses Microsoft Graph PowerShell in their daily job.

For those of you who learned PowerShell, especially for Microsoft Entra ID or IAM:
How did you learn PowerShell and become confident using it?
Did you learn the general PowerShell fundamentals first, or did you learn while working with Microsoft Graph?
What practical projects or exercises helped you the most?
How do you remember commands and know which ones to use when solving a problem?
What would you recommend to someone preparing for their first Junior IAM Administrator role?
I’m willing to put in the time and effort. I just feel like I need a better learning approach that will help me understand what I’m doing instead of simply following instructions.
Any advice, learning resources or personal experiences would be greatly appreciated.
Thanks in advance!


r/PowerShell • • Oct 22 '26

Question Exchange (Online) Powershell auto-forward and auto-reply

9 Upvotes

Ok, I need some help with Powershell.

Part of our company got sold. This weekend, the migration is set to go through. All users that are part of this transfer will login into the new owners IT infrastructure and their 365 tenant starting next monday. The mailbox contents will be synced and for the next few weeks all incoming e-mail needs to be auto-forwarded to the user's new mailbox in the other tenant. And a auto-reply will be sent to the sender informing them of the upcoming discontinuation of the old e-mail address.

So, all e-mail coming in to 'olduser' needs to be forwarded to 'newuser' and newuser is in another tenant. To prevent double e-mail, 'olduser' should not be seeing the e-mail in their inbox.

Currently this is what I have, being run from Exchange Management shell connected to Exchange Online

$Users = Import-Csv "c:\temp\usermailboxentest.csv" -delimiter ";"

foreach ($User in $Users) {

    Set-Mailbox -Identity $User.adresold `
        -ForwardingSmtpAddress $User.adresnew `
        -DeliverToMailboxAndForward $false
}

And then, I run this

$CsvPath = "C:\Temp\mailboxes.csv"

$StartTime = Get-Date
$EndTime   = [datetime]::new(2026, 12, 30, 23, 59, 59)

$Results = foreach ($CsvUser in Import-Csv -Path $CsvPath) {

    $MailboxAddress = $CsvUser.MailboxAddress.Trim()

    try {
        Write-Host "Processing: $MailboxAddress" -ForegroundColor Cyan

        # Retrieve the mailbox
        $Mailbox = Get-Mailbox -Identity $MailboxAddress -ErrorAction Stop

        # Determine the configured forwarding address
        if ($Mailbox.ForwardingSmtpAddress) {

            # Forwarding to an SMTP address
            $ForwardAddress = $Mailbox.ForwardingSmtpAddress.ToString() `
                -replace '(?i)^smtp:', ''
        }
        elseif ($Mailbox.ForwardingAddress) {

            # Forwarding to an internal Exchange recipient
            $ForwardRecipient = Get-Recipient `
                -Identity $Mailbox.ForwardingAddress `
                -ErrorAction Stop

            $ForwardAddress = $ForwardRecipient.PrimarySmtpAddress.ToString()
        }
        else {
            throw "No mailbox-level forwarding address is configured."
        }

        Write-Host "Forwarding address: $ForwardAddress" -ForegroundColor Green

        # Create the HTML automatic-reply message
        $AutoReplyMessage = @"
<p><strong>Dear Sender,</strong></p>

<p>
This email address has been discontinued etc. etc etc. and a variable for $ForwardAddress pointing the user to whatever the new e-mail address is.
</p>
"@

        # Configure automatic replies for internal and external senders
        Set-MailboxAutoReplyConfiguration `
            -Identity $MailboxAddress `
            -AutoReplyState Scheduled `
            -StartTime $StartTime `
            -EndTime $EndTime `
            -InternalMessage $AutoReplyMessage `
            -ExternalMessage $AutoReplyMessage `
            -ExternalAudience All `
            -ErrorAction Stop

        Write-Host "Automatic reply configured successfully." -ForegroundColor Green

        [PSCustomObject]@{
            MailboxAddress = $MailboxAddress
            ForwardAddress = $ForwardAddress
            Status         = "Success"
            Error          = ""
        }
    }
    catch {
        Write-Warning "Failed for $MailboxAddress`: $($_.Exception.Message)"

        [PSCustomObject]@{
            MailboxAddress = $MailboxAddress
            ForwardAddress = $null
            Status         = "Failed"
            Error          = $_.Exception.Message
        }
    }
}

# Show the results
$Results | Format-Table -AutoSize

# Export a processing report
$Results | Export-Csv `
    -Path "C:\Temp\AutoReplyResults.csv" `
    -NoTypeInformation `
    -Encoding UTF8

Now this is what happens, when I set DeliverToMailboxAndForward to $true, the autoreply works but the original e-mail is put into the old mailbox which I don't want to happen because in the new tenant users will end up with double e-mail because of the sync of mailbox contents.

When I set that to $false however, the autoreply doesn't work because 'olduser' mailbox is never 'hit'

Also, this will be for about 170 mailboxes, both user and shared boxes.


r/PowerShell • • Oct 22 '26

Question Automated QuickBooks Updates (Not Upgrades)

2 Upvotes

OK So this is going to sound crazy (kinda?) and I understand it is likely not an option based on what I know of the underlying application after nearly 10 years of working with it. I am hoping that someone in the wider world of Reddit has already come across a solution and is willing to share.

We (the company I work for) support a tax prep/accounting firm that has 2 RDS servers that are used to access accountant copies of QuickBooks Company Files. They use a variety of application versions from 2021 to 2024 (Accountant, Premier, and Enterprise distributions). During tax season, they are incredibly busy and as a result, have asked us to schedule application updates every Thursday evening along with updating their Thompson Reuters applications.

Personally, I don't like taking a couple hours out of my day when I'm on call to work after 7PM to update QuickBooks since they use all the versions depending on the client they are prepping taxes for. I am also in charge of making manual tasks automated wherever possible.

So, here's what I am looking to accomplish:

  1. Scripted updates of installed QuickBooks versions without the need to open each distro and check for updates. (automated updates are already enabled, still doesn't actually install the updates until we go in and tell it to do them which sucks hard).
  2. The script needs to be capable of recursively identifying the installed versions, exporting a response of all versions found and then go through and check for updates, install any updates found, and log any errors. It should also be capable of stopping and restarting any and all QuickBooks related services as needed and restart the server following the completion of the scripted tasks.
  3. This is for updates NOT upgrades - there is a difference.
  4. I would like to avoid using third party software to accomplish this - we already have ImmyBot but that platform appears to confuse the "upgrade" and "update" functions.

Here are the things I am already well aware of so don't comment if you feel the need to point out the below facts:

  1. QuickBooks does NOT come with known, publicly available scripted/command line options for this specific function.
  2. Non-current QuickBooks versions are not something I care about - if Intuit still pushes updates to the application, I don't care if it isn't a "current" distro version. (We are working with the last 5 years or so of distros, nothing older than that and those are still getting updates so far as I am aware.)
  3. QuickBooks online is not an option for this client's clients - please don't suggest that as an alternative, I've already been there done that.
  4. The servers are RDS servers - yes they have issues but these are not the worst of the servers we currently support.
  5. I would REALLY love to not have to take the code from a company that has a paywall to access because honestly that just feels gross. This is also why I am not taking the code I have access to via ImmyBot and running it through CoPilot or another AI platform to remove the references to another company's probably proprietary code. I don't want to steal anything from a company that has put effort into the solution.

Please let me know if you have come across this issue and/or have found a solution that you are willing to share with me via github or other sharing platform. If you are not authorized to share this info, please don't.

I would also appreciate any scripts be coded in either a batch file or (preferably) a powershell script. :) Thanks in advance!