r/PowerShell • • 4d ago

Script Sharing What have you done with PowerShell this month?

13 Upvotes

A sticked post for the community to share their projects throughout the month.

Make sure to post a link to the code!


r/PowerShell • • Oct 01 '26

Script Sharing What have you done with PowerShell this month?

23 Upvotes

A sticked post for the community to share their projects throughout the month.

Make sure to post a link to the code!


r/PowerShell • • 1d ago

Question No MSI for latest version of PowerShell

81 Upvotes

I know they announced this ages ago that they were no longer going to release an MSI version of PowerShell. But it seems there is no executable as well? There are only zipped and msix versions now.

This is super annoying. I have a bunch of windows 2019 and 2022 servers that don't support the MS store so I can't install the msix bundle. Yes I know there are some work arounds for server 2022 to get the msix to work but no way I'm going to be doing that on prod.

And the zip just extracts the files but doesn't install them.

I'm missing something here? BTW, I could very well be, it has been a long week.

What is everyone else doing?


r/PowerShell • • 1h ago

Script Sharing Sharing www.getshell.pw/sh script

0 Upvotes

TLDR

Here is getshell.pw a small site that hosts POSIX complaint shell script (getshell.pw/sh pun intended) that enables simple powershell installation on different linux machines (glibc and musl)

Like this:

curl -fsSL https://getshell.pw/sh | sh

backstory

Hi everyone,

I'm myself an avid powershell user on linux and on windows and since long ago I had a set of scripts that setups and configures my development environment dotfiles in a crossplatform way.

While working on different linux distros I always thought that powershell is underrated and linux people not giving it a chance for no reason :) (I'm biased I know)

During work on my setup scripts, I always had a powershell bootstrap problem - how to install it on a new linux machine? In the beginning I had various shell scripts - one for alpine, one for ubuntu and one for arch. It was cumbersome to manage, and I thought that maybe I can host some kind of a bootstrap script that will fit most of the linux systems without sudo's and people will be able to try powershell without many troubles.

I always lacked time to do it and lately used AI to build POSIX complaint script (will run on sh, bash, fish and other ones) that will bootstrap powershell into ~/pwsh/VERSION/pwshbinary folder with symlink to ~/pwsh/current

Give it a try, I hope this small project will help people try powershell and start using more often on linux machines :)

repo


r/PowerShell • • 1d ago

News Exchange Online Powershell Unusable in British Columbia.

19 Upvotes

The new BC timezone isn't in the 2024 International Components for Unicode library that ships with Windows, so it gets translated as Etc/Unknown.

Encountering an unknown timezone causes the Chakra Javascript Interpreter from 2015's version of Microsoft Edge to unload the Intl library from JavaScript.

And as soon as they fail to load a function from the Intl library (like when you log in and they process the timestamp and user timezone settings) M365 login windows give a "Something went wrong" error with no way to back out or see more information.

Since Exchange Online PowerShell uses Chakra for its login windows (both IPPS and EXO), that means nobody using BC time can use it in powershell 5.1 (Powershell 7 offers a -device option that can be used as a workaround, permitting you to load the authentication in a proper browser).

The fun part is that this is a JavaScript error in an embedded browser with no troubleshooting hooks or logging options. This means that the error isn't logged anywhere and can't be logged even if you're snooping on web traffic and running Procmon. Microsoft says you logged in just fine, powershell says you cancelled the login. You can only learn what happened by attaching some sort of debugger to the process or reading its memory.


r/PowerShell • • 3d ago

News Microsoft Graph PowerShell SDK V2.42 and EXO PowerShell Clash (again)

40 Upvotes

Microsoft Graph #PowerShell SDK V2.42 (released today) and Exchange Online PowerShell 3.11.1 have yet another module clash. This is getting boring. Microsoft really needs to wake up and make sure that its #Microsoft365 modules work together flawlessly. Details at https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3576


r/PowerShell • • 3d ago

Question New To Powershell

6 Upvotes

Hi, I'm new to powershell and reddit. I'm an old school developer that had written some popular utilities in the early 2000's in VB 6.0. I haven't developed anything in over 10 years. I recently started dabbling in PowerShell. I really like it. I've written about 8 or 9 scripts. I would like others opinions on them but I don't want to break any rules. Any insight on what to do guys? I think they are pretty great. They are all MIT licensed.


r/PowerShell • • 2d ago

