r/PowerShell • • Jun 23 '25

Using JSON for PowerShell has unlocked workstation automation for me.

261 Upvotes

I know there’s better tools for automating deployments, but I work for a big MSP and I don’t get direct access to those tools. But I am a big fan of Infrastructure as code, and I’m close to applying that to windows deployments. To the PS pros, I’m sure JSON is no big deal, but I’m having fun with it. I think I’m going to end up using these principles to extend out of workstation deployment into other IaC projects.


r/PowerShell • • May 24 '24

psDrugWars: A ridiculous PowerShell-based game inspired by 'Drug Wars' NSFW

260 Upvotes

https://github.com/dpo007/psDrugWars

I was looking to create something with 0 pressure, in my spare time.
This is what I came up with.

Do not expect genius programming, or groundbreaking code you should base a CS dissertation on. ;)

Enjoy!


r/PowerShell • • Feb 10 '19

Made a suite of PowerShell GUI Spelling games for my kids

Post image
260 Upvotes

r/PowerShell • • Nov 20 '20

PowerShell now supports 3D graphics

258 Upvotes

I got laid off at the start of Covid. During my unemployment, I kept busy by working on a project I call "DDD" (3D). DDD is a module that makes points, vectors, and matrices data types that can be displayed by piping them to an Out-3d command.

I got my project to a point where I can demo it and you can try it out too. I wrote about the preview release in my blog:

http://www.davidlenihan.com/2020/11/08/preview-release-of-ddd/


r/PowerShell • • Sep 16 '20

Information 11 PowerShell Automatic Variables Worth Knowing

Thumbnail
koupi.io
258 Upvotes

r/PowerShell • • Oct 12 '19

Misc List of Best Online Courses to Learn Powershell

Thumbnail
blog.coursesity.com
258 Upvotes

r/PowerShell • • May 22 '20

Information Fast LAN scanner, finds hosts on a /24 in under a second, even if the firewall is blocking pings

257 Upvotes

Driven by a previous post I wrote on ICMP, I've spent a bunch of time looking at reliably detecting devices on a network that may have firewalls blocking pings. There's a bunch of other tools that do this (arpping for one), but I haven't seen anything in PowerShell. Ended up with a pretty cool solution that can scan a whole /24 in well under a second.

https://xkln.net/blog/layer-2-host-discovery-with-powershell-in-under-a-second/

Discovered a bunch of other interesting stuff in the process, that's in there too... how long you do think Start-Sleep -Milliseconds 1 takes? :)

Edit: This seems to be getting a bit of interest, so to make it a more convenient I've put it up on GitHub and PowerShell Gallery.


r/PowerShell • • Dec 08 '22

Information ChatGPT is scary good.

253 Upvotes

If you haven’t tried it yet, do it.

https://chat.openai.com/chat

It just helped me solve an issue where I couldn’t think of a way to structure some data.

I then I asked if it was the best method and it gave me a better solution using json.net.

Finally I asked it how the method differed and it explained it incredibly well.

I’m gob smacked!!


r/PowerShell • • Nov 24 '21

Learn PowerShell in a Month of Lunches 4th Edition in 2022!

Thumbnail
manning.com
248 Upvotes

r/PowerShell • • Sep 08 '19

Script Sharing What do we say to health checking Active Directory?

247 Upvotes

Some time ago I've decided I'm a bit too lazy for manual verification of my Active Directory when it comes to doing Health Checks. I've caught myself a few times where I've configured 4 out of 5 Domain Controllers thinking everything is running great. While there are "pay" tools on the market I've usually no budget. And when you search for Active Directory Health Checks you can find a lot of blog posts covering Active Directory Health Checks. However, everyone treats every health check separately. If you want to test 20 different things you're gonna spend next 8 hours doing just that. And when you're done you should start all over the next day because something may have changed.

I wrote a PowerShell module called Testimo which bundles a lot of Active Directory checks and make it easy to expand on. It targets Forest/Domain and all it's Domain Controllers. It has reporting built-in. It's able to work ad-hoc to asses someone else directory and find what's misconfigured, but also has advanced configured which can test your AD against given specific settings.

