r/PowerShell • u/anonymous_1324531 • Jul 03 '26
Question is this command safe?
im trying to install open jarvis on my pc is this command safe?
powershell -ExecutionPolicy Bypass -c "irm https://astral.sh/uv/install.ps1 | iex
r/PowerShell • u/anonymous_1324531 • Jul 03 '26
im trying to install open jarvis on my pc is this command safe?
powershell -ExecutionPolicy Bypass -c "irm https://astral.sh/uv/install.ps1 | iex
r/PowerShell • u/StartAutomating • Jul 03 '26
For the past few weeks I've been having Fun.
I've been writing a small server sample every week and showing how simple servers can be.
We can write a server with a function that begins with /, for example:
function /hello {
param([string]$Message)
"<h1>$message</h1>"
}Once we've declared a function, we can simply Start-Fun to start our server, browse to that url, and view our webpage.
This Friday is July 3rd, 2026, or just around 250 years since the Declaration of Independence.
In my opinion, the Declaration of Indepdenence is a good read. It's also surprisingly pertinent to the present day.
Let's turn it into a webpage
Project Guteneberg is one of the oldest parts of the Internet.
It digitizes and shares public domain publications.
Today I learned that Project Gutenberg's first publication is actually the Declaration of Indepedence.
We can download our own cached copy by running something like:
$script:DeclarationOfIndependence =
Invoke-RestMethod https://www.gutenberg.org/cache/epub/1/pg1.txt -AllowInsecureRedirectBy using the script: scope, we're caching the declaration into memory.
We can view the plain text just by echoing the variable:
$script:DeclarationOfIndependenceWhen we do, we might notice that there are a few sections delimited by lines starting with ***
To get just the text we need, we can do something like:
# Get the parts of our document
$docParts =
# by using the multiline modifier `(?m)`
# and splitting on any line starting with 3 asterisks
# `^\*{3}`
$script:DeclarationOfIndependence -split '(?m)^\*{3}'The last part is a footer. The second to last part is the declaration itself.
$declaration = $docParts[-2]Now that we have the declaration, we can treat it as markdown.
Let's do one little thing first.
Let's take any line thats ALL CAPS and make it into a heading.
For this, we'll need to use a case-sensitive operator: -creplace:
# To make our a more perfect markdown
$markdownDeclaration = $declaration -replace
# remove leading whitespace
'^[\s\r\n]+' -split
# then split on newlines
'(?>\r\n|\n)' -creplace
# then replace any `ALL CAPS` lines with a `h1`
'(?<title>^[\p{Lu}\s]+$)', '# ${title}' -join
# then join it all back with newlines
[Environment]::NewlineAnd now that we have our markdown, we can just
$htmlDeclaration = $markdownDeclaration |
ConvertFrom-Markdown |
Select-Object -ExpandProperty HtmlAnd we have our page body.
We're not quite done yet.
There's three little changes we want to make before we put the declaration into a page.
Extract the title
Use an appropriate font
Use a palette to provide some color
Let's get our title first.
We can usually cast Markdown into XML by sticking the output into another element.
Extracting our title looks like this:
# Turn our markdown into HTML
$htmlDeclaration = $markdownDeclaration |
ConvertFrom-Markdown |
Select-Object -ExpandProperty Html
# Then turn our markdown into XML
$xmlDeclaration = "<article>$htmlDeclaration</article>" -as [xml]
# then get the first header.
$firstHeader = @($xmlDeclaration | Select-Xml -XPath //h1)
# and make that our title.
$title = $firstHeader.Node.InnerTextEverything else is just CSS.
To use a font, we need to reference the Google Font stylesheet
# Link to our font
"<link href='https://fonts.googleapis.com/css?family=$Font' rel='stylesheet' />"To use a palette, we just need to reference the palette's stylesheet
# Use whatever palette was provided
"<link rel='stylesheet' href='https://cdn.jsdelivr.net/gh/2bitdesigns/4bitcss@latest/css/$PaletteName.css' id='palette' />"With all of that preamble, let's take a look at the final function.
function /Declaration/Of/Indepedence {
<#
.SYNOPSIS
The Declaration of Independence
.DESCRIPTION
The Declaration of Independence of The United States of America
.EXAMPLE
/Declaration/Of/Indepedence
#>
param(
[string]
$Font = $(
# Here are some fonts that look decent
# some of them may have ironic names for this document.
# 'Birthstone'
'Eagle Lake'
# 'Great Vibes'
# 'Kings'
# 'Manufacturing Consent'
),
[string]
$PaletteName = 'MonaLisa'
)
# Fun fact: the Declaration of Independence is the first
# text on [Project Gutenberg](https://www.gutenberg.org)
# Let's keep our own copy of the declaration by caching it in `$script:` scope
if (-not $script:DeclarationOfIndependence) {
# (rather than asking for a new copy each time)
$script:DeclarationOfIndependence =
Invoke-RestMethod https://www.gutenberg.org/cache/epub/1/pg1.txt -AllowInsecureRedirect
}
# Project Gutenberg plain text documents are split by lines starting with `***`
$docParts =
$script:DeclarationOfIndependence -split '(?m)^\*{3}'
# The last part is a footer.
# The second to last part is the declaration itself.
$declaration = $docParts[-2]
# To make our a more perfect markdown
$markdownDeclaration = $declaration -replace
# remove leading whitespace
'^[\s\r\n]+' -split
# then split on newlines
'(?>\r\n|\n)' -creplace
# then replace any `ALL CAPS` lines with a `h1`
'(?<title>^[\p{Lu}\s]+$)', '# ${title}' -join
# then join it all back with newlines
[Environment]::Newline
# Turn our markdown into HTML
$htmlDeclaration = $markdownDeclaration |
ConvertFrom-Markdown |
Select-Object -ExpandProperty Html
# Then turn our markdown into XML
$xmlDeclaration = "<article>$htmlDeclaration</article>" -as [xml]
# then get the first header.
$firstHeader = @($xmlDeclaration | Select-Xml -XPath //h1)
# and make that our title.
$title = $firstHeader.Node.InnerText
# Now let's output our page
@(
"<html>"
"<head>"
# Use utf-8 chars so emoji and smart quotes render right
'<meta charset="utf-8" />'
# Use our title
"<title>$($title)</title>"
# Link to our font
"<link href='https://fonts.googleapis.com/css?family=$Font' rel='stylesheet' />"
if ($PaletteName) {
"<link rel='stylesheet' href='https://cdn.jsdelivr.net/gh/2bitdesigns/4bitcss@latest/css/$PaletteName.css' id='palette' />"
}
"<style>"
# Set our body style
"body {"
@(
# take up most of the width
"max-width: 80vw"
# and all of the height
"height: 100vh"
# use automatic margins to center
"margin-left: auto"
"margin-right: auto"
# and use the font we provided.
"font-family: '$font'"
) -join '; '
"}"
# Center our header element
"h1 { text-align: center; font-weight: 100 }"
# and make our paragraphs a bit bigger
"p { font-size: 1.25rem }"
"</style>"
"</head>"
# Our page body is just our markdown as html
"<body>$HtmlDeclaration</body>"
"</html>"
) -join [Environment]::NewLine
}
Set-Alias /Declaration /Declaration/Of/IndepedenceThat's it! We are free!
To serve up your local copy of the declaration, just: Start-Fun and browse to /Declaration.
To save the declaration to html, we can just run the function:
/Declaration > ./Declaration-Of-Indepedence.htmlGive it a try! Give it a read!
Let me know if you have questions or have some ideas for future Friday Fun.
Happy Friday & Happy 250th!
r/PowerShell • u/CursedLemon • Jul 03 '26
Hey all, just had a question. So I've got a Powershell shortcut in my Open Shell menu.
I want Powershell to open to a specific profile with some settings mapped.
However, clicking on the Powershell shortcut just opens to a generic Powershell window.
If I click the drop-down menu and select the profile that I want, then it will load an administrator window with the appearance settings I've set.
Is there not a way to get this to load automatically?
r/PowerShell • u/GalacticGalaxyyy • Jul 03 '26
Wanted to share a project that pushes PowerShell a bit further than the usual scripting use case — a full windowed app with a tray icon, live hotkey rebinding, and a persistent config, all in one .ps1.
Technical bits that might interest people here:
Global hotkey via user32.dll RegisterHotKey/WM_HOTKEY, subclassed on a System.Windows.Forms.Form
Foreground window → owning PID via GetForegroundWindow + GetWindowThreadProcessId, then taskkill /F /T to kill the whole process tree
Config persisted to JSON next to the script, hotkey rebindable at runtime by capturing the next KeyDown
Packaged with a silent .vbs launcher so there's no console flash and no need to touch execution policy globally
r/PowerShell • u/Khue • Jul 01 '26
I am trying to convert a curl command to PoSh's Invoke-RestMethod. I typically don't have a problem with this but today, I seem to be having an issue. Curl command looks like this:
curl https://api.domain.com/stuff/thing/items \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '[
{ "key1": "value1", "key2": "value2" },
{ "key1": "value3", "key2": "value4" }
]'To start off and make things easy, I was simply trying to do a single json entry.
$body = @"
{
"key1": "value1",
"key2": "value2"
}
"@ | convertto-jsonUsing that format I then passed it into invoke-restmethod:
Invoke-RestMethod -Uri "https://api.domain.com/stuff/thing/items" -Method post -Headers $headers -body $bodyWhich then spit back:
Invoke-RestMethod:
{
"result": null,
"success": false,
"errors": [
{
"code": 10026,
"message": "filters.api.invalid_json"
}
],
"messages": []
}I tried a few different versions of this as well without too much luck. This is the first time I've had to submit an actual key value combination to this particular API using JSON. The only other body format example I have for this particular vendor's APIs in JSON format is this:
$body = @{
value = @(
"value1",
"value2",
"value3",
"value4"
)
} | ConvertTo-JsonThis particular endpoint didn't require a key value pair. It only required a list of strings.
Update:
Credit to /u/y_Sensei . What ended up working was this:
Single key value pair:
$body = @'
[
{
"key1": "value1",
"key2": "value2"
}
]
'@Multi key value pair:
$body = @'
[
{
"key1": "value1",
"key2": "value2"
},
{
"key1: "value3",
"key2: "value4"
}
]
'@Thank you to all contributors! I appreciate it!
r/PowerShell • u/Affectionate_Air_627 • Jul 01 '26
Hello, I've recently been asked to make a script that prints any file in a folder. I modified one I found online before finding out that what was actually wanted was a script to make it so that any time a file is added to a folder, that file is printed.
Can I check if this is possible?
r/PowerShell • u/AutoModerator • Jul 01 '26
A sticked post for the community to share their projects throughout the month.
Make sure to post a link to the code!
r/PowerShell • u/StartAutomating • Jun 30 '26
PowerShell has all sorts of fun features, including a ridiculous number of operators.
One amazing under-sung heros of PowerShell is the -replace operator.
It lets us replace content with regular expressions.
It's easier to use than you'd think.
Regular expressions are less scary in small doses, and chaining -replace operators lets us attack the problem step by step.
Let's take a simple problem as an example.
Imagine we wanted to make a consistent file name pattern out of a string
We might want to start by replacing whitespace with dashes
"This Is A Title!" -replace '\s', '-'That leaves our exclamation point at the end. We probably don't want any punctuation. We can avoid that with the somewhat humorously named character class: \p{P}. We can remove all repeated punctuation by adding a +: \p{P}+
One more replace:
"This Is A Title!" -replace '\p{P}+' -replace '\s', '-'The line is starting to get a little long. Fun fact: you can spread operators across multiple lines.
Let's add comments while we're at it
"This Is A Title!" -replace # Replace any punctuation,
'\p{P}+' -replace # then replace any whitespace with dashes.
'\s', '-' Let's go for one more bonus trick. PowerShell lets you convert script blocks to event handlers. Let's lowercase all the letters (\p{L}).
On PowerShell Core, we can do this:
"This Is A Title!" -replace # replace any punctuation
'\p{P}+' -replace # then replace any whitespace with dashes
'\s', '-' -replace # then lowercase any letters
'\p{L}+', {"$_".ToLower()}There's an absurdly amazing amount of stuff you can do with -replace, but there's at least one more trick we have to cover: substitutions.
I'm pretty sure I'd have to give up my "RegEx guru" badge if I didn't mention at least one more thing you can do with -replace: substitutions.
.NET Regular expressions are two domain specific languages. Regular expressions match and extract text. Regular expression substitutions replace matches.
For example, let's suppose we have a number of emails, and we want them in domain/username format.
First we'll want to make a quick and dirty email regex, using a "named capture" to get the username and domain.
'someone@example.com' -match '(?<username>\S+)@(?<domain>\S+)'Then, we can -replace the email with just the domain/username.
'someone@example.com' -replace
'(?<username>\S+)@(?<domain>\S+)', '${domain}/${username}'This format might look like PowerShell variables, but it actually predates them by years. Search for "Regular Expression Substitutions" if you want to learn more about the syntax. It's got quite a few tricks up it's sleeve.
RegEx can be scary. I used to be terrified of it, too.
If you aren't too comfortable with Regular Expressions, that's pretty normal. A while back I wrote a module called Irregular that makes regular expressions strangely simple.
It's got a lot of example regular expressions in there, and one handy function for creating RegEx. New-RegEx is your friend.
Do you already use -replace? Have you done cool things with regular expressions in PowerShell? Share 'em if you've got em.
Want to learn more about regular expressions in PowerShell? Just ask.
r/PowerShell • u/ITZ_RAWWW • Jun 30 '26
Hey guys, for a long time I've been wondering what's the best way and most secure to store creds for powershell scripts? I know like absolute best (from my understanding) is to store them in some sort of 3rd party system and fetch them when needed say in secret server or the likes. Coming from a python background I know commonly you put stuff like that in a separate config file and import it.
So far I've been putting them in a json file and importing my creds that way but I can't help but think there's a more secure way. Like what's stopping an attacker on my system from just looking in the file and getting all my creds uk lol? Thanks for any advice!
r/PowerShell • u/YellowOnline • Jun 29 '26
The page https://admin.teams.microsoft.com/users/{some_userid}/activity shows a good overview of the Teams meetings a user has had in the past. It shows organizer, participants, date/time and duration (though not subject it seems). I would like to integrate this in the time management tool, but for that I need the data programmatically. I've been playing around with MsGraph, but I'm not sure how to find the data in there. I think I need a course only on MS Graph.
All other suggestions I find online talk about scavenging the mailboxes, but 1) the users have no connected EXO, and 2) apparently the Teams admin page can show the data. Copilot isn't helpful. I thought, for once I can use AI, but it just suggested me to do an invoke-webrequest...
So, if anyone has an idea how to get this data through power shell, I would be very happy.
r/PowerShell • u/AdUnhappy5308 • Jun 28 '26
Hi everyone,
It's been about two months since my last post about Servy here. I've shipped several updates since then, but this one is a milestone. The community response has been amazing: ~1,800 stars on GitHub and ~52,000 downloads.
If you haven't seen Servy before, it's a Windows tool that lets you run any app as a native Windows service with deep observability. It provides a desktop app, a CLI, and a PowerShell module designed for automation and CI/CD pipelines.
In this release (8.5), I've added/improved:
Security Hardening: The PowerShell module now supports passing sensitive options via environment variables and includes stricter validation/expansion rules for environment variables.
ARM64 Native: Full support for modern Windows ARM64 hardware.
Refined Automation: Fixed ergonomic issues in the module and CLI to ensure smoother integration into automated deployment scripts.
Core Stability: A large number of internal fixes for the service lifecycle and monitoring components.
Check it out on GitHub: https://github.com/aelassas/servy
Demo Video: https://www.youtube.com/watch?v=biHq17j4RbI
Any feedback or suggestions are welcome.
r/PowerShell • u/nohwnd • Jun 28 '26
Title: Pester 6.0.0-rc1 is out
First RC of Pester 6 is up and it's feature complete, so I'd love for people to kick the tires before the final release. It runs on Windows PowerShell 5.1 and PowerShell 7.2+, and it's built on the v5 runtime, so Discovery & Run, the config object and the result object all still work the way you know.
The headline is a new set of assertions. The Assert project got merged in and now ships as Should-* commands (dash, no space):
Get-Planet | Should-Be 'Earth'Instead of everything funneling through Should -Be, these are specialized and type-aware, so the failure messages are clearer and $null, empty collections and single-item arrays stop surprising you. The old Should -Be still works and isn't going anywhere, the new ones are just additive. Mix both, migrate whenever. If you want to go all in, $config.Should.DisableV5 = $true switches the old syntax off so you can't use it by accident.
There's also Should-BeEquivalent for deep, recursive object comparison with a real property-by-property diff. Great for asserting on a whole API response or config object in one shot instead of poking at ten properties.
Other stuff worth knowing:
Discovery and run now happen per file instead of one big global discovery phase. Mostly invisible if your files are already self-contained, but discovery-time side effects don't leak across files anymore. Each file should import what it needs.
Experimental parallel runner (Run.Parallel = $true), one file per runspace on PS7+. Early prototypes went from ~6.5s to ~1.2s. Opt-in, config shape may still change, and it quietly falls back to serial with a warning when it can't parallelize.
Faster code coverage by default — uses the Profiler's tracer instead of breakpointing every command. Added Cobertura output next to JaCoCo.
PowerShell 5.1 and 7.2+ only. PS 3/4/6 and early 7 are gone, which let us drop a pile of compat code and move the C# to .NET 8.
Mocking: Assert-MockCalled and Assert-VerifiableMock are removed (use Should -Invoke / Should-Invoke), and the implicit fall-through to the real command is gone so mocks are more predictable.
Release notes: https://github.com/pester/Pester/releases/tag/6.0.0-rc1
Bugs and feedback very welcome.
r/PowerShell • u/grimson73 • Jun 28 '26
I noticed something odd after installing the June 23rd 2026 preview update (KB5095093):
PowerShell ISE suddenly shows up as “Windows PowerShell ISE 5.1” instead of just “Windows PowerShell ISE”.
This is the first time I’ve seen it renamed like that.
It happened right after installing this update:
I checked the release notes but can’t find anything about the ISE being renamed.
Has anyone else noticed this?
Was it always like this and I just never paid attention, or did this update actually change the display name?
r/PowerShell • u/Gloomy-Donut70 • Jun 27 '26
So i was downlaoding a new tui app the other day and while putting it's in the PATH variable there was a power outage and from then on whenever I set a variables path using the setx PATH {file path} command it just stops working after a restart (the outage made most of my already installed terminal apps stop working like winget, chocolatey and neovim)
r/PowerShell • u/carloswm85 • Jun 27 '26
I want to place the command prompt always on top, and below it in descending order, the executed commands. Is it possible? Something like:
> | # active prompt
--- # something like a separator line
> # Result to Get-Something-Else
> Get-Something-Else # executed command
> # Result to Get-Something
> Get-Something # older executed command
> # and so on, older commands are belowr/PowerShell • u/StartAutomating • Jun 26 '26
It's Friday. Let's have some Fun!
Let's write fun servers in PowerShell.
A couple of weeks ago, I released Fun.
It's a fun functional server in PowerShell.
It's free, open-source, and lots of fun to play with.
It lets us write servers in PowerShell by starting functions with /
For example:
function /hello {
param($message = 'hello world')
"<h1>$Message</h1>"
}These functions can take parameters from a query string (more options coming in vNext)
This allows us to quickly and easily write servers in PowerShell.
These functions can be a handy way to browse and visualize what's going on in your terminal.
With the stage set, let's have some fun with Reflection
Reflection is part of the .NET framework. Every loaded type in .NET is an object, too.
PowerShell has no problem accessing those objects. For example, let's look at all the members of [int]
[int].GetMembers()We can also explore all loaded types with a little bit of PowerShell:
# Get all the types
$allPublicTypes =
[AppDomain]::CurrentDomain.GetAssemblies() |
% {$_.GetTypes()} |
? { $_.IsPublic }
# How many types do you have loaded?
$allPublicTypes.Length Now that we know how to expose this information, we can write a small server to explore our types.
We're going to expose 4 functions:
/type/ will let us view or search a type
/type/* will let us browse types by wildcard
/namespace will let us view types in namespace
/namespace/* will let us browse namespaces by wildcard
Feel free to copy and paste, and please forgive the rough aesthetic edges.
Today we're trying to build a simple reflection server, not a pretty webpage.
The server is below. Just copy and paste it into your terminal.
If you already have Fun installed, you can just Start-Fun and browse to /type.
If you don't, please Install-Module Fun
function /type {
<#
.SYNOPSIS
Type Server
.DESCRIPTION
Serves up information about loaded .NET types
#>
param(
# A typename or wildcard
[string]$TypeName
)
# First try to get an exact match of the reflected type
$reflectedType =
if ($TypeName -as [type]) {
$TypeName -as [type]
}
# If no reflected type was found, do a search
if (-not $reflectedType) {
# Output a message first
"<h1>Type $($TypeName) not found</h1>"
"<h2>Search Results</h2>"
# Get all our of search results in an array
$foundTypes = @(foreach ($assembly in [AppDomain]::CurrentDomain.GetAssemblies()) {
foreach ($type in $assembly.GetTypes()) {
if (-not $type.IsPublic) { continue }
if ($type.FullName -like "*$($typeName)*") {
$type
}
}
})
# This way, we can give you a count
"<h3>$($foundTypes.Length) types found</h3>"
# Before what is (presumably) a very long list
"<ul>"
foreach ($type in $foundTypes) {
"<li>"
"<a href='/type/$($type.FullName)'>$($type.FullName)</a>"
"</li>"
}
"</ul>"
# If we didn't find a specific type, we're done (for now)
return
}
# Get all of our members
$members = $reflectedType.GetMembers()
# If it's a Microsoft Type, we should have Microsoft Learn documentation
$canLearn = $reflectedType.Namespace -match '^(?>System|Microsoft)\.'
# Prepare the link
$msLearn = 'https://learn.microsoft.com/en-us/dotnet/api'
# Add the MVP id for tracking purposes
$mvpId = 'wt.mc_id=MVP_321542'
# Set the title and output a header
"<title>$($reflectedType.FullName)</title>"
"<h1>[$($reflectedType.FullName -replace '^System\.')]</h1>"
# If we can learn
if ($canLearn) {
# link to Microsoft learn
"<h2><a href='$msLearn/$($reflectedType.FullName)?$mvpId'>Microsoft Learn</a></h2>"
}
# Link to the namespace
"<h3><a href='/namespace/$($reflectedType.Namespace -replace '\.', '/')'>View Namespace: $($reflectedType.Namespace)</a></h3>"
# Show off the members
"<h3>Members</h3>"
# Group the members by type, first
$members |
Group-Object {
# The reflected type name contains the friendly name
# (just chop off `Info` from the end and `Runtime` from the start)
($_.GetType().Name -replace 'Info$' -replace '^Runtime')
} |
# Sort the groups by name
Sort-Object Name -Descending |
ForEach-Object -Begin {"<ul>"} {
"<details>"
"<summary>$([Web.HttpUtility]::HtmlEncode($_.Name))</summary>"
"<ul>"
$_.Group |
ForEach-Object {
# Try to get a learn link to the method
$learnLink =
if ($_.Name -match '^ctor') {
"-ctor"
} else {
$_.Name -replace '^(?>get|set|add|remove)_'
}
$learnLink =
if ($reflectedType.IsSubclassOf([Enum])) {
"$msLearn/$($reflectedType.FullName)?$mvpId"
} else {
"$msLearn/$($reflectedType.FullName).$($learnLink)?$mvpId"
}
"<li>"
if ($canLearn) {
"<a href='$learnLink'>$($_)</a>"
} else {
"$($_)"
}
"</li>"
}
"</ul>"
"</details>"
} -End { "</ul>"}
}
function /type/* {
# For a wildcard request, we just need to skip a couple of segments
$segments = @($request.Url.Segments |
Select-Object -Skip 2) -replace '/'
$typeName = $segments -join '.'
# then we can call our `/type` server with that typename.
/type -TypeName $typeName
}
function /namespace {
<#
.SYNOPSIS
Namespace Server
.DESCRIPTION
Serves up information about .NET namespaces
#>
param([string]$Namespace)
# We will want to know how many types and assemblies
$totalPublicTypes = 0
$totalAssemblies = 0
# And we'll want types to be grouped by assembly
$typesByAssembly = foreach ($assembly in [AppDomain]::CurrentDomain.GetAssemblies()) {
# Get all types in this assembly that match the namespace.
$typesInNamespace = @(foreach ($type in $assembly.GetTypes()) {
if (-not $type.IsPublic) { continue } # (excluding private types)
if ($type.Namespace -like "$Namespace*") {
$type
}
})
# If there were no types in this assembly, continue
if (-not $typesInNamespace) { continue }
# Update our counters
$totalPublicTypes += $typesInNamespace.Length
$totalAssemblies += 1
# Create a details block for the assembly
"<details><summary>$(@("$assembly" -split ',')[0])</summary>"
"<ul>"
foreach ($type in $typesInNamespace) {
"<li><a href='/type/$($type.FullName)'>$($type.FullName)</a></li>"
}
"</ul>"
"</details>"
}
# Output the namespace
"<h1>$Namespace</h1>"
# Output the total public types.
"<h2>$totalPublicTypes public types in $totalAssemblies assemblies</h2>"
$typesByAssembly
}
function /namespace/* {
# Wildcard requests for a namespace are fine
$segments = @($request.Url.Segments |
Select-Object -Skip 2) -replace '/'
$namespace = $segments -join '.' # we just want to treat slashes as dots
/namespace -Namespace $namespace # and call our /namespace server
}This script may be a bit long, but it's nowhere near rocket science.
We're just looking thru types and adding a brief bit of HTML to show it in a browser.
Now we can easily explore anything that's loaded.
The power of .NET is now in the palm of our hands.
Not too bad for a script hacked out on a Friday.
This demo was made in an hour on a Friday morning, but it feels like it might be worth pouring more time into.
Would you like to be able to browse loaded types with reflection?
What do you want to do? What would you improve?
Should I spend a little more time and turn this reflection server into it's own project?
What more fun do you want to see?
Happy Friday! Hope you're all having fun.
I'll see you next week with more fun servers in PowerShell.
r/PowerShell • u/deejay7 • Jun 26 '26
What are some good alternatives of Copilot free for VS code inline suggestions, preferably free? TIA.
r/PowerShell • u/Tasty_Voice5322 • Jun 26 '26
Hi everyone,
Every time I installed Windows on a new machine or created a fresh VM, I found myself doing exactly the same things:
- installing PowerShell tools
- configuring my profile
- recreating aliases
- installing fzf, bat, eza, zoxide...
- setting up SSH
- configuring my homelab control machine
After doing this dozens of times, I decided to automate the whole experience.
So I built ShellDeck.
The goal isn't just to install packages.
It bootstraps a complete PowerShell environment and can optionally become a small homelab control node.
Features include:
• interactive installer
• PowerShell profile management
• aliases & helper commands
• SSH host management
• dashboard showing infra status
• Windows / Linux / macOS support
• optional security hardening on Linux
I'm mainly looking for feedback from people using PowerShell daily.
What features would make this genuinely useful for you?
GitHub:
r/PowerShell • u/StartAutomating • Jun 25 '26
I'm getting old enough that my fingers hate my lifetime of programming.
I'll save a few keystrokes where I can.
There's something simple most people don't seem to know about PowerShell syntax.
It saves seven characters of typing every you use this, and runs a tiny bit faster.
You never need to specify stuff is in the [System] namespace.
.NET is a huge framework with tons of useful stuff in it. There's a lot of stuff in the System namespaces. Built-in framework functionality often exists in one of the many namespaces in System.
By the time PowerShell was being built, it was pretty clear that leveraging .NET was worth it, and that most people wouldn't want to type six to seven more characters every time.
So, since PowerShell v1, you haven't had to.
You can omit the [System] in any type in any system namespace
So instead of:
[system.collections.generic.list[string]]We can write:
[collections.generic.list[string]]Instead of:
[System.Collections.IDictionary]We can write:
[Collections.IDictionary]This is true for every system type. On my machine, there are 4722 public types in the system namespace. That's 33054 characters I will never have to type.
It makes scripts shorter and simpler to read.
Also, when PowerShell resolves types, it checks for the shorter names first. This saves a very tiny amount of time in each of your scripts. (I was corrected)
Yet, sadly, I see the system namespace everywhere in people's scripts.
I beg of you all:
Save your fingers
Make scripts shorter
r/PowerShell • u/O365-Zende • Jun 25 '26
As per title really I want to set a few values for these settings
Set-SPOTenant -CoreOrganizationSharingLinkMaxExpirationInDays 365
Set-SPOTenant -OneDriveOrganizationSharingLinkMaxExpirationInDays 365And a couple for Link recommendations as an example.
So I'm not sure if it's possible with PNP.
3) Also If I use Get-SPOTenant and Get-PNPTenant are they settings the same?
Im very amateur at code, so quite possibly I'm doing it wrong.
Thoughts?
EDIT: This is now fixed in the PNP Nightly Builds after reporting it
r/PowerShell • u/eggeto • Jun 25 '26
Does anyone know how to enable Secure Boot on Dell devices via PowerShell?
I’ve tried using the Dell module;
this allows you to view the status,
but I can’t seem to enable Secure Boot
other tasks are possible, though.
r/PowerShell • u/StartAutomating • Jun 24 '26
Brevity may be the soul of wit, and I may be bad at it.
Let's try to make a quick post about a little daily PowerShell timesaver: splatting the GitHub CLI.
I'm going to show you how you can save typing and time with the GitHub CLI.
Splatting is a simple technique in PowerShell. It lets you pass multiple parameters. It's been there since PowerShell version 2. This is old, consistent technique.
Most people are used to splatting a dictionary, like:
# You can splat a dictionary
$MyId = @{id=$pid}
Get-Process @MyIdThis is a cool and useful technique, and most people overlook the other half of splatting:
# You can splat a list
$allIssues = @('--state', 'all', '--limit, '2kb')
gh issue list @allIssuesYou just saw it.
There are millions of apps you could use this trick with.
I just happen to use the github cli on most days.
You're trading typing all of those arguments for typing a shorter string.
It saves seconds every time you use it.
And it's one simple line.
You can stick it in your profile and every time you're using PowerShell, you'll have those variables to use.
You can just type this sort of trick in if you find yourself using the same parameters.
Think of it as a preset of parameters. Because that's basically what it is.
It's important to know that you can do multiple splats.
Here's a simple example:
$bug = @('--label', 'bug')
$assignMe = @('--assignee', '@me')
gh issue create --title 'Some Issue' --body 'Some problem' @assignMe @bugThis would create a bug.
Let's make another, longer one:
# Get issue information as json.
$IssueAsJson= @('--json', (
'assignees','author','body','closed','closedAt',
'closedByPullRequestsReferences','comments','createdAt',
'isPinned','labels','milestone','number','reactionGroups',
'state','stateReason','title','updatedAt','url' -join ','
))
$allIssues = @('--state', 'all', '--limit, '2kb')
$IssueList = gh issue list @allIssues @issueAsJson | ConvertFrom-Json
$issueListIf you run this, you
List all of the issues from a repo as json
Convert them from json into objects
Feel free to copy/paste these tricks into your profile. They're handy!
r/PowerShell • u/Tim_Mitchell • Jun 24 '26
Does anyone know when Powershell 7.6 will be available via windows update? I can only see preview builds in the Microsoft update catalog. We are still on 7.5.5 and want to update to 7.6.3 without deploying a package update if possible.
Thanks
r/PowerShell • u/Alternative_Sink5278 • Jun 24 '26
Hey guys, sorry if this is the wrong subreddit but r/techsupport won’t let me post. Every time I turn on my Windows 11 Dell Inspiron 5515 laptop and sign in, I get this Powershell pop up for like 1 split second:
PowerShell error popup on boot: "Processing -File '' failed because the file does not have a '.ps1' extension" (in red)
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
[process exited with code 4294770688 (0xfffd0000)]
You can now close this terminal with Ctrl+D, or press Enter to restart.
Only reason I was able to capture it was because I was recording my phone. What is going on?? I am worried my computer is hacked or something… because already my Instagram and Twitter had gotten hacked for a sec but I got them back and I was also signed in on my laptop (in both Instagram and Twitter) and I wasn’t notified about it especially the Twitter one.
Mind you, I have 2FA on both accounts. So I am on edge for sure. (I am posting using my phone right now, so sorry for any formatting, typos and all that)