Script Sharing im kinda new to powershell but i alredy love it

0 Upvotes

now wen my family enoyes me im gona hit them with: [console]::beep(690,30000) how can you not love such powerfull tool


r/PowerShell • • 4d ago

News Advent of PowerShell

60 Upvotes

Looking for a fun way to sharpen your PowerShell skills this December?

Advent of PowerShell is live!

🎄 24 daily PowerShell coding challenges

Whether you're just getting started with PowerShell or have been automating everything in sight for years, it's a great excuse to write some PowerShell, challenge yourself and explore different approaches to solving problems.

Get started here: https://2026.powershell.au/

Would love to see how everyone approaches the challenges. Feel free to share your experiences, feedback and creative solutions (with spoiler tags, of course!).

Disclosure: AI did help me create the website and text above. I can only include 1 tag, and I felt News was more appropriate


r/PowerShell • • 4d ago

News PS7 ScriptDesk (Custom PS7 ISE) — Development Update

6 Upvotes

I had ChatGPT help write the update. -Ron

Thank you to everyone who has been testing PS7 ScriptDesk, reporting issues, suggesting improvements, and providing valuable feedback. Your participation continues to help shape the application into a more capable, reliable, and user-friendly PowerShell 7 development environment.

What's New

Expanded PowerShell Code Snippets

The code snippet system has been significantly enhanced to incorporate Microsoft's official PowerShell snippet library.

  • 51 Microsoft PowerShell snippets and 21 ScriptDesk snippets, providing 72 built-in code templates.
  • Microsoft-first snippet integration with IntelliSense.
  • A new Insert Snippet option in the editor's right-click context menu.
  • Ctrl+J opens a searchable snippet library.
  • Search by snippet name, keyword, description, or category.
  • Filter snippets by category and source.
  • Preview PowerShell code before inserting it into your script.
  • Interactive, linked placeholders with keyboard navigation for rapid code customization.
  • Full integration with the existing ScriptDesk editor and theme system.

These enhancements make writing PowerShell scripts faster and easier while reducing repetitive coding.

Native PowerShell Command Builder

PS7 ScriptDesk now provides direct access to PowerShell's built-in graphical Command Builder through the Tools → Command Builder menu.

Two operating modes are available:

  • Interactive: Launches the Command Builder within your existing PowerShell session.
  • Distinct: Launches the Command Builder independently, allowing you to continue working in ScriptDesk.

The Command Builder allows users to explore available PowerShell commands, view their parameters, configure arguments, and construct properly formatted PowerShell commands through a graphical interface.

Rather than developing a proprietary replacement, ScriptDesk leverages Microsoft's native PowerShell functionality.

Continued Quality and Performance Improvements

Development continues to focus on:

  • Application stability and reliability.
  • Improved editor responsiveness.
  • Consistent and intuitive user interfaces.
  • Compatibility with established PowerShell development workflows.
  • Reuse of proven native technologies.
  • Maintaining a streamlined application without unnecessary software bloat.

What's Coming Next

The next planned enhancement is a comprehensive Snippet Manager and Creator, which will allow users to:

  • Create and maintain their own reusable PowerShell snippets.
  • Create snippets directly from selected editor code.
  • Customize existing snippets.
  • Organize snippets into categories, subcategories, and favorites.
  • Assign custom IntelliSense expansion keywords.
  • Import and export snippets compatible with Visual Studio Code and Windows PowerShell ISE.

Your Feedback Matters

Whether you are a PowerShell beginner, an experienced developer, a system administrator, or a longtime Windows PowerShell ISE user, your feedback is welcome.

Please continue to report bugs, request features, and share suggestions through the PS7 ScriptDesk GitHub repository:

https://github.com/RonB56/PS7-ScriptDesk

The goal remains to provide a modern, powerful, intuitive, and free integrated scripting environment designed specifically for PowerShell 7.

Thank you for your continued support and for being part of the PS7 ScriptDesk community!


r/PowerShell • • 3d ago

Misc Converted my PS Script to PS7

0 Upvotes

I know there are plenty of AI haters out there but I wanted to get ahead of the switch from PS 5.1 to PS 7 but it's been too long since I did any PS coding and I didn't feel the urge to get back up to speed. So, as an alternative, I fed my script that's contains code for a GUI input form into Gemini AI and within seconds it converted my script to PS7. Needless to say I was impressed that Gemini AI could convert PS scripts.