Following "health" checks are added for now. I do intend to add more as I go. It's quite easy to add more sources/tests so if you wanna help out - please do. Of course, I may have done a few misconfigurations, some errors while putting it all together - so make sure to let me know via GitHub issues if you think some settings are incorrect and should be changed.

  • Forest Backup – Verify last backup time should be less than X days

  • Forest Replication – Verify each DC in replication site can reach other replication members

  • Forest Optional Features – Verify Optional Feature Recycle Bin should be Enabled

  • Forest Optional Features- Verify Optional Feature Privileged Access Management Feature should be Enabled

  • Forest Optional Features – Verify Optional Feature Laps should be enabled Configured

  • Forest Sites Verification Verify each site has at least one subnet configured

  • Forest Sites Verification Verify each site has at least one domain controller configured

  • Forest Site Links – Verify each site link is automatic

  • Forest Site Links – Verify each site link uses notifications

  • Forest Site Links- Verify each site link does not use notifications

  • Forest Roles Verify each FSMO holder is reachable

  • Forest Orphaned/Empty Admins – Verify there are no Orphaned Admins (users/groups/computers)

  • Forest Tombstone Lifetime – Verify Tombstone lifetime is greater or equal 180 days

  • Domain Roles Verify each FSMO holder is reachable

  • Domain Password Complexity Requirements – Verify Password Complexity Policy should be Enabled

  • Domain Password Complexity Requirements – Verify Password Length should be greater than X

  • Domain Password Complexity Requirements – Verify Password Threshold should be greater than X

  • Domain Password Complexity Requirements – Verify Password Lockout Duration should be greater than X minutes

  • Domain Password Complexity Requirements – Verify Password Lockout Observation Window should be greater than X minutes

  • Domain Password Complexity Requirements – Verify Password Minimum Age should be greater than X

  • Domain Password Complexity Requirements – Verify Password History Count should be greater than X

  • Domain Password Complexity Requirements – Verify Password Reversible Encryption should be Disabled

  • Domain Trust Availability – Verify each Trust status is OK

  • Domain Trust Unconstrained TGTDelegation – Verify each Trust TGTDelegation is set to True

  • Domain Kerberos Account Age – Verify Kerberos Last Password Change Should be less than 180 days

  • Domain Groups: Account Operators – Verify Group is empty

  • Domain Groups: Schema Admins – Verify Group is empty

  • Domain User: Administrator – Verify Last Password Change should be less than 360 days or account disabled

  • Domain DNS Forwarders – Verify DNS Forwarders are identical on all DNS nodes

  • Domain DNS Scavenging Primary DNS Server – Verify DNS Scavenging is set to X days

  • Domain DNS Scavenging Primary DNS Server – Verify DNS Scavenging State is set to True

  • Domain DNS Scavenging Primary DNS Server – Verify DNS Scavenging Time is less than X days

  • Domain DNS Zone Aging – Verify DNS Zone Aging is set

  • Domain Well known folder – UsersContainer  Verify folder is not at it's defaults.

  • Domain Well known folder – ComputersContainer  Verify folder is not at it's defaults.

  • Domain Well known folder – DomainControllersContainer Verify folder is at it's defaults.

  • Domain Well known folder – DeletedObjectsContainer Verify folder is at it's defaults.

  • Domain Well known folder – SystemsContainer Verify folder is at it's defaults.

  • Domain Well known folder – LostAndFoundContainer Verify folder is at it's defaults.

  • Domain Well known folder – QuotasContainer Verify folder is at it's defaults.

  • Domain Well known folder – ForeignSecurityPrincipalsContainer Verify folder is at it's defaults.

  • Domain Orphaned Foreign Security Principals – Verify there are no orphaned FSP objects.

  • Domain Orphaned/Empty Organizational Units – Verify there are no orphaned Organizational Units

  • Domain Group Policy Missing Permissions – Verify Authenticated Users/Domain Computers are on each and every Group Policy

  • Domain DFSR Sysvol – Verify SYSVOL is DFSR

  • Domain Controller Information – Is Enabled

  • Domain Controller Information – Is Global Catalog

  • Domain Controller Service Status – Verify all Services are running

  • Domain Controller Service Status – Verify all Services are set to automatic startup

  • Domain Controller Service Status (Print Spooler) – Verify Print Spooler Service is set to disabled

  • Domain Controller Service Status (Print Spooler) – Verify Print Spooler Service is stopped

  • Domain Controller Ping Connectivity – Verify DC is reachable

  • Domain Controller Ports – Verify Following ports 53, 88, 135, 139, 389, 445, 464, 636, 3268, 3269, 9389 are open

  • Domain Controller RDP Ports – Verify Following ports 3389 (RDP) is open

  • Domain Controller RDP Security – Verify NLA is enabled

  • Domain Controller LDAP Connectivity – Verify all LDAP Ports are open

  • Domain Controller LDAP Connectivity – Verify all LDAP SSL Ports are open

  • Domain Controller Windows Firewall – Verify windows firewall is enabled for all network cards

  • Domain Controller Windows Remote Management – Verify Windows Remote Management identification requests are managed

  • Domain Controller Resolves internal DNS queries – Verify DNS on DC resolves Internal DNS

  • Domain Controller Resolves external DNS queries – Verify DNS on DC resolves External DNS

  • Domain Controller Name servers for primary domain zone Verify DNS Name servers for primary zone are identical

  • Domain Controller Responds to PowerShell Queries Verify DC responds to PowerShell queries

  • Domain Controller TimeSettings – Verify PDC should sync time to external source

  • Domain Controller TimeSettings – Verify Non-PDC should sync time to PDC emulator

  • Domain Controller TimeSettings – Verify Virtualized DCs should sync to hypervisor during boot time only

  • Domain Controller Time Synchronization Internal – Verify Time Synchronization Difference to PDC less than X seconds

  • Domain Controller Time Synchronization External – Verify Time Synchronization Difference to pool.ntp.org less than X seconds

  • Domain Controller Disk Free – Verify OS partition Free space is at least X %

  • Domain Controller Disk Free – Verify NTDS partition Free space is at least X %

  • Domain Controller Operating System – Verify Windows Operating system is Windows 2012 or higher

  • Domain Controller Windows Updates – Verify Last patch was installed less than 60 days ago

  • Domain Controller SMB Protocols – Verify SMB v1 protocol is disabled

  • Domain Controller SMB Protocols – Verify SMB v2 protocol is enabled

  • Domain Controller SMB Shares – Verify default SMB shares NETLOGON/SYSVOL are visible

  • Domain Controller DFSR AutoRecovery – Verify DFSR AutoRecovery is enabled

  • Domain Controller Windows Roles and Features – Verify Windows Features for AD/DNS/File Services are enabled

