r/PowerShell • u/fbsau • Oct 29 '17
r/PowerShell • u/2j0r2 • Jan 01 '26
New Version KRBTGT Password Reset Script Released
FYI: the newest version of the KRBTGT Password Reset script has just been released!
Wanna try it out? Get it here: https://jorgequestforknowledge.wordpress.com/2026/01/01/powershell-script-to-reset-the-krbtgt-account-password-keys-for-both-rwdcs-and-rodcs-update-8/
Any feedback/comments? Please use https://github.com/zjorz/Public-AD-Scripts/issues
r/PowerShell • u/steak432 • Apr 13 '24
Microsoft Graph - Am I just an idiot?
I'll admit my PowerShell skills are mediocre at best, but the Microsoft Graph module is really making my head hurt. I'm trying to create a fairly basic script to to pull some logs from Entra. Before, this was quite straightforward using the AzureAD module, but the Graph cmdlets are constantly running into errors. The documentation is very hard to follow and the whole thing doesn't seem remotely intuitive. Is anyone else finding this or is it just me?
r/PowerShell • u/bstevens615 • Mar 21 '24
I Love PowerShell
Sometimes I forget that PowerShell is not all scripting. Sometimes a simple cmdlet gives you exactly what you need. Like joining a remote client to the domain. Desktop support has been waiting over a week to get access to a computer that someone forgot to AD join.
A simple "Add-Computer" and it's done. No local access required . No user interuption needed.
r/PowerShell • u/TheOneWhoKnocksBR • Jul 28 '22
Question Adding a GUI for Powershell scripts - Preferred and Easiest method
I had been looking for a way to add a GUI to my powershell scripts in the past and could not find one that was simple enough for me to get started.
I am aware normally its built using .NET but I think the learning curve on that would be a bit intense just to learn how to add some GUI to my scripts? If someone know any specifc training I would appreciate.
I know how to use Tkinter on Python, and have tried some parse powershell commands to python but the results were kind of messy and not really friendly.
Does anyone know what is the best, and what is the easiest option to go around learning how to add my scripts to a GUI format?
r/PowerShell • u/maybe_an_username • Oct 15 '21
Some powershell beep
I'm probably not very productive today... So may be someone will find these interesting :
White stripes : 7 nation army:
[System.Console]::Beep(196,1200);
[System.Console]::Beep(196,300);
[System.Console]::Beep(220,400);
[System.Console]::Beep(196,400);
[System.Console]::Beep(174,300);
[System.Console]::Beep(155,1000);
[System.Console]::Beep(146,1000);
[System.Console]::Beep(196,1000);
[System.Console]::Beep(196,300);
[System.Console]::Beep(220,400);
[System.Console]::Beep(196,400);
[System.Console]::Beep(174,300);
[System.Console]::Beep(155,400);
[System.Console]::Beep(174,300);
[System.Console]::Beep(155,400);
[System.Console]::Beep(146,1000);Haloween:
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1175,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1175,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1175,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1175,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1175,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1175,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1109,200);
[System.Console]::Beep(740,200);
[System.Console]::Beep(1175,200);
[System.Console]::Beep(740,200);Enjoy the beep :)
( Edit 1&2 : formating )
r/PowerShell • u/fedesoundsystem • Sep 10 '21
Just to share a Microsoft Virtual Academy super enjoyable Powershell course for new users
I found this Powershell course dictated by the inventor of Powershell, doing a walktrhough on all the coolest features, ideal for newbies! Don't be scared by the 6-hour duration, it is super easy to see and follow, an I am currently on the fourth hour, watching it little by little for about three days, and I love it!
You can see the wole though and effort they put to be easy to use!
EDIT:mistype
r/PowerShell • u/Betterthangoku • Dec 01 '20
Want to practice your skills? Advent of Code 2020 went live today!
Howdy folks,
Friendly reminder that Advent of Code started today! Time to save Santa. Or maybe the elves. Or maybe Rudolph or something. I dunno, but it's a great way to learn/practice coding.
If you are not familiar with Advent of Code it's a yearly game with coding problems that span from Dec. 1st to Dec. 25th. I can honestly say that I learn at least few new techniques every year whilst solving the puzzles.
Happy Holidays :-)
edit: This really blew up! Perhaps we should start our own daily thread for each day? There is the /r/adventofcode sub, but I've found very few Posh submissions there. Anyways, I'm so glad others are having fun with this. And they have past years to test your skills. :-)
r/PowerShell • u/ThomasMaurerCH • Jul 22 '20
News Windows Terminal Preview 1.2 Release | Windows Command Line
r/PowerShell • u/MadBoyEvo • Feb 19 '20
Script Sharing Finding GPOs missing permissions that may prevent GPOs from working correctly
Hi guys,
Recently I had another domain (pretty big one actually - 4000 GPOs) that had about 50-100 GPO's broken because of missing permissions.
This blog post talks about it and shows how to fix: https://evotec.xyz/finding-gpos-missing-permissions-that-may-prevent-gpos-from-working-correctly/
It all comes down to running:
Install-Module ADEssentials -Force
$MissingPermissions = Get-WinADGPOMissingPermissions -Mode Either
$MissingPermissions | Format-Table -AutoSizeHere's the output:

This scans the whole forest and all GPO's and searches for Authenticated users or Domain Computers permission missing from GPO's. It only does the scan, I didn't want to fix it. Not today at least.
It requires RSAT (AD+GPO).
Enjoy
r/PowerShell • u/Sin_of_the_Dark • Mar 28 '22
Script Sharing Here are 15 PowerShell functions for your day-to-day Intune needs
Hi all,
First, I would like to thank everyone for their feedback on the initial release of my Azure Administrator app. I've heard the feedback, and will soon be releasing an update that includes many of your day-to-day Intune needs.
That's actually why I'm writing this, I just finished all the primary functions that I'll be utilizing for the Intune module, and wanted to share the PowerShell source code for folks who want to adopt the functions into their environment without the GUI application. Here are 15 Intune-based functions, all with functionality descriptions. As with my AAD functions, you'll need to set up a registered app in AAD and configure graph permissions accordingly: Get access on behalf of a user - Microsoft Graph | Microsoft Docs
Required app Graph API permissions:
Assign-IntuneApp:
DeviceManagementApps.ReadWrite.AllAssign-IntuneCompliancePolicy:
DeviceManagementConfiguration.ReadWrite.AllAssign-IntuneDeviceConfiguration:
DeviceManagementConfiguration.ReadWrite.AllGet-IntuneApp:
DeviceManagementApps.Read.AllorDeviceManagementApps.ReadWrite.AllGet-IntuneCompliancePolicy:
DeviceManagementConfiguration.Read.AllorDeviceManagementConfiguration.ReadWrite.AllGet-IntuneDevice:
DeviceManagementManagedDevices.Read.AllorDeviceManagementManagedDevices.ReadWrite.AllGet-IntuneDeviceConfiguration:
DeviceManagementConfiguration.Read.AllorDeviceManagementConfiguration.ReadWrite.AllGet-IntuneDeviceLastSync:
DeviceManagementManagedDevices.Read.AllorDeviceManagementManagedDevices.ReadWrite.AllGet-IntuneDeviceLastUser:
DeviceManagementManagedDevices.Read.AllorDeviceManagementManagedDevices.ReadWrite.AllGet-IntuneDevicePrimaryUser:
DeviceManagementManagedDevices.Read.AllorDeviceManagementManagedDevices.ReadWrite.AllReboot-IntuneDevice:
DeviceManagementManagedDevices.PriviligedOperation.AllReset-IntuneDevice:
DeviceManagementManagedDevices.ReadWrite.AllorDeviceManagementManagedDevices.PriviligedOperation.AllSet-IntuneDevicePrimaryUser:
DeviceManagementManagedDevices.Read.AllorDeviceManagementManagedDevices.ReadWrite.AllSync-IntuneDevice:
DeviceManagementManagedDevices.PriviligedOperation.All
For those who are interested in the GUI app, stay tuned! I hope to have the update published this week.
r/PowerShell • u/itmonkey78 • Jan 30 '19
Listing Office365 Outages
I was asked for this in another sub, but will post here for the delight and ridicule of the PS community.
in light of the recent (and ever-increasing) Office365 outages, I mangled up some code to list the outages O365 has endured so far this year.
Many people lovingly refer to O365 with an ever-decreasing number after each outage, O364, O356 etc, so I also managed to come up with code that would output an accurate name for the current state of the service. Anyway, here goes...
function Get-O365Outages {
param(
[Parameter(Mandatory=$false)]
[Microsoft.PowerShell.Commands.HtmlWebResponseObject]$WebRequest,
[Parameter(Mandatory=$false)]
[int]$TableNumber=0
)
## Connect to the ITSD O365 Outage page if no Request is passed through - also auto-determine the security protocol to use
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
if (!$WebRequest) { $WebRequest=(iwr "https://istheservicedown.co.uk/status/office-365/history") }
## Extract the tables out of the web request
$tables=@($WebRequest.ParsedHtml.getElementsByTagName("TABLE"))
$table=$tables[$TableNumber]
$titles=@()
$rows=@($table.Rows)
## Go through all of the rows in the table
foreach($row in $rows){
$cells = @($row.Cells)
## If we've found a table header, remember its titles
if($cells[0].tagName -eq "TH"){
$titles = @($cells | % { ("" + $_.InnerText).Trim() })
continue
}
## If we haven't found any table headers, make up names "P1", "P2", etc.
if(-not $titles){ $titles = @(1..($cells.Count + 2) | % { "P$_" }) }
## Now go through the cells in the the row. For each, try to find the
## title that represents that column and create a hashtable mapping those
## titles to content
$resultObject = [Ordered] @{}
for($counter = 0; $counter -lt $cells.Count; $counter++){
$title = $titles[$counter]
if(-not $title) { continue }
$resultObject[$title] = ("" + $cells[$counter].InnerText).Trim()
}
## And finally cast that hashtable to a PSCustomObject
[PSCustomObject] $resultObject
}
}Output looks like this...
C:\»Get-O365Outages
Date Started Ended Duration
---- ------- ----- --------
January 29 2019 15:05 15:07 00:02:17
January 25 2019 21:35 22:37 01:02:28
January 25 2019 21:00 21:01 00:01:17
January 25 2019 12:05 14:28 02:23:38
January 25 2019 09:00 12:00 02:59:40
January 24 2019 22:20 08:48 10:28:29
January 24 2019 09:40 22:06 12:26:25
January 17 2019 15:00 15:02 00:02:41
November 28 2018 15:40 15:43 00:03:10
November 27 2018 17:20 17:33 00:13:13
November 27 2018 15:00 16:10 01:10:01
November 27 2018 14:20 14:38 00:18:24
November 27 2018 11:20 11:39 00:19:05
November 26 2018 17:00 17:18 00:18:19
November 26 2018 12:35 14:26 01:50:55
November 19 2018 21:01 02:03 05:02:25
November 19 2018 10:05 20:54 10:49:13
November 19 2018 08:35 09:27 00:52:00
November 13 2018 18:30 19:19 00:49:02
November 06 2018 12:20 12:21 00:01:03
October 12 2018 09:00 09:11 00:11:02
October 11 2018 16:55 21:38 04:43:20
October 05 2018 17:00 17:00 00:00:01And that joke-name command:
C:\»write-host "Todays Office365 is currently known as Office$(365-(Get-O365Outages | ? { $_.date -match (Get-Date).Year} | select -unique date).count)"
Todays Office365 is currently known as Office361r/PowerShell • u/rschiefer • Jan 19 '17
Learn Powershell in 5 Painless Steps - Storage
r/PowerShell • u/backdoor_boy • Apr 12 '26
Solved Is it worth learning PowerShell?
I’ve previously used Linux, where things felt very straightforward. Due to various reasons, I’m planning to stay on Windows for now. Since I’m here, I’d like to automate different tasks and deepen my understanding of Windows.
Because of my Linux background, I used the terminal a lot and really enjoyed it. Windows, on the other hand, feels much more GUI-oriented, with less emphasis on the command line. I’ve also briefly looked into PowerShell, and honestly, it feels a bit strange to me.
At this point, I’m not sure whether it’s worth investing time into learning it. The command structure, constant interaction with system services (and sometimes the internet), and the overall behavior of the terminal feel unusual.
Compared to Linux, it seems quite weird (to put it mildly). I assume that if I spend more time with it, I’ll understand its design and decisions better—but I’m still unsure.
So I wanted to ask: is it actually worth it?
EDITED:
I’m definitely going to start learning PowerShell. As I understand it, over the next few years, it will definitely pay for itself.
There were also comments about Azure, servers, and cloud services. I don’t plan on becoming a sysadmin and, for now, I only use my personal computer and maybe a laptop. The Microsoft ecosystem seems strange, but I’m getting more and more used to it, despite my dislike of big corporations (which is ironic).
Also, thank you for the quick feedback. That was incredibly kind of you. I’m just starting to get involved in the Windows community, and specifically in PowerShell, so this warmth really surprised and delighted me. Maybe I spend too much time in the toxic parts of the internet.
r/PowerShell • u/techbloggingfool_com • May 15 '22
I got tired of looking up group membership details for people that don't have access to ADUC. I used Powershell to make a GUI tool that anyone can use.
r/PowerShell • u/TheLazyAdministrator • Jul 20 '20
Free virtual PowerShell Conference with keynote speaker Jeffery Snover
r/PowerShell • u/[deleted] • Feb 16 '20
Script Sharing Can we start a PowerShell project of the day?
Kind of like on r/dailyprogrammer
It would be really nice honestly and a way for all of us to get better at this craft. :)
I am also really curious to see how others would tackle things. So, for example if the project of the day (potd) was "Create a simple script that pulls inventory info then sends them via email in a csv file"
I don't know, hopefully the mods approve.
r/PowerShell • u/premtech • Sep 06 '18
Help your users help the helpdesk. Introducing Show-Systeminfo.
r/PowerShell • u/TheLazyAdministrator • Apr 10 '18
Create a Real Time Interactive Dashboard for Office 365 Using PowerShell Universal Dashboard
r/PowerShell • u/krzydoug • Mar 29 '21
Script Sharing Get-LastLogon - get accurate last logon time for user
I see this task being brought up often and it seems each time someone learns the nuances of multiple DCs and lastlogon/lastlogontimestamp. Here are a couple of different functions you can use to check all DCs and get the newest last logon time.
Both functions are named the same. One depends on the AD module and the other does not.
AD Module required
Function Get-LastLogon (){
[cmdletbinding()]
Param(
[alias("UserName","User","SamAccountName","Name","DistinguishedName","UserPrincipalName","DN","UPN")]
[parameter(ValueFromPipeline,Position=0,Mandatory)]
[string[]]$Identity
)
begin{
$DCList = Get-ADDomainController -Filter * | Select-Object -ExpandProperty name
}
process{
foreach($currentuser in $Identity)
{
$filter = switch -Regex ($currentuser){
'=' {'DistinguishedName';break}
'@' {'UserPrincipalName';break}
' ' {'Name';break}
default {'SamAccountName'}
}
Write-Verbose "Checking lastlogon for user: $currentuser"
foreach($DC in $DCList)
{
Write-Verbose "Current domain controller: $DC"
$account = Get-ADUser -Filter "$filter -eq '$currentuser'" -Properties lastlogon,lastlogontimestamp -Server $DC
if(!$account)
{
Write-Verbose "No user found with search term '$filter -eq '$currentuser''"
continue
}
Write-Verbose "LastLogon : $([datetime]::FromFileTime($account.lastlogon))"
Write-Verbose "LastLogonTimeStamp: $([datetime]::FromFileTime($account.lastlogontimestamp))"
$logontime = $account.lastlogon,$account.lastlogontimestamp |
Sort-Object -Descending | Select-Object -First 1
if($logontime -gt $newest)
{
$newest = $logontime
}
}
if($account)
{
switch ([datetime]::FromFileTime($newest)){
{$_.year -eq '1600'}{
"Never"
}
default{$_}
}
}
Remove-Variable newest,lastlogon,account,logontime,lastlogontimestamp -ErrorAction SilentlyContinue
}
}
end{
Remove-Variable dclist -ErrorAction SilentlyContinue
}
}AD Module not required
Function Get-LastLogon (){
[cmdletbinding()]
Param(
[alias("UserName","User","SamAccountName","Name","DistinguishedName","UserPrincipalName","DN","UPN")]
[parameter(ValueFromPipeline,Position=0,Mandatory)]
[string[]]$Identity
)
begin{
$DCList = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().DomainControllers.name
}
process{
foreach($currentuser in $Identity)
{
$filter = switch -Regex ($currentuser){
'=' {'DistinguishedName';break}
'@' {'UserPrincipalName';break}
' ' {'Name';break}
default {'SamAccountName'}
}
Write-Verbose "Checking lastlogon for user: $currentuser"
foreach($DC in $DCList)
{
Write-Verbose "Current domain controller: $DC"
$ad = [ADSI]"LDAP://$dc"
$searcher = [DirectoryServices.DirectorySearcher]::new($ad,"($filter=$currentuser)")
$account = $searcher.findone()
if(!$account)
{
Write-Verbose "No user found with search term '$filter=$currentuser'"
continue
}
$logon = $($account.Properties.lastlogon)
$logontimestamp = $($account.Properties.lastlogontimestamp)
Write-Verbose "LastLogon : $([datetime]::FromFileTime($logon))"
Write-Verbose "LastLogonTimeStamp : $([datetime]::FromFileTime($logontimestamp))"
$logontime = $($logon,$lastlogontimestamp |
Sort-Object -Descending | Select-Object -First 1)
if($logontime -gt $newest)
{
$newest = $logontime
}
}
if($account)
{
switch ([datetime]::FromFileTime($newest)){
{$_.year -eq '1600'}{
"Never"
}
default{$_}
}
}
Remove-Variable newest,account,lastlogon,logon,logontime,lastlogontimestamp -ErrorAction SilentlyContinue
}
}
end{
Remove-Variable dclist -ErrorAction SilentlyContinue
}
}You can provide samaccountname, UPN, DN, or name. Unless you're one of those that has samaccountnames with spaces (yeah I didn't think that was possible until I encountered it.)
If you add the -Verbose switch you'll see the different values for both lastlogon and lastlogontimestamp for each DC. LastLogonDate is just a user friendly, already formatted representation of LastLogonTimeStamp.
This should demonstrate just how different these values can be from property to property, DC to DC.
Just for completeness you can add to existing calls like this.
Get-ADUser Someone | Select-Object *,@{n='LastLogon';e={Get-LastLogon $_}}r/PowerShell • u/Arcontar • Mar 24 '20
Script Sharing Windows Virtual Desktop - deployment tutorial
If you need to set up WVD (Windows Virtual Desktop) on Azure for your remote workers and want to do it with ease this may help you:
https://www.mczerniawski.pl/azure/wvd-how-to/
This is not another 'demo' tutorial (all global admins), but looks how to do it in real production. You'll be able to set it up, configure basic monitoring and finally clean it up, all with PowerShell