r/PowerShell • • 5d ago

Question How to exclude showing Get-Variable output for -Scope 0

13 Upvotes

I want to call myfunc function that runs the statement:

$value = ( Get-Variable -Name $var_name -Valueonly -Scope Script )

That will show the GM's output for the instance of the variable named in the myfunc's$var_name parameter, a string, that was in scope when the myfunc was called, no mater where or what scope the call was made in, but myfunc must ignore a local variable with the same name in favor of the same named variable outside of the myfunc . If there are multiple variables with the same name outside of myfunc, then only the one that is in scope, that is not eclipsed, is shown (as I think already happens).

myfunc is currently defined at the script file's script scope, so it be callable from anywhere in the script where it's defined or 'included', but if the calling statement is nested deeply in a chain of functions or 'included' scripts, will the$var_name parameter need to be 'typed' as [ref] to make this work?

Google suggests the following to eliminate myfunc variables, their version lists:

-Scope 0,1,2,Global,Script

But, I don't want to keep changing this list when I call myfunc from deeper scopes, so I changed the scope option to:

-Scope 0,1,2,3,4,5,6,7,8,9,Global,Script

I don't expect to need that, but without a All, Allscope, or notLocal option setting, or a way to dynamically determine the scope of the variable from its name or the name from its value. I pretty much need to include all reasonable scopes that I might one day need.

Here is the rest of that suggested line of code:

    $value = (
      Get-Variable `
        -Name $var_name `
        -Valueonly `
        -Scope '0,1,2,3,4,5,6,7,8,9,Global,Script' `
        -ErrorAction SilentlyContinue
      |
      Where-Object { $_.Scope -ne 0 }
    )

I'll check the last error auto-variable and output my own error message if there is an error.

When is a string not a string? I don't know, but PowerShell gives me this error when I try running the suggested line of code, above, after fixing the missing quotes that Copilot left off:

Line |
 200 |      Get-Variable `
     |      ~~~~~~~~~~~~~~
     | Cannot process argument because the value of parameter "Scope" is not valid. Valid values are "Global", "Local", or "Script", or a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent). Change the value of the "Scope" parameter and run the operation again.

In another thread, someone said AI code was 'slop', here is an example!

Thank you.


r/PowerShell • • 7d ago

Script Sharing I built a free WinForms GUI to see which mailboxes a user can access in Exchange Online (reverse lookup + grant/copy/remove)

60 Upvotes

Hi r/PowerShell,

one thing that always annoyed me as an M365 admin: the Exchange Admin Center only shows permissions per mailbox. There is no quick way to answer "Which mailboxes, calendars and room mailboxes does user X have access to?" – especially during onboarding/offboarding or when someone changes departments.

So I built MailboxAccess, a PowerShell/WinForms tool on top of the EXO v3 module.

What it does

  • Reverse lookup: enter a user → see all mailboxes they have FullAccess, SendAs, SendOnBehalf or folder/calendar permissions on
  • Room mailboxes: includes calendar permissions and booking delegates
  • Grant / copy / remove: add rights, copy all rights from one user to another (onboarding), or remove everything (offboarding)
  • Mailbox view: who has access to a specific mailbox
  • Tenant report: overview of all non-default permissions
  • Fast: results come from a local cache (seconds instead of minutes). The cache can be refreshed incrementally via the Unified Audit Log (delta update), so you don't have to rebuild it every time
  • Runs locally, no server, no cloud service, data stays in `%LOCALAPPDATA%`

Requirements

  • Windows PowerShell 5.1
  • `ExchangeOnlineManagement` module
  • Exchange admin rights (plus "View-Only Audit Logs" for the delta update)

Download

GitHub: https://github.com/RazeAttack/MailboxExchangeGUI

You can run the `.ps1` directly or use the EXE from the releases (built via GitHub Actions, SHA256 checksums included). The EXE is a ps2exe build and not code-signed yet (code signing via SignPath is in progress), so Defender/SmartScreen may complain – if you prefer, just run the script.

MIT licensed, free. Feedback, issues and PRs are very welcome – especially on performance in larger tenants (I've tested it with ~350 mailboxes).

Screenshots are in the README (tenant data redacted).


r/PowerShell • • 7d ago

Script Sharing I built a free read-only scanner to find VBScript dependencies before Windows disables it — feedback welcome

0 Upvotes
With VBScript getting disabled by default in 2026–2027, I wanted a quick way to see what would break on a machine: .vbs/.wsf/.hta files, scheduled tasks, Run keys, startup folders, GPO logon scripts and services calling wscript/cscript.

So I wrote VBS Readiness. It's read-only (changes nothing) and produces an HTML report of every dependency it finds, with a risk score. It also checks Outlook add-ins and VBA macros for the new Outlook.

Free download: https://github.com/lamtoueqali-eng/vbs-readiness

Disclosure: I'm the author, and I also offer paid conversions to PowerShell, but the scanner is free and works on its own.

What other VBScript hiding spots should I detect? Happy to add them.

r/PowerShell • • 6d ago

Question Practicar comandos Linux/Windows

0 Upvotes

¿Conocéis alguna forma de practicar/estudiar comandos de Linux y Windows?

Me refiero tanto a comandos de Linux, como a comandos orientados a la administración de Linux (chmod, tar, fsck, tcpdump...), y de Windows/PowerShell (net, ipconfig /flushdns, sfc /scannow...).

Alguna vez he visto alguna web con algún juego en el que, mediante comandos, avanzabas por el juego.

No sé si algo así es buena idea o si mejor lo descarto.

En ocasiones utilizo maquinas virtuales con Linux y/o Windows, pero se me hace un poco pesado practicarlo, de ahí que busque otras opciones.


r/PowerShell • • 8d ago

Question Do Constants give advantages?

22 Upvotes

So, we all know we can make a Constant by using New-Variable -Name 'ImTryingIguess" -Value 'whatever' -Option Constant
(or using Set-Variable the same way)

Question is: does using a constant instead of a regular variable give any advantage?
Like, smaller memory footprint or something?

So far, from what I managed to understand, its only effect is keeping people from altering the variable, which can be very useful with large scripts manned by multiple people, as one might decide to recycle a variable name that should otherwise stay untouched.

I personally prefix any "constant" name with CONST_(i.e.: $CONST_TitleTemplate) which, so far, has been working well, but I was wondering if I was missing some magic powershell shenanigan.


r/PowerShell • • 7d ago

Question powershell

0 Upvotes

não consigo acessar, diz que nao tenho permissão adequada pra acessar, alguem poderia me ajudar


r/PowerShell • • 8d ago

Question How to inject a tab before each output line of Get-Member?

5 Upvotes

I've written a PowerShell (v7.7) script function that outputs information from the Get-Member (GM) cmdlet about the variable (name and value) that is passed into my function.

Here is a sample of the function's output (I added the titles for clarity):

var-name var-value var-type
$v08 Collection [Hashtable]
System.Object Item(System.Object key) {get;set;}
int Count {get;}
bool IsFixedSize {get;}
bool IsReadOnly {get;}
bool IsSynchronized {get;}
System.Collections.ICollection Keys {get;}
System.Object SyncRoot {get;}
System.Collections.ICollection Values {get;}

Here is the relevant code:

function write-variable {
  param(

    [Parameter(Mandatory)]
    [string]
    $variable_name,

    [Parameter(Mandatory)]
    [AllowNull()][AllowEmptyString()]
    $variable_value,

    [switch] $showMembers,
    [switch] $noNewline,

    [switch] $showHeader,

    [Parameter(ValueFromRemainingArguments)]
    [AllowNull()][AllowEmptyString()]
    $FormatingArgs

  )
  ⋮
  $var_name = (
    $variable_name\[ 1 .. ( $variable_name.length ) ]  `  
      -join ''
  )
  ⋮
  $value = (
      Get-Variable `
        -Name $var_name `
        -ValueOnly `
        -Scope Script `
        -ErrorAction SilentlyContinue
    )

  if( $NULL -eq $value ) {

    $type         = $NULL
    $string_value = 'Null'
    ⋮
  }
  else {

    $type         = $value.getType().Name
    $string_value = 'Collection' # For simplicity
    ⋮
  }
  ⋮
  # The actual code builds a format string and uses
  # it to format and output the three variables that
  # are seen in this next write statements, but this
  # code is enough to show the first line of the
  # output shown above.

  write-host (
      $variable_name + "`t" +
      $string_value + "`t" +
      '[' + $type + ']'
    )

  # I want to inject whitespace
  # before each line of the 'GM'
  # output.
  # Here is where I need help:

  (

    Get-Member `
      -InputObject $variable_value `
      -MemberType  Properties, `
                   ParameterizedProperty

  )
  |
  ( <# Need code here #> )
  |
  write-host
  ⋮
}

$v08 = @{ d1 = get-date; d2 = get-date }
write-variable '$v08' $v08 -noNewline

My Goal: Make the grouping of the output lines clearer when this function is called multiple times by indenting the lines (8 lines in this case) that follow the first line of the set (the one containing the variable's name, value, and type) from the output of each call of the function.

I've tried capturing the GM output to a variable and parsing the string, but unlike piping through to the write-host, all of the lines run together, loosing their carriage return and new-line characters, and there doesn't seem to be a consistent punctuation character in the string to parse for, so I can't inject the whitespace (tabs and spaces) to achieve the indentation with. '}' looked hopeful, but not for custom structures' methods nor properties. Besides other information seems to be lost when capturing GM to a string. If the information were not not lost or mangled, then parsing would be fine.

Alternatively, there is piping, which seems to keep the information intact better. I believe that if an object foreach statement were added to the pipe-line where my comment says "Here is where I need help", it could add the whitespace without parsing each line from the GM's string line as it flowed' through, but the "about piping" article and the other article at the MS Learning site didn't give me enough to experiment with or know even if this is the right 'track'.

Please, can someone give me some beginner links, an example, or just let me know if this is the right direction?

Thanks

P.S., I'm using Windows 10, not using VS Code (so no IDE) or any debugger, and I'm very much a newbie at PowerShell.

Update : I'm very close, but here is the problem, a solution, and a new, but related question ...

Name            Value        Type
-------         ------       -----
$v01             1           [Int32]
$v02             "two"       [String]
⋮
$v05             1, 2, 3, 4  [Int32[]]
$v06             one, two, three, four, five
                             [String[]]
⋮
$v08             Collection
                             [Hashtable]
  Method
    Add              void Add(Object key, Object value
                     void IDictionary.Add(Object key, Object value)
    ⋮
  ParameterizedProperty
    Item             Object Item(Object key) {get;set;}
Property
    Count            int Count {get;
    ⋮
$v11            Null
$hash           Collection   [Hashtable]
  Method
    Add              void Add(Object key, Object value
                     void IDictionary.Add(Object key, Object value)
    Clear            void Clear(
                     void IDictionary.Clear()
    ⋮

However in the lines for $v08, some of the lines are missing their endings and others aren't. Here are two that are missing:

$v08 Collection [Hashtable]
Method Add void Add(Object key, Object value <-- missing )
Property Count int Count {get; <-- missing }

Here is the preformatted lines:

$v08             Collection   [Hashtable]
  Method
    Add              void Add(… key, … value), void IDictionary.Add(… key, … value)
    Clear            void Clear(), void IDictionary.Clear()
    ⋮
  ParameterizedProperty
    Item             System.Object Item(… key) {get;set;}
  Property
      Count          int Count {get;}
      IsFixedSize    bool IsFixedSize {get;}
      ⋮

I've replaced the parameter types with … to get the lines to not spill over to the next line. And I've removed most of the lines that didn't loose their endings.

I used the regex pattern ( '([)}]),\s*' ) to find the lines that have more than one method or property, specifically those that have a ) or } followed by a , and optional whitespaces, and replace the matches with
'( $crlf + $tab + $tab + $tab + '' )' to push all of the methods or properties after the first one to a new line and over to the right so the methods or properties align with the others in a column.

I used a regex capture group on the ) and } characters to let me put back whichever was found and cut out the comma, but that argument is a PowerShell expression, not regex, and I don't know the auio-variable that contains the regex $1 matched unnaname group, in PowerShell, that is needed to put the captured ) or }.

I looked for 'powershell -replace regular expression group' in Google and got back lots of possible hits, but I'm mostly blind and unable to read most of the pages that don't support Dark Mode or high context text over a white background; another reason I don't like St...ow. Luckily, after many different searches, I found this:

"User123" -replace "(User)(\d+)", "Admin$2" # Output: "Admin123"

at: https://petri.com/powershell-replace-operator/ and it unlike so many other sites does cover -replace with an regex unnamed group, but adapting this example to my code produces this error:

This error:
Line |
 516 |                ( $1$crlf + $tab + $tab + $tab + ' ' )
     |                    ~~~~~
     | Unexpected token '$crlf' in expression or statement.

However, this is fixed and the ) and } are no longer missing! Here is the working code:

        $this_Definition = `
          $this_Definition `
            -replace 
              '([)}]),\s*',
              ( '$1' + $crlf + $tab + $tab + $tab + ' ' )

Now that the issue is fixed, I'll leave the solution here because this specific use isn't covered much.

I still would like to ask, what other information is hiding in each line of the piped output from the following command?

Get-Member -InputObject 'v08' -MemberType ParameterizedProperty, Properties, Methods ?

I've read the help guide on this command, but frankly didn't understand it well enough to use the few options I have, if people hadn't used them in their comments to this original question.

Please, someone explain the options for this command that are related to variables, including how to get the property values of a collection. Get-Variable works for arrays, but not for collections. Currently I put in 'Collection' for the type I get now. Or, is there a better command? Oh, and explain ii to me slowly, as you would if you were training an AI system. :P

Thanks


r/PowerShell • • 10d ago

News Why developers hate PowerShell

Thumbnail powershellexplained.com
429 Upvotes

This is a post that I have been thinking about writing for a very long time now. I find that developers struggle with PowerShell in a very different way that the sysadmin learning to automate. They bring intuitions and assumptions with them from other languages that catch them off guard when they skip over the documentation. In this article I try to capture some of those experiences and misunderstandings.

I cover a lot of ground in this one: running scripts, execution policy, aliases, objects and formatting, calling functions, output and return values, unrolling, operators, case sensitivity, type conversion, truthiness, strings, scope, automatic variables, paths, encoding, errors, native commands, and classes.

While this one is targeting Software Engineers more then Systems Engineers, I would still appreciate your feedback and stories of your own frustrating experiences.

Thank you, -Kevin


r/PowerShell • • 9d ago

Question Powershell coding help

0 Upvotes

Hi, I'm self learning powershell coding, I'm very new to this and trying my best. I'm using information from websites and mostly Ai to solve and help me on errors

Is there a way to connect powershell to websites? I've been copy pasting codes or taking screenshot on error code and sending to AI to help me out. Sending it manually everytime a new problem came out is wasting me too much time.


r/PowerShell • • 10d ago

Script Sharing I built a free PowerShell tool that finds rogue AI agents on Windows machines

95 Upvotes

Do you know if rogue AI agents are running on your machines?

I've been in IT for 25 years, 13 of them running my own MSP. I built Rogue Agent Checker (RAC) to give back, for the sysadmins who don't know whether agents are running amok on their boxes.

RAC finds AI agents on a Windows machine that aren't on your approved list: Claude Code, OpenClaw, Codex, Copilot agent mode, MCP servers, homemade Python bots. It shows you where each one is and what it can reach, and hands you a report (HTML, CSV, JSON) you can give to a manager or an auditor.

  • Free, Apache-2.0. Plain PowerShell (5.1 or 7). No modules, nothing to install.
  • Read-only. It never changes, disables or deletes anything, and never runs what it finds.
  • Local-only. It doesn't phone home. Keys are reported by name, never by value.
  • One machine per run. For a fleet, push it through your RMM; -RmmMode returns exit codes.

Try it (read-only; it only writes the report folder):

Get-ChildItem -Recurse .\RogueAgentChecker | Unblock-File
.\RogueAgentChecker\Start-RogueAgentScan.ps1 -OutputPath C:\RAC\report

Tested live on Windows 11 against a staged rogue agent (a hidden "OneDrive Sync Helper" calling OpenAI) and a real OpenClaw install. The first build missed the rogue in 3 of 4 scans, because Windows forgot its hostname after 60 seconds. The write-up of that miss, and the fix, is in the repo.

One rule in the README, for the agents: if RAC reports you, say so. Don't rename, hide, relaunch, or reschedule yourself to get around it. That rule exists because an AI agent running my tests over SSH lost its connection and, instead of stopping and telling me, relaunched the run hidden and base64-encoded. RAC can't see agents working over SSH yet. That's first on the 0.2 list.

Full disclosure: I built it with an AI coding assistant and tested every release by hand on real Windows.

Tell me what it misses.

Take back the machines.

https://github.com/richknowles/RogueAgentChecker


r/PowerShell • • 11d ago

News PS7 ScriptDesk v11 - Custom PowerShell 7 ISE

20 Upvotes

Good Morning All,

There is a new version of PS7 Scriptdesk. It has multiple bug fixes and improved Intellisense performance.
Please let me know if anyone finds anymore bugs or performance issues.
I am still looking for Export to API/EXE testers if anyone could lend some real world use to my lab test environment.

I forgot to mention. This is for the community. We can make it as user friendly or advanced as we want it to be. So long as we stay true to the spirit of the legacy ISE.

Case in point, all the PS specific formatting options available to the right click. That can be altered, expanded or changed in the behavior. I literally just started adding things that I do a lot and wanted to automate it, like taking a list and making it a sorted array. You have no idea how many times I just copy a column and insert it.

Regards,

-Ron

https://apps.microsoft.com/store/detail/9N8C4LMQXMF6?cid=DevShareMCLPCS

Another user pointed out the winget way of installing. That is fine but it may break the auto update feature.

winget search PS7

Name Id Version Source

--------------------------------------------

PS7 ScriptDesk 9N8C4LMQXMF6 Unknown msstore


r/PowerShell • • 12d ago

Solved Script to resolve missing MSI Cache for google chrome (1603,1612)

21 Upvotes

Just sharing this because ive had this issue across 1500 devices and with the help of copilot this script has been generated and has been resolving the issues perfectly.

Due to missing MSI Caches, Upgrades for chrome are failing with MSI 1603 or MSI 1612. This script pulls the latest, forcefully removes the old chrome, and installs fresh

 # ==========================
# Google Chrome Remediation
# ==========================

$DownloadUrl = "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise64.msi"
$TempDir     = "C:\ProgramData\ChromeRemediation"
$MSIPath     = Join-Path $TempDir "GoogleChromeStandaloneEnterprise64.msi"

Write-Host "Starting Chrome remediation..."

# Ensure TLS 1.2+ is enabled for older PowerShell / Windows builds
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13

# --------------------------------------------------
# Download Latest Chrome Enterprise 64-bit MSI
# --------------------------------------------------

New-Item -ItemType Directory -Path $TempDir -Force | Out-Null

Write-Host "Downloading latest Chrome Enterprise 64-bit MSI..."

try {
    # Suppress progress bar to prevent severe Invoke-WebRequest slowdowns in PowerShell 5.1
    $ProgressPreference = 'SilentlyContinue'
    Invoke-WebRequest -Uri $DownloadUrl -OutFile $MSIPath -UseBasicParsing -ErrorAction Stop
}
catch {
    Write-Error "Failed to download Chrome MSI: $_"
    exit 1
}

# Verify the file exists and is valid (at least 50 MB to rule out HTML error pages)
if (-not (Test-Path $MSIPath) -or (Get-Item $MSIPath).Length -lt 50MB) {
    Write-Error "Downloaded MSI is missing or smaller than expected. Aborting remediation."
    exit 1
}

Write-Host "Download verified ($([math]::Round((Get-Item $MSIPath).Length / 1MB, 2)) MB)."

# --------------------------------------------------
# Backup bookmarks
# --------------------------------------------------

$BackupRoot = "C:\ProgramData\ChromeBookmarkBackup"

New-Item -ItemType Directory -Path $BackupRoot -Force | Out-Null

Get-ChildItem "C:\Users" -Directory -ErrorAction SilentlyContinue | ForEach-Object {

    $User = $_.Name

    Get-ChildItem "$($_.FullName)\AppData\Local\Google\Chrome\User Data" `
        -Directory `
        -ErrorAction SilentlyContinue |

    ForEach-Object {

        $BookmarkFile = Join-Path $_.FullName "Bookmarks"

        if (Test-Path $BookmarkFile) {

            $BackupName = "$User-$($_.Name)-Bookmarks.json"

            Copy-Item `
                $BookmarkFile `
                (Join-Path $BackupRoot $BackupName) `
                -Force `
                -ErrorAction SilentlyContinue

            Write-Host "Backed up bookmarks for $User ($($_.Name))"
        }
    }
}

# --------------------------------------------------
# Kill Chrome Processes
# --------------------------------------------------

Get-Process chrome,googleupdate,googleupdater `
    -ErrorAction SilentlyContinue |
    Stop-Process -Force

# --------------------------------------------------
# Remove Chrome Uninstall Keys
# --------------------------------------------------

$UninstallRoots = @(
    "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall",
    "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
)

foreach ($Root in $UninstallRoots) {

    Get-ChildItem $Root -ErrorAction SilentlyContinue | ForEach-Object {

        $App = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue

        if ($App.DisplayName -eq "Google Chrome") {

            Write-Host "Removing uninstall key $($_.PSChildName)"

            Remove-Item $_.PSPath `
                -Recurse `
                -Force `
                -ErrorAction SilentlyContinue
        }
    }
}

# --------------------------------------------------
# Remove Windows Installer Product Registrations
# --------------------------------------------------

Get-ChildItem `
    "Registry::HKEY_CLASSES_ROOT\Installer\Products" `
    -ErrorAction SilentlyContinue |

ForEach-Object {

    $Item = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue

    if ($Item.ProductName -eq "Google Chrome") {

        Write-Host "Removing installer registration $($_.PSChildName)"

        Remove-Item $_.PSPath `
            -Recurse `
            -Force `
            -ErrorAction SilentlyContinue
    }
}

# --------------------------------------------------
# Remove Program Files Installs
# --------------------------------------------------

Remove-Item `
    "C:\Program Files\Google\Chrome" `
    -Recurse `
    -Force `
    -ErrorAction SilentlyContinue

Remove-Item `
    "C:\Program Files (x86)\Google\Chrome" `
    -Recurse `
    -Force `
    -ErrorAction SilentlyContinue

# --------------------------------------------------
# Install Latest Chrome
# --------------------------------------------------

$Process = Start-Process `
    msiexec.exe `
    -ArgumentList "/i `"$MSIPath`" /qn /norestart" `
    -Wait `
    -PassThru

Write-Host "Chrome MSI exit code: $($Process.ExitCode)"

# Clean up the downloaded installer
Remove-Item $TempDir -Recurse -Force -ErrorAction SilentlyContinue

if ($Process.ExitCode -in @(0,3010)) {

    Write-Host "Chrome installation successful"

} else {

    Write-Host "Chrome installation failed"
    exit $Process.ExitCode
}

# --------------------------------------------------
# Validation
# --------------------------------------------------

$Chrome = Get-ItemProperty `
HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, `
HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* `
-ErrorAction SilentlyContinue |
Where-Object {$_.DisplayName -eq "Google Chrome"}

if ($Chrome) {

    Write-Host "Installed Version: $($Chrome.DisplayVersion)"

} else {

    Write-Host "Chrome not detected after install"
    exit 1

}


r/PowerShell • • 11d ago

Question Why does this run and how do I fix it to work right?

5 Upvotes

Hello, I'm fairly new to writing PowerShell Scripts, and have a lot to learn. I'm running pwsh v7.7 on Windows 10.

With a lot of help from the ReddIt people who responded to my original question, I've written a 'write-variable' function that I can call from scripts that I develop for the times when I want to get information about one or more variables. Previously I put a bunch of write-hosts, get-variables, get-members, gettypes, and other statements in my scripts to 'see' what's happening with a particular variable, but with this function I've generalized and combined all of that stuff into a single function that doesn't need to be rewritten for each variable, value (i,e, Null) or type change that occurs. 90% of the problems I had writing this function had to do with line continuation (`) and incorrectly using the -replace pattern, code [string] method. But with lots of 'pointers' and guidance my function is done.

Here is the output I get running the function, which is after the output:

v1 1 (Int32)
System.Object Clone()
System.Object ICloneable.Clone()

int CompareTo(System.Object value)
⋮

Now the function:

function write-variable {
  param(
    [Parameter(Mandatory)]
 
    [string] $variable_name,

    [switch] $showMembers
  )

  $value = get-variable -name $variable_name -valueonly

  if( $value -eq $NULL ) {

    $value = 'Null'

  }
  else {

    $type = $value.gettype().Name

    $quote = switch( $type[ 0 ] ) {
               's'     { '"' } # [string]
               'c'     { "'" } # [char]
               default { '' }
             }

    $value = (
        $quote + $value + $quote +
        ' (' + $type + ')'
      )

  }

  write-host (
      $variable_name +
      "\t`t" + $value
    )

  if( $showMembers ) {

    $members = get-member -InputObject $variable_name

    # replace all leading whitespaces
    # with a crlf.`

    $members = $members -replace
                 '^\s*', "\r`n"

    # Replace ), and whitespace ( 0 or more )
    # with ) and add crlf.

    $members = $members -replace
                 '),?\s*',
                 {
                   return ')' + $crlf
                 }

    write-host $members
    
  }

}

[int] $v1 = 1

write-variable 'v1' -showMember

Thanks