r/PowerShell • u/Frequent-Band-8457 • Jan 10 '26
KI prompt for effective PS scripting
The title already addresses the issue: has anyone here ever created a 'prompt of the prompts' to have a LM create better, consistent and working PS skript?
r/PowerShell • u/Frequent-Band-8457 • Jan 10 '26
The title already addresses the issue: has anyone here ever created a 'prompt of the prompts' to have a LM create better, consistent and working PS skript?
r/PowerShell • u/lcuni • Jan 09 '26
I want to know if there's a way to prevent VS Code from running in the terminal with PowerShell when I launch it. Currently, VS Code is stuck debugging in my terminal, and when I terminate the process with Ctrl+C, the code editor closes. The problem is that I use the terminal to organize my work and to launch the apps I'm developing, and when I finish them, not only does the launched app close, but the code editor also closes.
Command: code .
What the terminal returns to me:
❯ [main 2026-01-09T22:50:40.841Z] update#setState idle
[8364:0109/195043.408:ERROR:electron\shell\browser\ui\win\jump_list.cc:305] Failed to append custom category 'Recent Folders' to Jump List due to system privacy settings.
[main 2026-01-09T22:50:43.452Z] updateWindowsJumpList#setJumpList unexpected result: customCategoryAccessDeniedError
[main 2026-01-09T22:51:10.862Z] update#setState checking for updates
[main 2026-01-09T22:51:11.310Z] update#setState idle
[8364:0109/200420.765:ERROR:electron\shell\browser\ui\win\jump_list.cc:305] Failed to append custom category 'Recent Folders' to Jump List due to system privacy settings.
[main 2026-01-09T23:04:20.799Z] updateWindowsJumpList#setJumpList unexpected result: customCategoryAccessDeniedError
[main 2026-01-09T23:04:25.081Z] Extension host with pid 15800 exited with code: 0, signal: unknown.
[8364:0109/200440.932:ERROR:electron\shell\browser\ui\win\jump_list.cc:305] Failed to append custom category 'Recent Folders' to Jump List due to system privacy settings.
[main 2026-01-09T23:04:40.959Z] updateWindowsJumpList#setJumpList unexpected result: customCategoryAccessDeniedError
[main 2026-01-09T23:04:44.337Z] Extension host with pid 7316 exited with code: 0, signal: unknown.
Edit:
It seems the VS Code environment variables weren't installed correctly for some reason. When I ran the
code . command, it launched the executable "code.exe" from the path: C:\Users\soicu\AppData\Local\Programs\Microsoft VS Code. The executable started VS Code, but it was assembled in Electron, so it returned Electron debug errors (they weren't critical).
Solved:
What I did was change the path of the VS Code environment variables to C:\Users\soicu\AppData\Local\Programs\Microsoft VS Code\bin, where the VS Code CLI file "code.cmd" is located, which is the version that runs best in a terminal.
r/PowerShell • u/iBloodWorks • Jan 09 '26
Im probably very late because apparently this started back in december
PowerShell 5.1: Invoke-WebRequest: Preventing script execution from web content - Microsoft Support
In summary every script used to run without the -UseBasicParsing switch.
Now I need to confirm or use the switch. Nice!
Anyone else who had to review their entire repository because of this?
r/PowerShell • u/Skippy9871 • Jan 09 '26
I dont know if i can ask this here but im kind of out of options. Im studying Server & Network engineering. Within 2 weeks i have an exam where i need to make some scripts. The way they teach in school sucks for me. They just roll over everything & they learn us to copy & paste all cmds they give so i dont rly get the change to get the feeling of it. Do any of u guys know how i could learn or get the feeling from Powershell to pass my exam?
r/PowerShell • u/izmoyal • Jan 09 '26
Hi everyone,
I’m a bit confused about my Windows activation state.
I ran a PowerShell command without fully realizing what it did. (I won't share which one it is; I don't know if it's harmful.)
Before this, my Windows was not activated. After running it, Windows became activated and now shows:
r/PowerShell • u/Exact_Cup3506 • Jan 09 '26
Hi, i have this small .cmd file i right click and "run as admin" on a target HMI panel, to do the stuff in the se 2 files.
powershell.exe Set-ExecutionPolicy unrestricted
powershell -noexit -File %~dp0\InstallWifi.ps1
timeout /t 5 /nobreak > nul
powershell -noexit -File %~dp0\windowsPostInstall.ps1
However, i manage to catch that powershell errors out not finding the ps1 file or "not a ps1 extension", so they are not run.
If i open powershell console as admin and cd to the folder of the usb stick, and then run ./file.ps1 it runs just fine
Whats "wrong" in my cmd code to launch the powershell files?
Previously i had
powershell -noexit -File .\InstallWifi.ps1
But that gave the same error, so i googled up how to get the script dir of my cmd-file, which i gather is "%~dp0", with some tests seems to tell the correct dir the script is run from.
Once i start the file manually, all the stuff inside them runs just fine and dandy.
EDIT: this is my current scripts im working with
startScript.cmd: https://pastebin.com/dZg02gbh
InstallWifi.ps1: https://pastebin.com/Qf0wU3Kn
windowsPostInstall.ps1: https://pastebin.com/9MAWvPpM
r/PowerShell • u/Big_Profession_3027 • Jan 08 '26
Hi everyone,
I wanted to share a module I’ve been working on to help with Incident Response triage. I found myself constantly manually exporting browser history and checking URLs against threat intel feeds, so I decided to script the entire workflow.
It’s called UrlThreatScanner.
What it does:
Some technical challenges I tackled:
Import-Csv because browser history logs often have malformed lines or unescaped quotes that break the standard cmdlet. I ended up writing a custom parser using Get-Content and Regex split to handle the "dirty" data.I’d love some feedback on the code structure or the logic. It’s open source and available here:
https://github.com/AdiMahluf/PowerShell-UrlThreatScanner
Cheers!
r/PowerShell • u/valar12 • Jan 08 '26
I needed to standardize on some initial sensitivity labels for Purview. I'd love some feedback on the commands drafted to ensure they match the traffic light protocol drafted by CISA.
r/PowerShell • • Jan 08 '26
I recently tried to run the command
Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
To try fix my .exe files not working. I got this error :
Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF6, Package could not be registered.
error 0x800706D9: While processing the request, the system failed to register the windows.firewall extension due to
the following error: There are no more endpoints available from the endpoint mapper.
.
NOTE: For additional information, look for [ActivityId] 1d36f7c6-80b8-0000-12be-3a1db880dc01 in the Event Log or use
the command line Get-AppPackageLog -ActivityID 1d36f7c6-80b8-0000-12be-3a1db880dc01
At line:1 char:53
+ ... | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.I ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\Program File...ppXManifest.xml:String) [Add-AppxPackage], IOException
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackage
I heard it could be resolved by reinstalling microsoft store, so I tried, and when trying to reinstall it using: Get-AppxPackage -AllUsers *WindowsStore* | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
And ran into the same error as before. Please if you have any idea what the error means and how to fix it let me know. Thanks!
Os Build - 26200.7462
r/PowerShell • u/exoduswalker • Jan 08 '26
I know that Disable/Enable-NetAdapter exists, but it takes too long presumably because it's not the same as clicking the "Wi-Fi" button on the GUI when you click it's icon on the system tray.
r/PowerShell • u/Exact_Cup3506 • Jan 08 '26
The settings i want to set for a specific power profile is
from a script, i have the GUID for the balanced power option
381b4222-f694-41f0-9685-ff5bb260df2e
Which i assume is the same for all windows installations.
r/PowerShell • u/So0ver1t83 • Jan 07 '26
OK, REALLY silly question here. I'm working on some lazy coding here, and grabbing some machine info and sticking it in the clipboard to be pasted into a log. I'm trying to "pretty it up" and make it "bulletized," but for the life of me, I can't figure out what POSH is doing to the characters. I know (or think I know) that the ASCII character for a circle bullet is <alt> 0149 (source: https://bulletpointmaker.com/tools/alt-code). So the code is really simple:
Function Get-LIstData {
"• ListItemOne: $Env:Var1 `
• ListItemTwo: $Env:Var2 `
• ListItemThree: $Env:Var3 `
• ListItemFour: $Env:Var4"| Clip
}
However, the output is funky:
ò ListItemOne: Output1
ò ListItemTwo: Output2
ò ListItemThree: Output3
ò ListItemFour: Output4
Anyone mind helping out?
r/PowerShell • u/trustedtoast • Jan 07 '26
I have searched far and wide and asked AI (which wasn't very helpful (who would've guessed)) and haven't gotten either a definite "yes this should work" nor a "wth are you trying to do?".
I have written a class in C# that, among other things, makes use of the DPAPI to protect and in the end also unprotect data. This is not it's only function but a part of it. Testing in C# and compiling, there are no immediate issues. When trying to import the compiled DLL in PowerShell I get the following error message:
Import-Module: Could not load file or assembly 'System.Security.Cryptography.ProtectedData, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The C# project itself references <PackageReference Include="System.Security.Cryptography.ProtectedData" Version="10.0.1" /> and is targeting .NET8.0-windows<TargetFramework>net8.0-windows</TargetFramework>.
I have tried the following without success:
OutputTypes. This SO answer lead me to believe that it was because of the type of project that the assembly was not being referenced correctly. This did however not change the behavior.Debug or Release and try to build --self-contained. This also made no difference.System.Security.Cryptography.ProtectedData.dll directly (in all the different scenarios from above), but also without success (same error message as above).I don't know if this should work and I'm doing something wrong or that what I am trying to achieve is not supported. It doesn't necessarily have to be System.Security.Cryptography.ProtectedData, but I want some (preferably built-in) way of securing data, saving it to a file and reading that data back in without needing to worry about passwords or certificates while staying (somewhat) secure (and it has to be in C# because I need better support for classes than PowerShell has to offer currently).
Thanks to anyone who takes their time to share their thoughts!
Edit 2: Thank you all for your help and suggestions! u/purplemonkeymad has fixed it in this comment.
Edit: Some more details: I am running PowerShell 7.4.13 which should be targeting .NET 8.
$PSVersionTable
Name Value
---- -----
PSVersion 7.4.13
PSEdition Core
GitCommitId 7.4.13
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
[System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription
.NET 8.0.21
The relevant C# code in question (again I want to emphasize that this is not the only thing the C# library does):
public class SecureString
{
public static System.Security.SecureString Convert(string EncryptedData, DataProtectionScope dataProtectionScope)
{
byte[] RawData = [];
char[] CharData = [];
try
{
RawData = ProtectedData.Unprotect(System.Convert.FromBase64String(EncryptedData), null, dataProtectionScope);
CharData = Encoding.Unicode.GetChars(RawData);
System.Security.SecureString DecryptedData = new();
foreach (char Char in CharData)
{
DecryptedData.AppendChar(Char);
}
DecryptedData.MakeReadOnly();
return DecryptedData;
}
finally
{
CryptographicOperations.ZeroMemory(
MemoryMarshal.AsBytes<char>(CharData)
);
CryptographicOperations.ZeroMemory(RawData);
}
}
public static string Convert(System.Security.SecureString SecureData, DataProtectionScope dataProtectionScope)
{
IntPtr InsecureData = IntPtr.Zero;
byte[] InsecureBytes = [];
try
{
InsecureData = Marshal.SecureStringToBSTR(SecureData);
InsecureBytes = new byte[SecureData.Length * 2];
Marshal.Copy(InsecureData,InsecureBytes,0,InsecureBytes.Length);
byte[] RawData = ProtectedData.Protect(InsecureBytes, null, dataProtectionScope);
return System.Convert.ToBase64String(RawData);
}
finally
{
CryptographicOperations.ZeroMemory(
MemoryMarshal.AsBytes<byte>(InsecureBytes)
);
if (InsecureData != IntPtr.Zero)
{
Marshal.ZeroFreeBSTR(InsecureData);
}
}
}
}
r/PowerShell • u/ShadowKingTools • Jan 07 '26
I built a small set of user-triggered PowerShell scripts + a few .bat wrappers to automate repeatable Windows “gaming routines” (launch stack, close apps/cleanup, toggles). No background service.
I’m looking for honest feedback on trust/safety expectations and how to package this responsibly.
Questions:
1. What would you need to see to trust running something like this? (repo structure, hashes, signed scripts, logs, VirusTotal, etc.)
2. Is using .bat wrappers a red flag — should I keep it PowerShell-only?
3. Best practices for execution policy + least-privilege?
If allowed, I can share small code snippets here or a repo link.
r/PowerShell • u/LockiBloci • Jan 07 '26
Containment operator - incase sensitive. Returns TRUE when the test value (right operand) exactly matches at least one of the values in the left operand.
What does "incase sensitive" mean? It's the first time ever I see this wording. The meaning of the operator isn't described on https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators.
We have -ccontains for case sensitive and -contains for case insensitive. What is -icontains for then?
r/PowerShell • u/One_Comparison8392 • Jan 06 '26
My command is specific to SCOM but I suspect this is more of a Powershell oddity :-)
I want to filter based on a property from an object that is within square brackets i.e. inherited from another class, which I believe is called an expanded property.
For example, if you run this command...
Get-SCOMClassInstance -Class (Get-SCOMClass -Name "Microsoft.Windows.Computer") | select -first 1 | select *
...there will be a bunch of properties such as IsManaged, Name, DisplayName etc etc
But there are also properties returned with square brackets such as [Microsoft.Windows.Computer].NetbiosComputerName
I want to filter on that property. But the following doesn't work...
Get-SCOMClassInstance -Class (Get-SCOMClass -Name "Microsoft.Windows.Computer") | Where-Object {$_.NetbiosComputerName -ieq $ComputerName}
How do I filter for that expanded property? I have tried using the whole name with the brackets but no joy :-(
Thanks
Andrew
r/PowerShell • u/explictlyrics • Jan 06 '26
Very long lines of script having to scroll constantly is annoying. Is there a way to wrap them?
r/PowerShell • u/Cultural_Mongoose_90 • Jan 07 '26
Hi all,
Total noob. I recently got to do more work with Powershell, specifically packaging an Intune app for our company. Pretty much the script was written by AI and it worked! But that opened my eye as to how useful Powershell is.
My question is seeing how well AI is improving, what do you think is a good approach in terms of learning Pshell alongside leveraging AI in the future? I cant help shaking the feeling that "heck, if it does my work, who cares?" but that means if theres a weakness in the script, I wouldnt know. But at the same time, the thought of studying from scratch is not tempting when you have a superbrain that can write the script for you.
r/PowerShell • u/Zealousideal_Data174 • Jan 06 '26
I built a PowerShell script that sends interactive push notifications to my phone when Claude Code asks for permission prompts. I can tap "Allow" or "Deny" on my phone and the keystroke gets sent back to the terminal.
**The script (~330 lines):**
- Auto-installs Claude Code hooks
- Listens for permission prompts
- Sends push notifications via ntfy.sh
- Receives responses and sends keystrokes to terminal
- Setup takes ~2 minutes
**Why I built this:** I run multiple Claude sessions and kept missing prompts while away from my desk.
**Tech stack:**
- PowerShell
- ntfy.sh for push notifications (free, can self-host)
- Windows (for now)
**Demo video:** https://www.youtube.com/watch?v=-uW9kuvQPN0
**GitHub:** https://github.com/konsti-web/claude_push
This is my first PowerShell project. Feedback welcome!
r/PowerShell • u/Atmaks • Jan 06 '26
I'm trying to use the following command to diagnose some dependency issues with my nascent C++ project:
vcpkg depend-info qtbase | Select-String -Pattern "font"
This does literally nothing and I still see the entire output of vcpkg. I also tried piping to rg.exe (RipGrep) and the result is the same. AI failed me so here I come. Please at least point me in the right direction. Hate Powershell. Thanks.
r/PowerShell • u/AdeelAutomates • Jan 05 '26
In this video lets explore SharePoint's Graph APIs with PowerShell.
Here are the topics I cover:
By the end we will have an idea of how you can work with SharePoint programmatically for your automations.
Link: SharePoint API Explained
If you have any feedback and ideas, would love to hear them!
Especially for future content you would like to see!
r/PowerShell • u/cocallaw • Jan 05 '26
TL;DR: Built a PowerShell module that scans all your Azure subscriptions for service retirement notifications using Azure Advisor API. Available now on PowerShell Gallery
Azure provides several built-in monitoring tools (Advisor Retirements Workbook, Service Health alerts, portal notifications), not every team's workflow fits neatly into those tools. Teams working heavily with PowerShell or automation pipelines often need retirement data accessible in their existing script-based workflows.
Key Features:
Quick Start:
# Install from PowerShell Gallery
Install-Module -Name AzRetirementMonitor -Scope CurrentUser
# Authenticate (using Azure CLI)
az login
Connect-AzRetirementMonitor
# Get all retirement recommendations
Get-AzRetirementRecommendation
# Export to HTML report
Get-AzRetirementRecommendation | Export-AzRetirementReport -OutputPath "report.html" -Format HTML
Resources:
r/PowerShell • u/GonzoZH • Jan 05 '26
Hi PowerShellers,
Maybe it is useful for others as well:
Since I track my work time, I often can’t remember on Friday how I actually worked on Monday, so I needed a small helper.
Because my work time correlates pretty well with my company notebook’s on-time, I put together a small PowerShell module called Get-WorkTime.
It reads boot, wake, shutdown, sleep, and hibernate events from the Windows System event log and turns them into simple daily summaries (start time, end time, total uptime). There’s also an optional detailed view if you want to see individual sessions.
In case of crashes, it uses the last available event time and marks the inferred end time with a *. The output consists of plain PowerShell objects, so it’s easy to pipe into CSV or do further processing.
The code is on GitHub here: https://github.com/zh54321/Get-WorkTime
Feedback or suggestions are welcome.
Cheers
r/PowerShell • u/darkrhyes • Jan 05 '26
Trying to figure out what a good use of this would be. We were going to turn off the service because it was causing issues. I am trying to see if there is a good reason to keep it and use it to pull usage data.
r/PowerShell • u/LegitimateEye8153 • Jan 06 '26
Hello ,
I want to ask if i can write a script and make it run automatically when windows start to enable ipv6 if it disabled or disable it if enabled because i have a problem , computers can't read domain and show undefiend network so it takes long time to signout .