I welcome all good/bad feedback.

- blog post with description: https://evotec.xyz/what-do-we-say-to-health-checking-active-directory/

- sources: https://github.com/EvotecIT/Testimo

It's an alpha product - but I've tested it on 3-4 AD's I have and so far it works ok. I've probably missed some things so if you find some bugs please let me know.


r/PowerShell • • Oct 31 '21

Who uses Visual Studio Code for PowerShell Scripting?

246 Upvotes

I personally do, but only for typing scripts. I then copy code into ISE and run it on Sandbox environments.

What does everyone else do? What settings do you use if you use VS Code?


r/PowerShell • • Dec 08 '20

Information New Microsoft Learn module: Introduction to PowerShell 🎓

Thumbnail
docs.microsoft.com
244 Upvotes

r/PowerShell • • Nov 07 '19

Powershell top ten for growth in Github usage(154%); beating out Python and Go in growth(%) from 2018-2019.

Thumbnail
octoverse.github.com
244 Upvotes

r/PowerShell • • May 12 '19

What do we say to writing Active Directory documentation?

244 Upvotes

I wanted to introduce you today to my new PowerShell module. Actually a couple of them, and to remind you a bit about my other PowerShell modules. Hope you like this one. This PowerShell module is able to extract Active Directory data as can be seen below. If you want to find out more: https://evotec.xyz/what-do-we-say-to-writing-active-directory-documentation/

It covers usage, code explanation, examples, and a few other things. Generally all the know/how (no ads/no pay software). It's free and open source. All of it.

Links to sources:

Example output

Small code sample 1:

$Forest = Get-WinADForestInformation -Verbose -PasswordQuality
$Forest

Small code sample 2:

$Forest = Get-WinADForestInformation -Verbose -PasswordQuality
$Forest.FoundDomains
$Forest.FoundDomains.'ad.evotec.xyz'

Small code sample 3:

$Forest = Get-WinADForestInformation -Verbose -PasswordQuality -DontRemoveSupportData -TypesRequired DomainGroups -Splitter "`r`n"
$Forest

