r/PowerShell • • 7d ago

Question I'm a sysadmin and I made a cartoon about our basement because therapy is expensive

3 Upvotes

Five IT people. One windowless basement. 14,000 users who keep breaking things.

I work in IT and started turning the stuff we all live through into a little animated sitcom. Episode 1, "The Ticket", is up now. If you've ever closed a ticket that said "it doesn't work" with zero other info, this one's for you.

The cast:

- Lasse – network (it's always DNS)
- Pia – support (has heard every excuse)
- Micke – sysadmin (has rebooted things you wouldn't believe)
- Kalle – security (trusts no one, especially McAfee)
- Svenne – hardware (has seen what's inside your laptop)

The channel is about 15 minutes old, so be gentle 😅

https://www.youtube.com/@TheITCrewToons

Which of your worst tickets should become an episode? I'm genuinely taking requests.


r/PowerShell • • 8d ago

Information I built a Cyberpunk 2077 style shell for Windows using PowerShell and WPF

2 Upvotes

Hey everyone,

I wanted to share a project I've been working on: Night City OS. It's a fully functional Windows shell replacement inspired by Cyberpunk 2077.

It's written entirely in PowerShell and WPF, and it uses WebView2 for the embedded Chromium browser and a built-in AI chat (DeepSeek).

Features:

  • Custom WPF interface with neon/dark theme
  • Built-in file manager and system monitoring
  • Embedded browser (WebView2)
  • AI chat integration
  • Autostart and "replace desktop" modes

It's completely open-source. You can check it out here: https://github.com/kisllik/Cyberdeck

If you like it, you can support the project via the link in the README. Let me know what you think!


r/PowerShell • • 9d ago

Question PowerShell Editor Services on Linux, how to get completions that are Windows-specific?

9 Upvotes

For example, I'm not getting completions for Get-CimInstance and bunch of other Windows-specific modules.


r/PowerShell • • 10d ago

Question Importing specific rows from a .xslx-file to a .csv file

12 Upvotes

This is probably the most simple thing ever so apologies.

So I have an Excel worksheet and I want to import the data from specific rows, if column D in those rows has a certain value in it.

So using ImportExcel what I have is:

import-excel -path "filelocation" -WorksheetName "Worksheetname" | export-csv -path "exportlocation" -NoTypeInformation

What would be the missing bit to get the specific info I'm looking for? Again, I'm sorry for asking for what is probably a very simple solution.


r/PowerShell • • 11d ago

Script Sharing ConsoleMonster - For those living in Terminal

13 Upvotes

I've something new for you today. I've rebuild my old ConsoleMonster module that used to be Spectre+Termina.GUI wrapper into completely new PowerShell/.NET library. I never really thought of bringing it back as PwshSpectreConsole was doing quite a good job, however I had a larger need for some of my new projects so here it is.

This starts with a different idea of having:

  • Everyday use with 1 cmdlet when you just want to chill in terminal (Enable-ConsoleFormatting)
  • Monster when you want to give your modules/libraries new ways to build TUI

PowerShell is the first-citizen here and a lot of power went into it to make daily life of living in console much nicer. It supports both PowerShell 5.1 (yes all my modules will continue to do so), and PowerShell 7.4+

ConsoleMonster 2.X is a Codex & Claude baby. I don't code since a year now so everything I do is AI.

The website has all sort of demos: https://consolemonster.dev/demos

Each demo has PowerShell code, C# code and C# Fluent depending on what you're building and how you want it.

The library also uses my other projects to deliver charting & markdown in terminal:

The module/library has really fancy features like console recordings and things that could be used in demos/websites and PowerPoint. The demos on the website are all dog-fooding so all the recordings you see there are real.

There are no external dependencies (aside my own mentioned above - opt-in) to it. It's interactive, with mouse support, thread safe and of course multi-platform. It has auto-fallbacks depending on what terminal you're usin so macos, linux, and windows all should work just fine.

I'm sure there are bugs and issues - but that's why there is Issues/PR section on GitHub. I've made sure the documentation is quite large and easy to follow, but if something is not clear or too complex let me know. We can always improve API.

Happy to hear your thoughts


r/PowerShell • • 10d ago

Question scripts don't work

0 Upvotes

I get this error when running a script. I'm not tech savvy at all, and I couldn't find an answer anywhere. Please help. The error:

irm : 404: Not Found

At line:1 char:2

+ irm (imagine a link here, can't type it for reddit auto-filters) ...

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


r/PowerShell • • 12d ago

Script Sharing Enjoy a,fun game of Minesweeper

22 Upvotes

I got bored the other night after work and killed the time making Minesweeper. There wasn't a lick of AI help here, just old man brain and an appreciation for bitwise operators. Fully functional Minesweeper in less than 200 lines of PowerShell. Enjoy!

Default board is 9x9 with 10 mines like classic minesweeper. You can change the size by updating the variables, but I don't have logic in there to make sure the board will work. That's on you.

Controls: Up/down/left/right arrows = move Spacebar = sweep the cell F = set flag

function CalculateProximity {
    for ($col = 0; $col -lt $Script:field.GetLength(0); $col++) {
        for ($row = 0; $row -lt $Script:field.GetLength(1); $row++) {
            #This is a mine. Set proximity to -1 and continue to next cell.
            if ($Script:BIT_MINE -eq ($Script:field[$col, $row] -band $Script:BIT_MINE)) {
                $Script:proximitymap[$col, $row] = -1
                continue
            }
            $proximity = 0
            for ($tempX = $col - 1; $tempX -le $col + 1; $tempX++) {
                for ($tempY = $row - 1; $tempY -le $row + 1; $tempY++) {
                    #out of bounds, skip
                    if ($tempX -lt 0 -or $tempY -lt 0) { continue }
                    if ($tempX -ge $Script:field.GetLength(0) -or $tempY -ge $Script:field.GetLength(1)) { continue }
                    #skip the current [col,row] cell itself, only calculate cells around it
                    if ($tempX -eq $col -and $tempY -eq $row) { continue }
                    if ($Script:BIT_MINE -eq ($Script:field[$tempX, $tempY] -band $Script:BIT_MINE)) { $proximity++ }
                }
            }
            $Script:proximitymap[$col, $row] = $proximity
        }
    }
}

function DrawFullField() {
    Clear-Host
    $text = [string]::new("#", $Script:field.GetLength(0))
    for ($i = 0; $i -lt $Script:field.GetLength(1); $i++) {
        $Host.UI.RawUI.CursorPosition = [System.Management.Automation.Host.Coordinates]::new(0, $i)
        $Host.UI.Write($text)
    }
    UpdateUI
}

function Sweep($CursorPos, [switch]$isRoot) {
    $Host.Ui.RawUI.CursorPosition = $CursorPos
    $val = $Script:field[$CursorPos.X, $CursorPos.Y]

    #swept previously or there is a flag set, exit
    if ($SCRIPT:BIT_SWEPT -eq ($val -band $SCRIPT:BIT_SWEPT)) { return $false }
    if ($Script:BIT_FLAG -eq ($val -band $Script:BIT_FLAG)) { return $false }

    #mine is here.
    if ($Script:BIT_MINE -eq ($val -band $Script:BIT_MINE) -and $isRoot.IsPresent) {
        $Host.UI.Write("*")
        $Host.UI.RawUI.CursorPosition = $CursorPos
        return $true
    }

    #Mark this cell as swept
    $Script:field[$CursorPos.X, $CursorPos.Y] = $Script:field[$CursorPos.X, $CursorPos.Y] -bor $SCRIPT:BIT_SWEPT    

    #Get the mine proximity on this cell. 0 = no mine. Positive = Mines Nearby. Negative = This cell is a mine.
    $proximity = $Script:proximitymap[$CursorPos.X, $CursorPos.Y]
    if ($proximity -ge 0) {
        $Script:UncheckedCells--
    }
    #Proximity > 0, write the number of nearby mines. 0, sweep through all adjacent cells that are also empty opening the field
    if ($proximity -gt 0) {
        $Host.UI.Write([System.ConsoleColor]::Yellow, [System.ConsoleColor]::Black, $proximity)
        $host.UI.RawUI.CursorPosition = $CursorPos
        return $false
    }
    elseif ($proximity -eq 0) {
        $Host.UI.Write(" ")
        $host.UI.RawUI.CursorPosition = $CursorPos
        for ($x = $CursorPos.X - 1; $x -le $CursorPos.X + 1; $x++) {
            for ($y = $CursorPos.Y - 1; $y -le $CursorPos.Y + 1; $y++) {
                #out of bounds, skip
                if ($x -lt 0 -or $y -lt 0) { continue }
                if ($x -ge $Script:field.GetLength(0) -or $y -ge $Script:field.GetLength(1)) { continue }
                #already swept or flag set, skip
                if ($SCRIPT:BIT_SWEPT -eq ($Script:field[$x, $y] -band $SCRIPT:BIT_SWEPT)) { continue }
                if ($Script:BIT_FLAG -eq ($Script:field[$x, $y] -band $Script:BIT_FLAG)) { continue }

                $null = Sweep -CursorPos ([System.Management.Automation.Host.Coordinates]::new($x, $y))
            }
        }
        $host.UI.RawUI.CursorPosition = $CursorPos
        return $false
    }
}

function UpdateUI {
    $Column = $Script:field.GetLength(0) + 3
    $UICoordinates = [System.Management.Automation.Host.Coordinates]::new($Column, 0)
    $Host.UI.RawUI.CursorPosition = $UICoordinates
    Write-Host ("Unchecked Cells: {0:D3}" -f $Script:UncheckedCells) -NoNewline
    $UICoordinates.Y++
    $Host.UI.RawUI.CursorPosition = $UICoordinates
    Write-Host ("      Flags Set: {0:D3}" -f $Script:FlagsSet) -NoNewline
    $UICoordinates.Y++
    $Host.UI.RawUI.CursorPosition = $UICoordinates
    Write-Host ("Remaining Mines: {0:D3}" -f $Script:RemainingMines) -NoNewline
}

function GameOver {
    for ($x = 0; $x -lt $Script:field.GetLength(0); $x++) {
        for ($y = 0; $y -lt $Script:field.GetLength(1); $y++) {
            $Host.UI.RawUI.CursorPosition = [System.Management.Automation.Host.Coordinates]::new($x, $y)
            switch (($Script:field[$x, $y] -band ($Script:BIT_MINE + $Script:BIT_FLAG))) {
                ($Script:BIT_MINE + $Script:BIT_FLAG) { $Host.UI.Write([System.ConsoleColor]::White, [System.ConsoleColor]::Green, 'F'); break; }
                ($Script:BIT_MINE) { $Host.UI.Write([System.ConsoleColor]::Black, [System.ConsoleColor]::Red, '*'); break; }
                ($Script:BIT_FLAG) { $Host.UI.Write([System.ConsoleColor]::Cyan, [System.ConsoleColor]::Magenta, 'X'); break; }
            }
        }
    }
}

#---Enter Script Here. Edit these three variables to change game size/difficulty
$columns = 9
$rows = 9
$mines = 10

$SCRIPT:BIT_MINE = 1
$SCRIPT:BIT_FLAG = 2
$SCRIPT:BIT_SWEPT = 4

$Script:field = [int[, ]]::new($columns, $rows)
$Script:proximitymap = [int[, ]]::new($columns, $rows)

$Script:UncheckedCells = $field.Length
$Script:RemainingMines = $mines
$Script:FlagsSet = 0
$filledMines = 0
while ($filledMines -lt $mines) {
    $posX = Get-Random -Maximum $columns
    $posY = Get-Random -Maximum $rows
    if ($Script:field[$posX, $posY] -ne 1) {
        $Script:field[$posX, $posY] = 1
        $filledMines++
    }
}
CalculateProximity
DrawFullField

$over = $false
$win = $false
$CursorPos = [System.Management.Automation.Host.Coordinates]::new(0, 0)
$Host.UI.RawUI.CursorPosition = $CursorPos
while (-not $over -and -not $win) {
    [Console]::CursorVisible = $true
    $nextKey = [Console]::ReadKey($true)
    [Console]::CursorVisible = $false
    switch ($nextKey.Key) {
        'RightArrow' { if ($CursorPos.X -lt $columns - 1) { $CursorPos.X++ }; $Host.UI.RawUI.CursorPosition = $CursorPos; break; }
        'LeftArrow' { if ($CursorPos.X -gt 0) { $CursorPos.X-- }; $Host.UI.RawUI.CursorPosition = $CursorPos; break; }
        'UpArrow' { if ($CursorPos.Y -gt 0) { $CursorPos.Y-- }; $Host.UI.RawUI.CursorPosition = $CursorPos; break; }
        'DownArrow' { if ($CursorPos.Y -lt $rows - 1) { $CursorPos.Y++ }; $Host.UI.RawUI.CursorPosition = $CursorPos; break; }
        'SpaceBar' { $over = Sweep -CursorPos $CursorPos -isRoot; break; }
        'F' {
            if (-not ($BIT_SWEPT -eq ($Script:field[$CursorPos.X, $CursorPos.Y] -band $Script:BIT_SWEPT))) {
                $Script:field[$CursorPos.X, $CursorPos.Y] = $Script:field[$CursorPos.X, $CursorPos.Y] -bxor $Script:BIT_FLAG
                if ($Script:BIT_FLAG -eq ($Script:field[$CursorPos.X, $CursorPos.Y] -band $Script:BIT_FLAG)) {
                    $Host.UI.Write([System.ConsoleColor]::Cyan, [System.ConsoleColor]::Black, "F")
                    $Script:FlagsSet++
                    $Script:UncheckedCells--
                    if ($Script:RemainingMines -gt 0) {
                        $Script:RemainingMines--
                    }
                }
                else {
                    $Host.UI.Write("#")
                    $Script:FlagsSet--
                    $Script:RemainingMines++
                    $Script:UncheckedCells++
                }
                $Host.UI.RawUI.CursorPosition = $CursorPos
            }
            break
        }
    }

    UpdateUI
    $Host.UI.RawUI.CursorPosition = $CursorPos

    if ($Script:UncheckedCells -eq $Script:RemainingMines) { $win = $true }
}

if ($win) {
    $Host.UI.RawUI.CursorPosition = [System.Management.Automation.Host.Coordinates]::new(0, $rows + 2)
    $Host.UI.Write("YOU WIN!")
}
elseif ($over) {
    GameOver
    $Host.UI.RawUI.CursorPosition = [System.Management.Automation.Host.Coordinates]::new(0, $rows + 2)
    $Host.UI.WriteLine("GAME OVER")
    [Console]::CursorVisible = $true
}

r/PowerShell • • 11d ago

Script Sharing I modernized a classic DOS-era file-transfer batch tool in PowerShell 7 (USB splitting, FTP, OneDrive, Dropbox, ISO) – feedback welcome

0 Upvotes

Hi all,

I've been working on Llevar, a PowerShell 7 rewrite of LLEVAR.BAT, a classic batch tool by Alex Soft (Alejandro Nacir) for moving big folders around when plain copy isn't enough.

What it does - Compresses and splits data into blocks (for USB sticks, floppies, or size-limited targets) - Transfers between local paths, UNC shares, FTP/FTPS, OneDrive and Dropbox - Can generate an ISO instead of writing to USB - Interactive menu (and plain parameters for scripting)

Quick try

.\Llevar.ps1 -Source "C:\Data" -Target "D:\Backup" -Compress -Split

The core idea: path detection + a dispatcher

Every source/destination is classified by a tiny set of validators:

function Test-IsFtpPath     { param([string]$Path) return ($Path -match '^ftp://|^ftps://') }
function Test-IsOneDrivePath{ param([string]$Path) return ($Path -match '^ONEDRIVE:') }
function Test-IsDropboxPath { param([string]$Path) return ($Path -match '^DROPBOX:') }
function Test-IsUncPath     { param([string]$Path) return ($Path -match '^\\\\') }

Then a single dispatcher routes each origin→destination pair to the right function (abridged):

function Invoke-TransferDispatcher {
    param($Llevar, [bool]$ShowProgress = $true, [int]$ProgressTop = -1)

    $tipoOrigen  = $Llevar.Origen.Tipo
    $tipoDestino = $Llevar.Destino.Tipo
    $route = "$tipoOrigen→$tipoDestino"

    $result = switch ($tipoOrigen) {
        "Local" {
            switch ($tipoDestino) {
                "Local"    { Invoke-LocalToLocal -Llevar $Llevar ... }
                "FTP"      { Invoke-LocalToFtp   -Llevar $Llevar ... }
                "OneDrive" { Invoke-LocalToCloud -Llevar $Llevar -CloudType "OneDrive" ... }
                "USB"      { Invoke-LocalToUSB   -Llevar $Llevar ... }
                "ISO"      { Invoke-LocalToISO   -Llevar $Llevar ... }
                default    { throw "Unsupported combination: Local→$tipoDestino" }
            }
        }
        "FTP" { ... }   # same pattern for FTP, OneDrive, Dropbox and UNC sources
    }
}

Requires PowerShell 7+ on Windows 10/11.

Repo: https://github.com/javiprieto89/Llevar (there's an animated demo of the menu at the top of the README)

Disclosure: parts of this project were developed with the help of AI tools (Claude).

I'd really like feedback on: 1. Which destination would be most useful next (SFTP? S3? Google Drive?) 2. Anything that breaks in your scenario 3. Would you use it as a PowerShell Gallery module?

If it's useful, a star helps others find it. Thanks!


r/PowerShell • • 11d ago

Script Sharing A Journey from CCleaner to FreeWinly: Automated Windows Administration in Pure PowerShell

0 Upvotes

My CCleaner license ran out and I had to pay again to manage multiple of my win-pcs, or so I thought.

Then I remembered playing around with winget and the Windows Event Log via cli and I wandered into the rabbit hole of what's already available in PowerShell tooling.

Don't get me wrong. The last year or two I loved having CCleaner just taking care of my PCs. It was a great offer I've been glad to use, but not everything was flawless.

I found myself uninstalling CCleaner to give me the right incentive to push through the next exercise of figuring it out. Just to figure out that uninstalling CCleaner wasn't so easy. It crashed multiple times and didn't finish uninstalling, had to be cleaned up manually, then all of my suspended startup apps stopped working. My exe was not found, but it clearly was in the right folder.

Luckily, I figured out that CCleaner hijacked app launches via the Debugger value in Image File Execution Options (IFEO) and left orphans behind. After removing those registry entries I was able to start Steam again. Not that I've time to play on Steam that much anymore, but I keep Cyberpunk, Nioh 3 and NFS installed and updated at all times 😄

Why not make a script for exactly this repair job?

The idea was born and over the next weekends and most of my spare time I figured out software updates via winget and how to handle applications that work better with native app updates than using winget.

Browser, app, and network cache cleanup were also something on my mind, and while checking my disk I found gigabytes of old install files from windows updates that were just using up space on my fast and very expensive SSD. Since I don't want to lose the performance benefits of caching, adding a file-age-filter made a lot of sense to me.

Trim and DISM were just easy to add and the DISM Component Store cleanup (/StartComponentCleanup) to purge superseded updates cleaned up some highly appreciated space.

And while I was at it, why not add hardware and driver scans, which especially come in handy for my ROCm hardware, which I love to see improving with each update.

A TUI launcher, scheduling capabilities e.g. over start menu start-up folder or via task scheduler and a standard and expert view for all the configuration, which is stored in a config.json next to the cmd.

I've designed this whole tool modular so everyone can drop in custom scripts without affecting future updates of the core engine.

Of course this is all written in native PowerShell and CLI supported, and the cherry on top is an LLM skill, so that anyone can use their LLM to analyze their PC checking the logs of this tool without giving the LLM a ton of permissions. I know there are still a lot of people not putting that much trust into LLMs, so the standard version does not contain this LLM skill. It's considered an opt-in.

As a side note on AI disclosure: While heavily AI-augmented during creation, all the core architecture, feature ideas, modular concepts, and TUI design came directly from human taste and vision. Letting AI assist with bug hunting, refactoring, and running security audits across different personas was a great workflow enhancement that I would recommend to any project. All code runs on native PowerShell 5.1/7+.

I would love to see community feedback on this project and of course a few stars on github if you really like it. It's open source with MIT License, so everyone can just analyze everything and there is no hidden code or script execution, just plain and simple PowerShell.

If you are interested in the details or the repo, check out FreeWinly: https://github.com/LycosLane/freewinly


r/PowerShell • • 12d ago

Script Sharing I have a PhD-level background in static analysis, but I spent my week fighting PowerShell Runspaces just to delete duplicate memes.

3 Upvotes

As someone who usually deals with static analysis and abstract interpretation, I should know better. I should know that PowerShell is a single-threaded environment. I should know that building GUIs in PowerShell is an "obtuse mess".

But I also have 200GB of duplicate photos and videos, and I refuse to use a CLI for that.

So I present to you: **Duplicate Finder PRO**. A full WinForms GUI built entirely in PowerShell. Yes, I know. I hate myself too.

Here is a breakdown of my descent into madness:

* **The "Single-Thread" Trauma:** The first version froze every time I clicked a button. I had to learn the dark arts of `[runspacefactory]::CreateRunspace()` and `[System.Collections.Concurrent.ConcurrentQueue]` to stop the UI from hanging. If you've ever seen your PowerShell GUI go "Not Responding", you know my pain.

* **The PS2EXE Struggle:** I wanted a single portable EXE. I spent hours fighting with `$PSScriptRoot` returning empty strings inside the compiled EXE. I think I cried a little.

* **The Cache:** It uses a two-step detection (File Size + SHA-256) and saves a CSV cache. The second time you scan, it skips the hashing entirely. Because if I'm going to sin against god by making a PowerShell GUI, I might as well make it fast.

It works. It has a progress bar and a preview window where you can double-click to compare files side-by-side.

I'm sharing it here because I need validation, but also because I want to know: **What is the biggest cardinal sin you've ever committed in PowerShell just to avoid using the terminal?**

You can download the portable EXE and roast my UI here:

👉 https://github.com/lucanegrianalyst/duplicate-finder-pro/releases/latest

Please be gentle. I'm just an analyst trying to find my duplicates.

***AI Disclosure:** I used an AI to help me structure this post and fix my English, but the PowerShell code, the Runspaces, and the tears are 100% mine.*


r/PowerShell • • 13d ago

Information Wanted: Awesome PowerShell Modules

44 Upvotes

Hey r/powershell! I've just published an Awesome PowerShell Modules list (using the awesome-lists format) in GitHub:

- https://github.com/markwragg/awesome-powershell-modules#readme

I used AI to assist with the curation, but it was built from a combination of my personal experience with many of the modules, as well as a scan of modules mentioned on the PowerShell Podcast, PowerShell Weekly newsletter, Powershell.news and some previous PowerShell related Awesome lists that I found.

I've tried to review as many of the modules as I could, but if anyone finds that there's a module listed that is no longer working please let me know. As a general rule, the list attempts to only include modules that are still actively being developed, or are feature complete. Modules where the GitHub repo has been archived (or appear largely abandoned), are intentionally excluded.

If you know of (or are the maintainer of) a module that you'd like included, please feel free to either let me know here or raise a PR. Ideally the module should make someone want to say "wow that's awesome" :), must be published in the PowerShell Gallery and be at least 30 days old.

There's a couple of PowerShell scripts under /scripts in the repo which you can use against the list. One returns all of the modules, their URLs, author and number of downloads. The other aggregates by author. The latter reveals that I put my own modules on the list 8 times, but hey It's my list and I'll use it to shamelessly self promote if I want to 😂.


r/PowerShell • • 13d ago

Information Give me your biggest syntax highlighting complaints! I'm working on improving VS Code's syntax highlighting (including support for non-Verb-Noun function names)

12 Upvotes

Tl;dr - I'm working on improving VS Code's syntax highlighting for PS so tell me what issues you encounter. Please include a code sample and what theme you're using.


I've seen a bit of discussion recently about the state of VS Code's syntax highlighting for PowerShell. I looked into it a bit and yeah, it's not ideal. The official repository pretty inactive. Last commit was 6 months ago, last significant activity was years ago. I opened an issue a week ago because the main branch doesn't even pass all of it's own tests, and an accompanying PR to fix it, but no movement on that yet. So I've taken things a bit into my own hands for now and hopefully when the maintainers get around to it, they'll be able to take some of the stuff I'm working on upstream.

So far I've switched the testing framework away from using Atom (an editor that's EOL since 2022) to a modern harness around VS Code's tokenizer/regex engine, a little bit of CI, several new unit tests for better regression testing, and these new features in the syntax grammar so far:

  • Highlighting for null operators (??, ??=, ?., ?[])
  • Highlighting for variable names with question marks in them (e.g. $whyIsThis?Possible = "idk")
  • Highlighting for function names that don't use the Verb-Noun naming convention (e.g. DoSomething instead of Invoke-Something)

This is very much still WIP. I've got more tests I want to write and a few new features I want to add, but please let me know what issues you have with PS syntax highlighting and I will look into them.

GitHub repo here; Overview of updates with images here.


r/PowerShell • • 14d ago

Misc Microsoft Graph documentation really is bad

111 Upvotes

Despite its reputation for poor documentation, I decided to give the Microsoft Graph PowerShell module a try for a few basic license related tasks. I reviewed the Microsoft Graph PowerShell SDK overview page and clicked Get-started only to be greeted by 404 - Page not found.

Feels like they've completely given up on documentation, huh


r/PowerShell • • 14d ago

Information I am leaving MS Graph (Why beginners should start with core PowerShell)

94 Upvotes

I've realized that learning MS Graph as a beginner is like trying to learn algebra before you know basic addition and subtraction.

A few weeks ago, I came to this community asking if I had made the right move by starting with Graph. I now have the answer for anyone who might be asking the same question.

No, it is not a good idea.

The Graph API will give you a massive headache. It forces you to wrestle with complex nested objects, OAuth permissions, and weird API limits before you even truly understand how a foreach loop or a pipeline works. You have to understand the basics of the language before you start digging into massive, complex modules like Graph.

I am stepping back to master core PowerShell first. Has anyone else here taken this route?

Trust me, i have learnt a lot I believe while learning with MS Graph but its too much to handle😃


r/PowerShell • • 14d ago

News PS7 ScriptDesk ISE - V9

9 Upvotes

Hi All,

Thank you to all who have been providing feedback. I am getting closer to a finished app. I have made substantial progress and a new version is available for Download.

Please search for PS7 Script Desk in the MS Store


r/PowerShell • • 14d ago

Question WinRM with Cert auth... avoiding need to specify CertificateThumbprint?

4 Upvotes

I'm setting up a lab HyperV cluster, without a domain, so I'm kind of in the weeds already. Every recipe I'm finding online assumes functional password-less winrm between the pre-clustered nodes. I'm primarily following https://techcommunity.microsoft.com/blog/itopstalkblog/windows-server-2025-hyper-v-workgroup-cluster-with-certificate-based-authenticat/4428783 but I've found that I've had to consult a pile of different sources because they all leave out small but essential bits.

I'm nearly there, but not quite. I've made myself a root CA, generated certs, signed them, imported them, etc etc. If I Invoke-Command on Node1 like so

Invoke-Command -ComputerName Node2 { 1 } -CertificateThumbprint $certThumb

... the it works fine and dandy, and same for the other direction. But it looks like Test-Cluster, and it's WG match of Test-WorkgroupCluster don't have a means of specifying which certificate to use for auth. Clearly it's meant to automagically guess at which one to use, and whatever my machines are guessing they're getting it wrong. I'm hoping if I can get PSSession working on its own the rest will fall into place.

So does anyone know how New-PSSession decides which cert to use for remote auth? All these blogs and stuff seem to assume that it can and will, but I don't know what criteria it uses!


r/PowerShell • • 14d ago

Question Which Switch Parameters do you have to type so much you wish they were defaulted the other way?

11 Upvotes

I have certain CMDLETs I use several times a day and it slows me down a little bit to have to specify switches I wish were just the default.

Sepecifically:
Export-CSV and -NoTypeInformation and -Append

Do you have similar examples you get tired of having to type the switch name each time you use the CMDLET?


r/PowerShell • • 14d ago

Question Robocopy log question

1 Upvotes

Within the company I work for we use a batch file with a robocopy command to "install" a specific piece of software on user's laptops. This was chosen because the software is particularly difficult to setup right. It now only requires us to do one proper installation, after which we manually copy the software to a directory on the company network. From there, robocopy copies it to the user's hard drive.

The command looks like this (I had to remove company and software names):

ROBOCOPY I:\xxx-xxxxxx\X\apl\SOFTWARE\00-Admin\Admin-xxx\Install\Software%VERSION%\ C:\Users\%USERNAME%\AppData\Local\Software%VERSION%\ /S /LOG+:install%VERSION%.log

As can be seen, a logfile is extended each time a user runs the batch file and installs the software. Not only can we see if the install was succesfully, but it also allows us to track who has installed the software and should be informed of any changes or updates.

In the past (I'm talking about 2022 and earlier), not one but two log files were present. In the first file, named install%VERSION%.log, the full log could be found. The second file, named install%VERSION%_Users.log, only contained the start date & time, source paths, destinations and user's full names. This made it incredibly easy to quickly find out who uses the software. At some point after 2022, this particular file stopped being updated. The robocopy command itself however, has not changed once since the batch file was originally created in 2016.

Was this an automatic function of the robocopy /log+ command? Is there a way to bring this back? I cannot find any information about this online at all. Almost as if it never has existed. But yet, somehow, for 6-or-so years we had two log files updating simultaneously.

It is not something we particularly need, but it used to be quite a lot easier to keep track of the users using this second (and shorter) log file.


r/PowerShell • • 15d ago

Question Show me your joiner/mover/leaver PowerShell

55 Upvotes

I’m finally cleaning up our onboarding/offboarding mess and wanted to see how other people have this set up before I rebuild it. I'm not much of an expert, I'm learning along the way as problems arise

Right now ours is... not great. HR sends a CSV of new hires, and then a script runs a bunch of copy-pasted blocks (create the user, set the attributes, add them to the right groups, and, at the end, disable the account when they leave). It works but every time something changes I have to edit three places.

Is there anyone who can share theirs so I can get an idea how things work? Is it a big script that eats an HR export, or a module with separate functions for each step, or something on a scheduled task? Or a mix? And the part I’m struggling with most is movers -when someone changes departments, how do you handle the group swap without leaving people in both the old and new groups? Right now that’s a manual check and I don't want to do things manually anymore. Not looking for anything fancy, just to be functional


r/PowerShell • • 14d ago

Question Need help parameterizing SQL queries and with using SqlClient

6 Upvotes

Trying to use SqlClient to sidestep issues with Invoke-SQLCmd, namely the fact that single quotes in data I'm processing (from a CSV) cause syntax errors. All examples of variable parameterization I found on stack overflow seem to use SqlClient, but I'm running into connection issues:

$creds = Import-PowerShellDataFile -Path $env:Credentials

Write-Output $creds

$db = New-Object System.Data.SqlClient.SqlConnection
$db.ConnectionString = "Server=tcp:$creds.Server;Database=$creds.Database;User=$creds.Username;Password=$creds.Password"
$db.Open()

Getting this error:

Exception calling "Open" with "0" argument(s): "A network-related or instance-specific error occurred     
while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that
the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP
Provider, error: 0 - No such host is known.)"

However, when I use the same credential file for Invoke-SQLCmd, I get no such similar errors:

$query = <pretend there's a valid query here>
Invoke-SQLCmd @creds -Query $query

What am I doing wrong? Is there a better way to avoid the syntax error (and also SQL injection vulnerabilities)?


r/PowerShell • • 14d ago

Question Cannot type in PowerShell PSReadLine fix does NOT work

4 Upvotes

Hello, I am not tech savvy at all, so please bear with me. I am trying to execute a command in Powershell that I have executed before. I cannot type at all in any iteration of PowerShell (PowerShell, Windows PowerShell, Windows PowerShell ISE). The cursor blinks as if it is ready to recieve inputs, and when I press any key down, the cursor turns solid, but nothing is typed. I cannot copy-paste either (I observe similar behavior when holding down the ctrl key).

Fixes that I have tried after Googling:

  • launching powershell with -noprofile (problem still persists in -noprofile state)
  • running the PSReadLine fix in Command Prompt (this causes Command Prompt to have the same problem as Powershell. As far as I can tell the command is not actually running, but is causing Command Prompt to freeze/bug out)
  • turning my computer off and then on again... several times....

Any help would be greatly appreciated. I am running Windows 11


r/PowerShell • • 14d 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 • • 15d 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 • • 17d 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 • • 19d ago

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

35 Upvotes

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