r/PowerShell • u/HelloOrGoodbye • Sep 23 '26
Question Saw this on LinkedIn -- anyone give it a shot yet?
https://github.com/Kanders-II/PoshUI
Looks really cool but I have not tried it. Anyone tried this? Seems like the new way to do WPF with Posh!
r/PowerShell • u/HelloOrGoodbye • Sep 23 '26
https://github.com/Kanders-II/PoshUI
Looks really cool but I have not tried it. Anyone tried this? Seems like the new way to do WPF with Posh!
r/PowerShell • u/Calm_Examination_591 • Sep 23 '26
Weird question, moving large amount of files from one place to another using Robocopy found this CMD prompt but I want some others to look at it before I run it robocopy E:\ G:\FromE /E /Z /MT:8 /R:3 /W:5 /COPY:DAT /DCOPY:DAT /TEE /LOG:G:\robocopy-copy.txt /XD "System Volume Information" "$RECYCLE.BIN" /XJ
Moving 196GB from E to G, G has 339GB free.
also If you don't mind DM me instead of just replying since trying to send this to a couple servers.
r/PowerShell • u/Equivalent_Comb_5342 • Sep 22 '26
HyperTerminal hasn't shipped with Windows since Vista, and on locked-down work PCs you often can't install PuTTY or Tera Term either. Windows PowerShell 5.1 can talk to a serial port by itself through .NET's System.IO.Ports.SerialPort.
List the ports
[System.IO.Ports.SerialPort]::GetPortNames()
Get-PnpDevice -Class Ports -PresentOnly | Select-Object Status, FriendlyNameDrop -PresentOnly and you also get devices that are no longer plugged in but still carry their COM numbers, which is how a new adapter ends up on COM34.
Send a line, read a line
$port = New-Object System.IO.Ports.SerialPort 'COM3', 115200, 'None', 8, 'One'
$port.ReadTimeout = 2000
$port.Open()
$port.WriteLine('AT')
try { $port.ReadLine() } catch { 'no reply' }
$port.Close()The constructor arguments are port, baud, parity, data bits, stop bits.
Defaults of a fresh SerialPort object (checked in 5.1)
NewLine is LF only. If the device expects CR, change it or send the bytes yourself:
$port.NewLine = "`r"
$port.Write("AT`r")$port.Read($buffer, 0, $buffer.Length) instead of strings.What the errors mean
Access to the port 'COM3' is denied. - something else already has it open (Arduino serial monitor, another terminal, an upload tool). A COM port can be open in only one program at a time.The port 'COM99' does not exist. - wrong number, or the device is unplugged.In PowerShell these arrive wrapped in a MethodInvocationException, so $_.Exception.InnerException.Message gives you the actual text.
mode still works
mode COM3 in cmd prints the port's current baud, parity, data bits and DTR/RTS state, and plain mode lists every COM port.
If what comes back is unreadable, check the baud rate first (a stream of garbage), then the data format (8N1 vs 7E1: only some characters come out wrong), then the line ending.
I wrote up the longer version, comparing PuTTY, Tera Term and RealTerm for the same job plus a troubleshooting checklist, here: https://www.coding-now.com/en/guides/hyperterminal-alternative
r/PowerShell • u/RandomSkratch • Sep 21 '26
In the case of looking for the presence of something and using If paired with Exit codes, what's the difference between looking for the presence vs absence? For example
$Thing = Get-Thing
if ($thing) {
Exit 1
}
Else {
Exit 0
}vs
if (-not $thing) {
Exit 0
}
Else {
Exit 1
}Is it just for readability (ie 0 comes before 1 because it's in sequence?) Or are there speed differences or logic handling differences that matter in more complex scenarios?
Solved
Depends on the results of $thing determine whether or not you need to test for true or false. Speed isn't really a factor.
r/PowerShell • u/Imaginary_Rip2833 • Sep 21 '26
Hello everyone,
About 3 months ago, I started learning PowerShell, specifically with the Microsoft Graph PowerShell module.
I decided to learn it because I thought it would be relatively easy to pick up. My thinking was that I already know how to do many Microsoft 365 tasks through the GUI — creating users, creating groups, assigning licenses, managing devices, etc. — so I thought learning how to do the same things with PowerShell would be straightforward.
Three months later... 😂
I've learned quite a lot. I understand a bit of variables, arrays, hashtables, loops, functions, pipelines, filtering, objects/properties, foreach, if/elseif, try/catch, error handling, and I'm now starting to use Graph for real Microsoft 365 administration tasks.
I've actually really enjoyed some of the things I've been able to do so far, especially creating users and groups, updating users, filtering users, and building small scripts to audit my Microsoft 365 environment.
But honestly, I'm starting to feel really strained by it.
There are so many things to understand, and sometimes I look at a script and think, "How am I ever going to actually master this language?"
I understand the concepts when I'm learning them individually, but when I have to put everything together into a real script, my brain starts struggling. 😂
So I'm wondering:
Did I make a mistake by starting with Microsoft Graph PowerShell?
Would it have been better to learn "pure" PowerShell first and then move into Graph?
Or is this simply what learning PowerShell feels like for everyone at this stage?
I'd really appreciate hearing from people who have gone through this — especially anyone who started PowerShell for Microsoft 365/Entra/Intune administration.
I'm not looking to become a PowerShell developer. I mainly want to become competent enough to automate and administer Microsoft 365 properly.
Did you feel overwhelmed when you were learning, and what helped you get through that stage?
r/PowerShell • u/Unlikely_Tie1172 • Sep 21 '26
Microsoft has introduced a new control to stop Graph API-powered apps and agents from having unfettered access to Teams meetings transcripts. The new control is tenant-wide and either blocks or allows Graph API access. But after that, apps need the appropriate permissions and access through a Teams application access policy. To help, we illustrate how everything works with a PowerShell script.
https://office365itpros.com/2026/09/21/teams-meeting-graph-api/
r/PowerShell • u/Over_Dingo • Sep 21 '26
UI language for my PS7 suddenly changed to polish. PS5 stayed in english. I can't seem to find a way to revert PS7 back to english, like it was for many years (while system language was polish).
Things like errors, some information in Get-Help, or description for operators when you press 'ctrl + space'
Powershell 7:
PS C:\Users\lenovo\test> $PSVersionTable.PSVersion.ToString()
7.6.6
PS C:\Users\lenovo\test> $PSCulture
pl-PL
PS C:\Users\lenovo\test> Get-UICulture
LCID Name DisplayName
---- ---- -----------
1045 pl-PL polski (Polska)
PS C:\Users\lenovo\test> ls asdasdas
Get-ChildItem: Nie można odnaleźć ścieżki „C:\Users\lenovo\test\asdasdas”, ponieważ nie istnieje.
PS C:\Users\lenovo\test> Get-WinUILanguageOverride
Get-WinUILanguageOverride: Cannot marshal 'parameter #1': Invalid managed/unmanaged type combination.
PS C:\Users\lenovo\test> help ls -Parameter path
-Path [<System.String[]>]
Specifies a path to one or more locations. If not specified, the default location is the c
urrent
directory (`.`). Wildcards are accepted. Use care when using the **Path** parameter with t
he
**Recurse** parameter. For more information, see the [NOTES](#notes) section of this artic
le.
Wymagany? false
Lokalizacja? 0
Wartość domyślna
Zaakceptować dane wejściowe potoku? false
Aliasy none
Akceptować symbole wieloznaczne? truePowershell 5:
PS C:\Users\lenovo\test> $PSVersionTable.PSVersion.ToString()
5.1.19041.6456
PS C:\Users\lenovo\test> $PSCulture
pl-PL
PS C:\Users\lenovo\test> Get-UICulture
LCID Name DisplayName
---- ---- -----------
1045 pl-PL Polski (Polska)
PS C:\Users\lenovo\test> ls sadasd
ls : Cannot find path 'C:\Users\lenovo\test\sadasd' because it does not exist.
At line:1 char:1
+ ls sadasd
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\lenovo\test\sadasd:String) [Get-Child
Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
PS C:\Users\lenovo\test> Get-WinUILanguageOverride
PS C:\Users\lenovo\test> help ls -Parameter path
-Path <string[]>
Required? false
Position? 0
Accept pipeline input? true (ByValue, ByPropertyName)
Parameter set name Items
Aliases None
Dynamic? falseI know it doesn't need to be linked to system culture, because that change just happened and before it wasn't linked to it.
Any help would be appreciated.
EDIT:
found a partial workaround in setting:
[System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'en-US'but it works only for errors and autocomplete, not for Get-Help.
For further testing I decided to downgrade to powershell 7.6.3 ... and voila.
Everything is in english despite $PSUICulture is pl-PL.
I've been looking for release notes that mention it but couldn't find any. I tried in version 7.6.3 doing [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'pl-PL'
but it does ignore it, so it must be something with a later version
EDIT 2:
I pretty much confirmed it by jumping back and forth between PS 7.6.6 and 7.6.3. The earlier version ignores UICulture:
PS 7.6.6:
PS C:\Program Files\PowerShell\7> $PSVersionTable.PSVersion.ToString()
7.6.6
PS C:\Program Files\PowerShell\7> $PSUICulture
pl-PL
PS C:\Program Files\PowerShell\7> foobar
foobar: Termin „foobar” nie jest rozpoznawany jako nazwa polecenia cmdlet, funkcji, pliku skryptu lub programu wykonywalnego.
Sprawdź pisownię nazwy lub sprawdź, czy ścieżka została dołączona, sprawdź, czy ścieżka jest poprawna, i spróbuj ponownie.
PS C:\Program Files\PowerShell\7> [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'en-US'
# Culture is switched and the language of the error message changes:
PS C:\Program Files\PowerShell\7> foobar
foobar: The term 'foobar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Program Files\PowerShell\7> [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'pl-PL'
PS C:\Program Files\PowerShell\7> foobar
foobar: Termin „foobar” nie jest rozpoznawany jako nazwa polecenia cmdlet, funkcji, pliku skryptu lub programu wykonywalnego.
Sprawdź pisownię nazwy lub sprawdź, czy ścieżka została dołączona, sprawdź, czy ścieżka jest poprawna, i spróbuj ponownie.PS 7.6.3:
PS C:\Program Files\PowerShell\7> $PSVersionTable.PSVersion.ToString()
7.6.3
PS C:\Program Files\PowerShell\7> $PSUICulture
pl-PL
PS C:\Program Files\PowerShell\7> foobar
foobar: The term 'foobar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Program Files\PowerShell\7> [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'pl-PL'
PS C:\Program Files\PowerShell\7> $PSUICulture
pl-PL
# Error language stays the same even after explicitly setting the UICUlture:
PS C:\Program Files\PowerShell\7> foobar
foobar: The term 'foobar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Little bit annoying change after so many years
r/PowerShell • u/Devious018 • Sep 21 '26
Basically I am trying to create a desktop shortcut that would execute three commands one after another. So far I have created two separate desktop shortcuts that both work independently but have not been able to put them together to run one after another. One disables my gpu drivers and the other one enables it, i want to make a desktop shortcut that would enable the drivers and then after that is completed it would disable them and then finally re enable them
This is the disable line
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "Disable-PnpDevice -InstanceId 'PCI\VEN_1002&DEV_73DF&SUBSYS_52101849&REV_C5\6&399090B&0&00000019' -confirm:$false"
this is the enable line
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "Enable-PnpDevice -InstanceId 'PCI\VEN_1002&DEV_73DF&SUBSYS_52101849&REV_C5\6&399090B&0&00000019' -confirm:$false"
just need some help to create a sequential command to make as a desktop shortcut, and for anyone curious my gpu has issues where it regularly crashes this is the only fix that works
EDIT: Solved, created a .bat file with all commands written sequentially with a wait timer between them to let them run one by one. Thank you all for your help.
r/PowerShell • u/FerrousBueller • Sep 21 '26
EDIT for resolution: as the comments said, the various modules were incompatible being loaded into one script. The script has been split up for AD / email / EXO only functions loading only those modules.
Also found that SQLSERVER module Microsoft.Graph module have an incompatibility https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2566
Load SQLSERVER first then Microsoft.Graph
I've got a handful of user management scripts that connect to EXO and Entra to manage accounts / email etc. They should be sending emails about new account creations, manage distribution groups, send password expiring reminders etc.
They've all been working without issues for a while until last week.
They are all failing at Connect-MgGraph / Send-MgUserMail
Here's the error block from the script transcript. It's the same error for the applicable line where Connect-MgGraph is in each script:
Connect-MgGraph : Method 'RefreshCacheAsync' in type
'Microsoft.Graph.PowerShell.Authentication.Core.TokenCache.InMemoryTokenCacheOptions' from assembly
'Microsoft.Graph.Authentication.Core, Version=2.40.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have
an implementation.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:220 char:1
+ Connect-MgGraph -NoWelcome -ClientId $ClientId -TenantId $TenantId -C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-MgGraph], TypeLoadException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph
Connect-MgGraph : Method 'RefreshCacheAsync' in type
'Microsoft.Graph.PowerShell.Authentication.Core.TokenCache.InMemoryTokenCacheOptions' from
assembly 'Microsoft.Graph.Authentication.Core, Version=2.40.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' does not have an implementation.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:220 char:1
+ Connect-MgGraph -NoWelcome -ClientId $ClientId -TenantId $TenantId -C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-MgGraph], TypeLoadException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph
Send-MgUserMail : Authentication needed. Please call Connect-MgGraph.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:222 char:1
+ Send-MgUserMail -UserId "notification@company.com" -BodyParameter $Emai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Send-MgUserMail_Send], AuthenticationException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.SendMgUserMail_Send
Send-MgUserMail : Authentication needed. Please call Connect-MgGraph.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:222 char:1
+ Send-MgUserMail -UserId "notification@company.com" -BodyParameter $Emai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Send-MgUserMail_Send], AuthenticationException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.SendMgUserMail_SendFeeling a little stuck on this one, I haven't found much about that error message.
I've verified the app registrations, certificates, client/tenant IDs etc. are still valid. The service account isn't locked out / password expired etc.
If this is helpful here are the PS and Module versions:
PS C:\Windows\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.9245
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.9245
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\Windows\system32> Get-Module Microsoft.Graph* -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name
---------- ------- ----
Manifest 2.40.0 Microsoft.Graph
Script 2.40.0 Microsoft.Graph.Applications
Script 2.40.0 Microsoft.Graph.Authentication
Script 2.40.0 Microsoft.Graph.BackupRestore
Script 2.40.0 Microsoft.Graph.Bookings
Script 2.40.0 Microsoft.Graph.Calendar
Script 2.40.0 Microsoft.Graph.ChangeNotifications
Script 2.40.0 Microsoft.Graph.CloudCommunications
Script 2.40.0 Microsoft.Graph.Compliance
Script 2.40.0 Microsoft.Graph.ConfigurationMan...
Script 2.40.0 Microsoft.Graph.CrossDeviceExper...
Script 2.40.0 Microsoft.Graph.DeviceManagement
Script 2.40.0 Microsoft.Graph.DeviceManagement...
Script 2.40.0 Microsoft.Graph.DeviceManagement...
Script 2.40.0 Microsoft.Graph.DeviceManagement...
Script 2.40.0 Microsoft.Graph.Devices.CloudPrint
Script 2.40.0 Microsoft.Graph.Devices.Corporat...
Script 2.40.0 Microsoft.Graph.Devices.ServiceA...
Script 2.40.0 Microsoft.Graph.DirectoryObjects
Script 2.40.0 Microsoft.Graph.Education
Script 2.40.0 Microsoft.Graph.Files
Script 2.40.0 Microsoft.Graph.Groups
Script 2.40.0 Microsoft.Graph.Identity.Directo...
Script 2.40.0 Microsoft.Graph.Identity.Governance
Script 2.40.0 Microsoft.Graph.Identity.Partner
Script 2.40.0 Microsoft.Graph.Identity.SignIns
Script 2.40.0 Microsoft.Graph.Mail
Script 2.40.0 Microsoft.Graph.Notes
Script 2.40.0 Microsoft.Graph.People
Script 2.40.0 Microsoft.Graph.PersonalContacts
Script 2.40.0 Microsoft.Graph.Planner
Script 2.40.0 Microsoft.Graph.Reports
Script 2.40.0 Microsoft.Graph.SchemaExtensions
Script 2.40.0 Microsoft.Graph.Search
Script 2.40.0 Microsoft.Graph.Security
Script 2.40.0 Microsoft.Graph.Sites
Script 2.40.0 Microsoft.Graph.Teams
Script 2.40.0 Microsoft.Graph.Users
Script 2.40.0 Microsoft.Graph.Users.Actions
Script 2.40.0 Microsoft.Graph.Users.Functionsr/PowerShell • u/TearInternational414 • Sep 22 '26
I have a scheduled task that starts a Node server at logon through a hidden wscript shim (wscript //B start-agent-hidden.vbs, which runs node.exe server.js). To update it, my setup script did the obvious thing: stop the task, copy the new files, start the task.
The update never took effect. So I measured it:
before: node pid 9724; task Running after Stop-ScheduledTask: node alive = True; task Ready
The task went to Ready, while the process it launched kept running and kept its port. The new copy then started, failed with EADDRINUSE, and the old version carried on serving. A "is it up?" check even passed, against the old one.
What I use now: stop the task, then stop the process by its command line. Never by name, because other Node processes are yours too:
Stop-ScheduledTask -TaskName 'My Agent' -ErrorAction SilentlyContinue Get-CimInstance Win32_Process -Filter "Name='node.exe'" | Where-Object { $.CommandLine -and $.CommandLine.Contains("$dst\agent\server.js") } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }
$_.CommandLine -and matters: without elevation, other users' processes come back with a null command line, and .Contains on null throws.
Then, after Start-ScheduledTask, I check who actually owns the port, instead of trusting that something answers:
$owner = (Get-NetTCPConnection -LocalPort $port -State Listen).OwningProcess | Select-Object -First 1 $cmd = (Get-CimInstance Win32_Process -Filter "ProcessId=$owner").CommandLine if (-not $cmd.Contains("$dst\agent\server.js")) { throw "port $port is not served by the new copy" }
Two other things bit me in the same script:
Is this documented behaviour for tasks whose action is a script host that spawns a child? I couldn't find it written down anywhere.
(Context: this is the setup for Claude Remote, a side project that starts Claude Code on my PC from my phone. It goes open source soon: https://github.com/MrTig-afk)
EDIT: Answering the thing everyone asks first, so nobody has to ask it again. Why is there a whole chain in front of node instead of pointing the task straight at node.exe? Nothing clever. The task runs at logon and I don't want a console window appearing on my desktop every time I sign in. That's it. It's my own PC and my own preference.
Which is the other thing worth saying plainly: this is a hobby project on a home machine. It is not something I'd put on a managed corporate box and I'm not suggesting anyone else should.
The VBScript is gone since I posted. Microsoft is disabling VBScript by default so wscript //B is on a clock, and powershell -WindowStyle Hidden still flashes a console before it hides, which is the exact thing I was trying to avoid. The task now runs:
conhost.exe --headless cmd.exe /s /c "node.exe "<path>\server.js" 1>>"<log>" 2>&1"
Two caveats on that came out of the comments, so they go here rather than staying buried in a thread. It doesn't pass your command's exit code back, I measured it, cmd /c exit 42 comes back as 0. And it's a known technique in attacker tooling, so EDR may flag it. Neither bothers me on my own machine, but both would on a monitored one, and I'd rather this thing be fine on either. So I'm looking at replacing
that launcher with something that doesn't carry either problem.
--headless is also completely undocumented, conhost /? prints nothing at all, so the installer pushes a throwaway command through it and checks the file actually landed before it will register the task.
And on the "make it a Windows Service" replies: it can't be. The whole job of this thing is opening interactive windows on my desktop as me, and a service runs in session 0 where those windows are invisible.
EDIT 2: the conhost launcher is gone. Thanks to the comments here, the task now runs a tiny launcher I build from source on install: it starts the command with no window and passes the real exit code back, so exit 42 comes back as 42. No undocumented flag, and nothing that looks like attacker tooling. Two people from this thread are credited in the README. The project is open source now: https://github.com/MrTig-afk/claude-remote
r/PowerShell • u/l1ppgod • Sep 21 '26
PowerShell 5.1 + a small WPF wizard. Pick which monitor is the TV, hide the desk displays (disconnect / black overlay / DDC), optionally switch audio, then launch Steam Big Picture, Playnite fullscreen, or Xbox (Win+F11). When Big Picture/Playnite closes it restores the original layout from the tray.
Packed with ps2exe so it runs as a portable exe. Uses NirSoft MultiMonitorTool under the hood for the display side.
r/PowerShell • u/Professional-Rule-58 • Sep 20 '26
Edit: Built with AI assistance. The idea, direction and playtesting are mine, most of the code is not. A fun project to see how far PowerShell can be pushed. The whole story: https://github.com/oNdsen/polf3d/blob/main/HOW-IT-WAS-BUILT.md
POLF 3D is a Wolfenstein-style ray casting shooter that runs in PowerShell 7 on Windows. No modules, no asset files, no installation – every texture, sprite, sound effect, spoken line and music track is generated by code at start-up.
GitHub: oNdsen/polf3d: POLF 3D: a ray casting shooter written in PowerShell
As much PowerShell as possible, as little C# as necessary. The ray caster (DDA, one ray per column), the enemy AI, the map format, the network protocol, the sandbox and the chiptune composer are plain PowerShell. Only the innermost pixel loops, the audio callback and two P/Invoke declarations are C#, compiled once with Add-Type and cached. It runs at 45–60 fps in a 960×720 window. How it works
Download polf3d.zip, unpack it, start Play.cmd – or:
git clone https://github.com/oNdsen/polf3d.git
cd polf3d
./Start-Polf3D.ps1
Windows and PowerShell 7.2+. MIT licensed. GitHub: oNdsen/polf3d
Feedback is very welcome!
r/PowerShell • u/ViperThunder • Sep 19 '26
Has anyone gotten their VS Code environment set up with Local AI that works as well as copilot for inline code suggestions?
When connecting a github account to vs code, the copilot AI automatically enables and does an amazing job at inline code suggestions when writing powershell.
Sometimes, I'll just type one comment line and it'll write an entire script for me, ie:
#Get all Enabled AD Users that have a password expiration coming up in the next 7 days, and trigger a nice-looking html-formatted email to each user to inform they need to change their password
I press tab, and BOOM, half the script is already done.
I have been failing to get even close to the same behavior working for Local AI. I've pulled several different models in with Ollama, and tried several different extensions such as the Continue extension, Twinny, Code Llama and a couple others. Each has its own quirks. The best has been Code Llama, and it's still terrible. I'm convinced I'm doing something wrong.
For example, as a test, if I create a new powershell file and write: #find the password expiration date for each AD user
it suggests:$Users = get-aduser -filter {Enabled -eq $true} -Properties *#find the password expiration for each userforeach ($user in $users) {
$passwordexpirationdate = $user.passwordexpired
$passwordExpirationdate = $user.PasswordExpirationDate.ToString("MM/dd/yyyy")
$User.Samaccountname + " " + $PasswordExpirationdate}
and then it repeats the same block of code above 4 times. And that is the best I've seen so far.
This particular output is from codellama:7b-code-q6_K. I have also tried the qwen base models as well (1.5b, 7b, 13b) and they've been worse. All of these fit easily into my VRAM with plenty of room to spare.
I like Copilot, and I have configured my Github account to not allow AI to train on my data, but I am not convinced it's secure, so I would prefer to leverage my local hardware and not have to change names, email addresses, keys, etc. all the time before pasting anything into VS Code.
r/PowerShell • u/cooly0 • Sep 18 '26
So, I was migrating one of my personal PCs and tried the PCMover, but found it missed many things, that included things like Task Scheduler tasks, many Apps, StartMenu tiles, taskbar icons, powershell and cmd layouts, nearly all the custom Firefox profiles I had, for some examples. Some other examples that were originally missed, I found my shortcut for "Run", task scheduler tasks for Powershell and pwsh, all missing from my taskbar and startmenu, and Date/Time regional settings unchanged.
I didn't do an disk image because I was having some odd instabilities on the OS and I wanted to take advantage of this PC Move process to proactively attempt to filter that out on the new machine. Also the source was an old major brand-name business pre-built, and I decided to do the new one as a custom build, I thought try to filter out some of that clutter for the same reason. Plus, with how the business PC was, it was restricted from any post-end-of-support ESU updates, even manually downloading them and installing them from catalog.update.microsoft.com, the OS wouldn't allow them to complete.
So I vibed coded this with 5.6 Sol and 6 Astra, since didn't have the time and too tired to work through it, and it still took a couple of weeks, at my pace. Now this solves all the above issues.
Note, I only had ran this for a destination that had received the PCMover migration and not one with a clean installation. This was done for Win10 pro -> Win 10 Pro.
Also, as a FYI, I came upon some new tools that I hadn't been familiar with that do migrations, but hadn't tried them out since I was pretty far along in this process already.:
Hopefully someone finds this to be a little help.
r/PowerShell • u/Unlikely_Tie1172 • Sep 17 '26
On September 16, 2026, Microsoft announced a 12-month retirement period for support of PowerShell V5.1 by the Microsoft Graph PowerShell SDK. Microsoft also announced V3 of the Graph SDK and said that the new version will only support PowerShell V7. The transition for most scripts should be straightforward, but attention needs to be paid when scripts use outdated .NET assemblies. Famous last words…
https://office365itpros.com/2026/09/17/microsoft-graph-powershell-sdkv3/
r/PowerShell • u/icebreaker374 • Sep 17 '26
Looking for opinions...
When using Write-Progress inside of for/Foreach loops and using a counter stored in a variable defined outside the loop, do you start the counter at 0 or 1, and why?
r/PowerShell • u/Ok_Winter_2206 • Sep 17 '26
Screenshot (tray menu + taskbar icon): https://raw.githubusercontent.com/sahidhh/lenovo-battery-tray/main/assets/hero.png
Lenovo Vantage is a big Store app that needs admin, and the two things I actually use it for are toggling battery conservation mode and the Fn+Q power profile. So I wrote a tray app that does only that.
What it does:
lenovo-battery.ps1 set Conservation, power-set -Mode PerformanceHow: talks straight to the EnergyDrv kernel driver with DeviceIoControl (IOCTL protocol lifted from the Lenovo Legion Toolkit source) and to the LITSSVC service via control codes for power mode. No admin, no .NET install, no Vantage — plain Windows PowerShell 5.1 + WinForms, ~110 MB RAM idle, 0% CPU (all push-driven, no polling).
MIT, source: https://github.com/sahidhh/lenovo-battery-tray
Caveat: verified on exactly one machine (IdeaPad Slim 9 14ITL5). Other IdeaPad / Yoga / Slim / ThinkBook should work (same driver) but unconfirmed — if you try it, Copy diagnostics from the menu into a GitHub issue would help me build the compatibility list.
r/PowerShell • u/BurberryC06 • Sep 16 '26
EDIT: Now solved. Either was caused by power options being enabled (even though AC was connected) or changing trigger from 'startup' to 'logon'.
I have a simple PS script that turns on Mobile Hotspot automatically. The only conditional check is to see if there is ethernet connected. It was AI authored but I have run this script manually and also checked it works by running the task post-startup (mobile hotspot can be confirmed running).
The task scheduler shows the last run time as the last time the task was run manually so I assume the Task itself was just never started rather than a script execution error. Why isn't it running the startup task?
Here is the powershell code:
# 1. Define WinRT types
$NetworkInfoType = [Windows.Networking.Connectivity.NetworkInformation, Windows.Networking.Connectivity, ContentType=WindowsRuntime]
$TetheringManagerType = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager, Windows.Networking.NetworkOperators, ContentType=WindowsRuntime]
# 2. Get active connection profile
$connectionProfile = $NetworkInfoType::GetInternetConnectionProfile()
# 3. Verify connection is valid and is Ethernet (IanaInterfaceType 6)
if ($connectionProfile -and $connectionProfile.NetworkAdapter.IanaInterfaceType -eq 6) {
# 4. Initialize tethering manager
$wifiManager = $TetheringManagerType::CreateFromConnectionProfile($connectionProfile)
# 5. Trigger the hotspot activation asynchronously
$asyncOperation = $wifiManager.StartTetheringAsync()
# 6. Wait for the background WinRT process to finish its work (Status 0 = Started/Running)
while ($asyncOperation.Status -eq 0) {
Start-Sleep -Milliseconds 200
}
}The action is 'start a program', trigger 'at startup', execution command is
powershell.exe -ExecutionPolicy Bypass -File "C:\StartupScripts\TurnOnHotspot.ps1"r/PowerShell • u/Old_Employment8066 • Sep 15 '26
I wanted a downloader for friends who won't use a terminal, without shipping Python or Electron. So it's a single .ps1 — the whole window is WPF, compiled to an exe with ps2exe. Unzip and run, no console window, nothing installed.
https://github.com/Pronexsteam/deviload (MIT, portable zip in Releases)
Signing in: Chrome and Edge encrypt cookies now, so most people end up installing a cookie-export extension to download anything that needs an account. Here you press one button, log into Google in a small built-in browser window, and the app saves the session for yt-dlp itself. Works for the "confirm you're not a bot" refusals, private and members-only videos.
Also: download queue, playlists, split by chapters, trim with a preview, GIF from a selection, MP3/FLAC, subtitles, SponsorBlock, light/dark, English and Russian.
PS 5.1 notes: @() over a List[Object] that came from New-Object throws "Argument types do not match" (PSObject wrapper; only [Object], only List) — [List[Object]]::new() is fine. A hidden-window launcher through start still flashes a console, a two-line .vbs doesn't.
A lot of the code was written with Claude Code; I directed it and tested every build. Questions welcome.
r/PowerShell • u/ITZ_RAWWW • Sep 15 '26
Hey everyone, I made a simple ps log writer and thought I'd share it. Hopefully it's of use to someone. Just as a quick background, I come from a python background but for work I've been writing a lot of ps for a project I'm working on. Boss man was pleased with the code but then asked about log files (insert spongebob "but what about my drink meme here").
So I did some searching to see if there's a native ps logging module similar to python's. To my dismay, I came across non native options. While they may be reputable, given I work in cybersecurity and I had concerns given the recent uptick in supply chain attacks for open source software i was on edge. Didn't feel like reading through the whole code base to see if it was something that can be trusted. So I just wrote my own really simple version.
If the formatting look odd for some reason below, see my github jist. Hope this helps someone, kind regards!
<#
Author: shewdew the hedgehog
Date: 09/15/2026
Description: PS code to write logs to text file.
Version: Initial
#>
function Write-Log{
<#
Custom function to be able to write basic logs to a text file.
Eventually I might turn this into a whole module and add extended features since I didn't want to downlaod a logging module of the internet. But this works for now.
While not a hard rule, log levels are just like python's:
- Debug
- Info
- Warning
- Error
- Critical
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Level,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Message
)
$timeStamp = Get-Date -Format "dd-MM-yyyy HH:mm:ss"
$logEntry = "$timeStamp - $($level.ToUpper()) - $message"
Add-Content -Path "myLogFile.log" -Value $logEntry
}
function Reset-Log{
# Rotate log file every 90 days
$cutOff = (Get-Date).AddDays(-90)
$file = Get-Item "C:\path\to\myLogFile.log" -ErrorAction Stop
if ($file.LastWriteTime -lt $cutOff) {
Remove-Item $file.FullName -Force
Write-Log -Level "Info" -Message "Log file deleted."
}
}
# Usage
Write-Log -Level "debug" -Message "Succesfully did something or whatever."
Write-Log -Level "Critical" -Message "WEEWOOWEEWOOWEEWOO! SOMETHING BROKE!"
# since the log levels aren't hard coded, you could have a log level of anything lol. Which can be a pro/con.
Write-Log -Level "pizza" -Message "The server blew up..."r/PowerShell • u/_iamrewt • Sep 15 '26
Our CI/CD scripts are written in PowerShell and I like to break some of them up into separate .ps1 files for clarity. For example, I have a paths.ps1 file that establishes a several common paths that I then import into our build.ps1 file. Here's a contrived example...
$Paths = [pscustomobject]@{
BuildRootDir = Resolve-Path "$PSScriptRoot/.."
SrcDir = Resolve-Path "$PSScriptRoot/../src"
# many other paths
}. "$PSScriptRoot/paths.ps1
$Paths. # no autocompleteI like the simplicity but autocomplete fails and I believe it is due to this issue and it may never be addressed.
Have you found a reasonable workaround for this limitation?
r/PowerShell • u/CypherAus • Sep 15 '26
Per the title. I can set affinity per the following example (cores 10-19)
But is there a way to find which cores are performance and thus build an Affinity mask for the performance cores (hex string)?
$Process = Get-Process myexename$Process.ProcessorAffinity = 0x00000000000FFC00
Thanks
PS I'm using Dave Plummer's TMOG to check the core usage
r/PowerShell • u/fradan12 • Sep 14 '26
Curious how people are handling this in real environments, especially larger estates.
I’ve worked in environments where PowerShell ends up scattered everywhere over time. Scripts sitting on servers, scheduled tasks nobody remembers creating, service accounts tied to things, old modules/commands still being used, and scripts that are apparently “business critical” but have almost no documentation.
A few problems I’m curious whether others actually run into:
How do you guys manage this?
Git obviously solves part of the versioning/source-control problem, but I’m more interested in discovery and understanding.
For example, if you inherit 30 servers and nobody can confidently tell you what PowerShell is running across them, what’s your process?
Do you have tooling that inventories it? CMDB? Git repos? Scheduled scans? Documentation standards? Just grep/search everything and hope for the best?
Also interested in how people approach migration. How do you decide whether something should:
Full disclosure: I’ve been building At0mFlow because I kept running into versions of this problem myself. I’m not looking to pitch it here though. I’m actually trying to work out whether this is a widespread PowerShell/IT Ops problem or something that was disproportionately common in the environments I worked in.
Would genuinely love to hear how people are handling this in the real world, especially anyone managing hundreds/thousands of scripts or multiple servers.
r/PowerShell • u/Tidy-Developer • Sep 11 '26
I appreciate that there are a lot of experienced PS folk here, so I'd like to invite some experienced eyes to code-review a library before I make it v1.0.0. I want to get the codebase to a solid foundation that includes idiomatic PowerShell and community conventions that I might have missed.
I'd particularly value constructive comments relating to any of these:
I'd like to find breaking changes pre v1.0.0.
The main file for review is TidyLog.ps1, which contains the function library. The other repo files are demo and test scripts that don't necessarily need review.
Review version: https://github.com/tidy-tools/tidylog-pwsh/releases/tag/v0.9.0
Project link: https://github.com/tidy-tools/tidylog-pwsh
To give an idea of what the library is for, the intention is to:
The "With Tidylog" screenshot in the README shows the kind of use case I'm optimising for.
It took a fair bit of work to get from concept to working concept to potentially sharable. So to keep a manageable lid on the v1 workload, I intentionally kept some functionality out of scope for this release. Here are some code decisions/limitations that you'll probably notice:
I'm still noticing things I could change, but I'm working in a bubble so I feel it needs a review.
Thanks for reading and I hope you get a chance to review!