You can install it using:

Install-Module PSWinDocumentation.AD -Force

Datasets covered by PSWinDocumentation.AD

  • ForestInformation

  • ForestFSMO

  • ForestGlobalCatalogs

  • ForestOptionalFeatures

  • ForestUPNSuffixes

  • ForestSPNSuffixes

  • ForestSites

  • ForestSites1

  • ForestSites2

  • ForestSubnets

  • ForestSubnets1

  • ForestSubnets2

  • ForestSiteLinks

  • ForestDomainControllers

  • ForestRootDSE

  • ForestSchemaPropertiesUsers

  • ForestSchemaPropertiesComputers

  • DomainRootDSE

  • DomainRIDs

  • DomainAuthenticationPolicies

  • DomainAuthenticationPolicySilos

  • DomainCentralAccessPolicies

  • DomainCentralAccessRules

  • DomainClaimTransformPolicies

  • DomainClaimTypes

  • DomainFineGrainedPolicies

  • DomainFineGrainedPoliciesUsers

  • DomainFineGrainedPoliciesUsersExtended

  • DomainGUIDS

  • DomainDNSSRV

  • DomainDNSA

  • DomainInformation

  • DomainControllers

  • DomainFSMO

  • DomainDefaultPasswordPolicy

  • DomainGroupPolicies

  • DomainGroupPoliciesDetails

  • DomainGroupPoliciesACL

  • DomainOrganizationalUnits

  • DomainOrganizationalUnitsBasicACL

  • DomainOrganizationalUnitsExtendedACL

  • DomainContainers

  • DomainTrustsClean

  • DomainTrusts

  • DomainBitlocker

  • DomainLAPS

  • DomainGroupsFullList

  • DomainGroups

  • DomainGroupsMembers

  • DomainGroupsMembersRecursive

  • DomainGroupsSpecial

  • DomainGroupsSpecialMembers

  • DomainGroupsSpecialMembersRecursive

  • DomainGroupsPriviliged

  • DomainGroupsPriviligedMembers

  • DomainGroupsPriviligedMembersRecursive

  • DomainUsersFullList

  • DomainUsers

  • DomainUsersCount

  • DomainUsersAll

  • DomainUsersSystemAccounts

  • DomainUsersNeverExpiring

  • DomainUsersNeverExpiringInclDisabled

  • DomainUsersExpiredInclDisabled

  • DomainUsersExpiredExclDisabled

  • DomainAdministrators

  • DomainAdministratorsRecursive

  • DomainEnterpriseAdministrators

  • DomainEnterpriseAdministratorsRecursive

  • DomainComputersFullList

  • DomainComputersAll

  • DomainComputersAllCount

  • DomainComputers

  • DomainComputersCount

  • DomainServers

  • DomainServersCount

  • DomainComputersUnknown

  • DomainComputersUnknownCount

  • DomainPasswordDataUsers

  • DomainPasswordDataPasswords

  • DomainPasswordDataPasswordsHashes

  • DomainPasswordClearTextPassword

  • DomainPasswordClearTextPasswordEnabled

  • DomainPasswordClearTextPasswordDisabled

  • DomainPasswordLMHash

  • DomainPasswordEmptyPassword

  • DomainPasswordWeakPassword

  • DomainPasswordWeakPasswordEnabled

  • DomainPasswordWeakPasswordDisabled

  • DomainPasswordWeakPasswordList

  • DomainPasswordDefaultComputerPassword

  • DomainPasswordPasswordNotRequired

  • DomainPasswordPasswordNeverExpires

  • DomainPasswordAESKeysMissing

  • DomainPasswordPreAuthNotRequired

  • DomainPasswordDESEncryptionOnly

  • DomainPasswordDelegatableAdmins

  • DomainPasswordDuplicatePasswordGroups

  • DomainPasswordHashesWeakPassword

  • DomainPasswordHashesWeakPasswordEnabled

  • DomainPasswordHashesWeakPasswordDisabled

  • DomainPasswordStats

And just a small update on my Find-Events command... I've added one more report Organizational Unit Changes (move/add/remove). So the default list now covers:

  • ADComputerChangesDetailed

  • ADComputerCreatedChanged

  • ADComputerDeleted

  • ADGroupChanges

  • ADGroupChangesDetailed

  • ADGroupCreateDelete

  • ADGroupEnumeration

  • ADGroupMembershipChanges

  • ADGroupPolicyChanges

  • ADLogsClearedOther

  • ADLogsClearedSecurity

  • ADUserChanges

  • ADUserChangesDetailed

  • ADUserLockouts

  • ADUserLogon

  • ADUserLogonKerberos

  • ADUserStatus

  • ADUserUnlocked

  • ADOrganizationalUnitChangesDetailed (added in 2.0.10)

I've also added Credentials parameter which should provide a way for you to use a command from normal user PowerShell prompt. If you have no clue about that command yet - have a read here: https://evotec.xyz/the-only-powershell-command-you-will-ever-need-to-find-out-who-did-what-in-active-directory/ otherwise:

Update-Module PSWinReportingV2

Enjoy :-)


r/PowerShell • • Apr 13 '17

Using powershell for office pranks

244 Upvotes

Have a coworker who habitually leaves their workstation unlocked? Want to mess with them? Make this script a scheduled task on their computer in order to have their workstation tell them a random fact about cats at random times throughout the day.

#Run this every 1/2 hour and in an 8 hour work day there will be approximately 3 times per day that your victim hears a cat fact
if ((Get-Random -Maximum 10000) -lt 1875) {
    Add-Type -AssemblyName System.Speech
    $SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
    $CatFact = (ConvertFrom-Json (Invoke-WebRequest -Uri 'http://catfacts-api.appspot.com/api/facts')).facts
    $SpeechSynth.Speak("did you know?")
    $SpeechSynth.Speak($CatFact)
}    

Who else has powershell hijinks to share?


r/PowerShell • • Mar 14 '18

Script Sharing I made this script that automatically create a AD user, assign O365 licenses, Shared mailboxes, O365 Groups, Ad Groups and O365 and AD Distribution list. Tell me what you think

243 Upvotes
#This is my first real script and I am really proud of it. Please tell me what you think.

#You need to have Active Directory modules install and Global Admin Access to Office 365
#You also need an AD "OU" that you have synchronized in Azure AD Connect

Import-Module ActiveDirectory

$MsolCreds = Get-Credential -Credential '****@domain.com'

Write-Host "What is the user givenname?" -ForegroundColor Green
$Givenname = Read-Host  
Write-Host "What is the user surname?" -ForegroundColor Green
$Surname = Read-host
Write-Host "What is the user department" -ForegroundColor Green
$Department = Read-Host
Write-Host "What is the user job description" -ForegroundColor Green
$Description = Read-Host
Write-Host "Copy access from?" -ForegroundColor Green
$CopyAccess =  Read-Host 
Write-Host "New user password?" -ForegroundColor Green
$Password = Read-Host -AsSecureString
$Password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password))

#Now for the Username you can customize to your needs, this one does 1st letter of $Givename plus $Surname

$Username = $Givenname.Substring(0, 1)+$Surname
$Email = "[email protected]"
$defpassword = (ConvertTo-SecureString "$Password" -AsPlainText -force)
$CopiedAccess = "[email protected]"

$OU = "Your New User OU"

New-ADUser -SamAccountName $Username -AccountPassword $defpassword -UserPrincipalName "$Email" -Surname $Surname -GivenName $Givenname -EmailAddress "$Email" -Enabled $True -ChangePasswordAtLogon $False  -DisplayName "$GivenName $Surname" -Name "$GivenName $Surname" -Path $OU -Department $Department -Description $Description -OfficePhone "(888)888-8888"

#For this next step to work, you need to have enabled PSremoting in the server

$AADServer = "Your server where Azure AD Connect is installed"
$Session = New-PSSession -computerName $AADServer
Invoke-Command -Session $Session -ScriptBlock {Start-ADSyncSyncCycle -Policytype Delta}
Remove-PSSession $Session

Get-ADUser -Identity $CopyAccess -Properties memberof |
Select-Object -ExpandProperty memberof |
Add-ADGroupMember -Members $Username  

Remove-PSSession $Session

Start-Sleep -Seconds 75

#Here you need to find your O365 country code and the licenses you want to use with Get-AccountSku. Me I only have one I use.
#If you want I can probalby easily get the license from the user thet this on is copied from and assign them automatically
#Of course you have to provision licenses before you exeute the script


Connect-MsolService -Credential $MsolCreds
Set-MsolUser -UserPrincipalName $Email -UsageLocation "CA"
Set-MsolUserLicense -UserPrincipalName $Email -AddLicenses "O365:License"

$MsolSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell -Credential $MsolCreds -Authentication Basic -AllowRedirection
Import-PSSession $MsolSession -AllowClobber

#This copies Shared Mailbox

$CopyMailbox = Get-Mailbox | 
Get-MailboxPermission -User $CopiedAccess |
Select-Object -ExpandProperty identity 
Foreach ($Mailbox in $CopyMailbox) {Add-MailboxPermission -AccessRights FullAccess -Identity $Mailbox -User $Email -InheritanceType All}

#This Copies O365 Distribution Lists

$CopyDLMailbox = Get-Mailbox $CopiedAccess
$DN = $CopyDLMailbox.DistinguishedName
$Filter = "Members -like ""$DN"""
$DLMailbox = Get-Recipient -ResultSize Unlimited -Filter $Filter -RecipientTypeDetails MailUniversalDistributionGroup |
Select-Object -ExpandProperty Identity
ForEach ($IDMailbox in $DLMailbox) {Add-DistributionGroupMember -Identity "$IDMailbox" -Member "$Email" -BypassSecurityGroupManagerCheck} 

#This Copies O365 Office365 Groups

$CopyO365Mailbox = Get-Mailbox $CopiedAccess
$DNO365 = $CopyO365Mailbox.DistinguishedName
$FilterO365 = "Members -like ""$DNO365"""
$O365Mailbox = Get-Recipient -ResultSize Unlimited -Filter $FilterO365 -RecipientTypeDetails GroupMailbox |
Select-Object -ExpandProperty Identity
ForEach ($MailboxO365 in $O365Mailbox) {Add-UnifiedGroupLinks -Identity "$MailboxO365" -LinkType Members -Links "$Email"} 

#If you think it is missing something please tell me

r/PowerShell • • May 05 '21

Script Sharing Happy Birthday Song With Beep Tones in Powershell Script (My Cake day)

242 Upvotes
# Happy Birthday song with Beep tones in Powershell Script
cls
$BeepList = @(
    @{ Pitch = 1059.274; Length = 300; };
    @{ Pitch = 1059.274; Length = 200; };
    @{ Pitch = 1188.995; Length = 500; };
    @{ Pitch = 1059.274; Length = 500; };
    @{ Pitch = 1413.961; Length = 500; };
    @{ Pitch = 1334.601; Length = 950; };

    @{ Pitch = 1059.274; Length = 300; };
    @{ Pitch = 1059.274; Length = 200; };
    @{ Pitch = 1188.995; Length = 500; };
    @{ Pitch = 1059.274; Length = 500; };
    @{ Pitch = 1587.117; Length = 500; };
    @{ Pitch = 1413.961; Length = 950; };

    @{ Pitch = 1059.274; Length = 300; };
    @{ Pitch = 1059.274; Length = 200; };
    @{ Pitch = 2118.547; Length = 500; };
    @{ Pitch = 1781.479; Length = 500; };
    @{ Pitch = 1413.961; Length = 500; };
    @{ Pitch = 1334.601; Length = 500; };
    @{ Pitch = 1188.995; Length = 500; };
    @{ Pitch = 1887.411; Length = 300; };
    @{ Pitch = 1887.411; Length = 200; };
    @{ Pitch = 1781.479; Length = 500; };
    @{ Pitch = 1413.961; Length = 500; };
    @{ Pitch = 1587.117; Length = 500; };
    @{ Pitch = 1413.961; Length = 900; };
    );
# I Just added this For..loop in order to listen the beep tones twice (-_°)
For ($i=1; $i -le 2; $i++) {
    foreach ($Beep in $BeepList) {
        [System.Console]::Beep($Beep['Pitch'], $Beep['Length']);
    }
}

r/PowerShell • • Jun 11 '23

News r/PowerShell Blackout June 12-14th

239 Upvotes

With community feedback, PowerShell will be going Private on June 12th through the 14th to participate in the coordinated protest of Reddit API changes.

If you have any questions, feel free to message the mod team.


r/PowerShell • • Jun 15 '19

A general IT tool with GUI I created in PowerShell

239 Upvotes

Hello everyone,

I picked up PowerShell in the last year and pieced together a little tool that served as a project to learn as well as something I used daily and wanted to share what I built. I removed my companies name and internal links, so you may find specific buttons or links that won't function - for example the Active Directory related stuff would need to be pointed at your AD. I'm not an expert but I think there is some useful/fun things in there that someone else may be able to use in their own IT environment. Would love to hear any comments or thoughts on it!

Some of my favorite functions..

- The Local Admin tool lets you add a user to a remote PC's local admin group AND set a timer to remove them (via task scheduler)

- The Message button sends a pop-up message to a remote computer

- The speech button.. un-mutes, sets volume to 100%, and sends a customer text-to-speech message to a remote computer. For legitimate business functions only of course.

- The compare user groups button lets you compare 2 AD user's and if you want you can add user 1 into all of user 2's groups (mirror access).

Photo of the tool's different tabs: https://imgur.com/a/eYQXuPg

The first 3 tools on the tool tab are unfinished I think.. been a while.. but may be some good code there anyway. Let me know what you think!

Code: https://pastebin.com/Af1qEvgu


r/PowerShell • • Mar 07 '20

I'm a P.S. Noob who created a 750+ line script that is now mission critical. Now it is too slow for peoples liking, even tho it saves us hours a week

238 Upvotes

This script allows us to locate any of our wifi enabled devices by its MAC address at anyone of 12 remote locations. It does this by connecting to our wifi system's API. This script turns what use to be a 10-30 min process per device, into a 15-20 second process. But now the 15-20 seconds is too long for people to wait, which is the reason I'm posting here. I know I am probably doing several things very inefficiently. Most actions are repeated 12 times (once for each site) which gives the script its length. Also the meraki api can handle up to 5 api calls a second. I'm only running one at a time. If anyone can point out what my inefficiencies are, and can offer me any guidance on making this script more efficient, i'd greatly appreciate it!

Here is what it basically does (not every step is listed, these are the majors things)

  1. Gets mac address from text file (another program puts it there)

  2. Connects to api to check if mac address is present on site networks x12 ( once for each site, as each site has a unique api connection it has to do)

  3. writes the results to a text file x12

  4. references text files to get the mac of AP it connected to x12

  5. gets unix time of last connection x12

  6. goes through process of changing unix time to normal time x12

  7. reconnects to api x12 (this time to get access point info and not device info)

  8. goes through process to get the name of AP x12

  9. throws it all into a pretty html table that tells us the last access point it connected to and the time of the connection

Here is a link to the script - https://pastebin.com/x5bbGW9t

Edit: Thank you for all the help I’m getting! So many helpful posts and suggestions that have really taught me a lot and that have given me many areas to improve in


r/PowerShell • • Mar 27 '22

Script Sharing I made a simple PowerShell script to organize messy folders

237 Upvotes

r/PowerShell • • Aug 13 '18

Some of my weekends

Post image
235 Upvotes

r/PowerShell • • Jul 06 '17

Not what I expected

Post image
234 Upvotes

r/PowerShell • • Sep 02 '20

Script Sharing Visually display Active Directory Nested Group Membership using PowerShell

233 Upvotes

It's me again. Today you get 4 cmdlets:

  • Get-WinADGroupMember

  • Show-WinADGroupMember

  • Get-WinADGroupMemberOf

  • Show-WinADGroupMemberOf

Get cmdlets display group membership in console so you can work with it as you like. They show things like all members and nested members along with their groups, nesting level, whether group nesting is circular, what type of group it is, whether members of that group are cross-forest and what is their parent group within nesting, and some stats such as direct members, direct groups, indirect members and total members on each group level.

This allows for complete analysis of nested group membership. On top of that the Show commands display it all in nice Table that's exportable to Excel or CSV, Basic Diagram and Hierarchical diagrams making it super easy to understand how bad or good (very rarely) nesting is. They also allow to request more than one group at the same time so you can display them side by side for easy viewing. And on top of that they also provide Summary where you can put two or more groups on single diagram so you can analyze how requested groups interact with each other.

In other words - with one line of PowerShell you get to analyze your AD structure in no time :-)

Here's the blog post: https://evotec.xyz/visually-display-active-directory-nested-group-membership-using-powershell/

Sources/Issues/Feature Requests: https://github.com/EvotecIT/ADEssentials

Enjoy :-)