r/usefulscripts • u/mindlessgrenade • Nov 02 '20
r/usefulscripts • u/mindlessgrenade • May 25 '20
[bash] github.com's password based auth will be deprecated November, helpful github bash examples
r/usefulscripts • u/MadBoyEvo • Feb 19 '20
[PowerShell] 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/usefulscripts • u/tonydacto • Oct 18 '17
Run a powershell script as a local administrator
All you will need to do is Add the below code to the beginning of your script It great and comes in handy when you have scripts that need to be run as local admin
https://www.petri.com/run-powershell-scripts-with-administrative-privileges
param([switch]$Elevated)
function Test-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Test-Admin) -eq $false) {
if ($elevated)
{
# tried to elevate, did not work, aborting
}
else {
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}
exit
}
'running with full privileges'r/usefulscripts • u/Cornbeetle • Dec 09 '15
[BATCH] Tetris! A real Tetris game written in pure batch. (by Antonio Perez Ayala)
r/usefulscripts • u/vocatus • Nov 06 '14
[BATCH] Tron v4.0.0 (2014-11-06) (ProcessKiller; nircmd; -e flag; significant bugfixes)
NOTE: Tron now has it's own subreddit. Check it out at /r/TronScript
Background
Tron is a script that "fights for the User"; basically automates a bunch of scanning/disinfection/cleanup tools on a Windows system. I got tired of running these utilities manually and decided to just script the whole thing. I hope this helps other techs and admins.
Stages of Tron:
0. Prep: rkill, ProcessKiller, TDSSKiller, registry backup, WMI repair, sysrestore clean, oldest VSS set purge
Tempclean: TempFileCleanup,
CCLeaner,BleachBit,backup & clear event logs,Windows Update cache cleanup,Internet Explorer cleanupDisinfect:
RogueKiller,Vipre Rescue Scanner,Sophos Virus Removal Tool,Malwarebytes Anti-Malware,DISM image check (Win8/2012 only),sfc /scannowDe-bloat: removes a variety of OEM bloatware; customizable list is in
\resources\stage_3_de-bloat\oem\programs_to_target.txt; Metro debloat (Win8/8.1/2012 only)Patch: Updates 7-Zip, Java, and Adobe Flash/Reader and disables nag/update screens (uses some of our PDQ packs); then installs any pending Windows updates
Optimize:
chkdsk(if necessary), Defrag%SystemDrive%(usually C:); skipped if system drive is an SSDManual stuff: Contains additional optional tools that can't currently be automated (
ComboFix,AdwCleaner,aswMBR,autoruns, etc.)
Saves a log to C:\Logs\tron.log (configurable).
Example Screenshots
Welcome Screen | New version detected | Help | Config dump | Dry run
Changelog (full changelog on Github)
v4.0.1 (2014-11-07)
+ tron.bat:annoyance: Add annoying disclaimer warning screen (sorry :-/). Accept with -e flag, or change associated EULA_ACCEPTED variable to yes to permanently accept+ stage_0_prep:feature: Add ProcessKiller utility. Nukes various userspace processes before starting. Thanks to/u/cuddlychops06+ stage_0_prep:feature: Add speak ability. Tron now audibly announces when it starts and finishes. Mute with the -q flag or the SHUT_UP variable. Depending on interest, may add ability to announce each stage as it begins and completes+ stage_0_prep:utility: Add nircmd.exe to support speak ability, among other things! stage_0_prep:bugfix: Fix logic error where we skipped calculating free hard drive space if the system drive was an SSD. Now detect free space regardless of disk type- stage_4_patch:cleanup: Remove all version-specific subfolders for Java, Flash, Reader, and Notepad++, and rename all .bat installers to be version-neutral. Should reduce number of places we need to update when a new version is released! misc:bugfix: tons of bugfixes, including MANY affecting Vista. Read the full changelog if you're interested in seeing what they were
Download
Three download options:
Primary: Mirror the BT Sync repo (get fixes/updates immediately) using the read-only key:
BYQYYECDOJPXYA2ZNUDWDN34O2GJHBM47
Make sure the settings for your Sync folder look like this (or this on the v1.3.x version).
Download a self-extracting .exe pack from one of the mirrors:
| Mirror | HTTP | HTTPS | Host |
|---|---|---|---|
| Official | link | link | /u/SGC-Hosting |
1 | link | link | /u/ellisgeek
2 | link | link | /u/danodemano
3 | link (geolocated) | --- | /u/andrewthetechie
4 | link | --- | /u/jamesrascal
3. Script only:
If you want to preview the latest code, the master script is available **[here on Github](https://github.com/vocatus/tron/blob/master/tron.bat)** (Note: this is *only* the script and doesn't include the utilities Tron relies on to function).Command-Line Support
Tron has full command-line support. All flags are optional, can be combined, and override their respective script default when used.
Usage: tron.bat [-a -c -d -e -m -o -p -r -s -v -x] | [-h]
Optional flags (can be combined):
-a Automatic mode (no welcome screen or prompts; implies -e)
-c Config dump (display current config. Can be used with other
flags to see what WOULD happen, but script will never execute
if this flag is used)
-d Dry run (run through script without executing any jobs)
-e Accept EULA (suppress display of disclaimer warning screen)
-m Preserve default Metro apps (don't remove them)
-o Power off after running (overrides -r)
-p Preserve power settings (don't reset power settings to default)
-r Reboot automatically (auto-reboot 30 seconds after completion)
-s Skip defrag (force Tron to ALWAYS skip Stage 5 defrag)
-v Verbose. Show as much output as possible. NOTE: Significantly slower!
-x Self-destruct. Tron deletes itself after running and leaves logs intact
Misc flags (must be used alone):
-h Display this help textIntegrity
checksums.txt contains SHA-256 checksums for every file and is signed with my PGP key (0x82A211A2; included). You can use this to verify package integrity if necessary.
Please suggest modifications and fixes; community input is helpful and appreciated.
Tips: 19B5mytMCqkEpAAW9f2NLjKEoHSndKdRBX
r/usefulscripts • u/MadBoyEvo • Oct 09 '22
[PowerShell] Easy way to send emails using Microsoft Graph API (Office 365) with PowerShell
Microsoft has now disabled basic auth for Office 365, with the minor exception of SMTP. While SMTP Basic Auth is not going away because of mostly legacy devices or applications, it's better to switch to oAuth 2.0 and Graph API as per Microsoft's recommendation.
The more significant issue is that Microsoft points you to Graph API documentation, specifically this link: https://learn.microsoft.com/en-us/graph/api/user-sendmail. If you want to upload attachments higher than 4MB, they send you to this link https://learn.microsoft.com/en-us/graph/outlook-large-attachments where after a brief moment, you decide to drop that idea and not send emails with larger attachments ;-)
Over one year ago, I wrote a PowerShell module called Mailozaurr, which simplifies sending emails with SMTP using BASIC Authentication, OAuth 2.0 and Graph API, or even SendGrid API. Last week I added functionality to send a that big attachment with Graph.
As Microsoft just disabled basic auth, I thought it would be a good idea to write a new blog post on how easy it is to replace Send-MailMessage with Send-EmailMessaage (part of the Mailozaurr module).
Blog post: https://evotec.xyz/easy-way-to-send-emails-using-microsoft-graph-api-office-365-with-powershell/ with examples/how-to and some configuration options and screenshots
Sources: https://github.com/EvotecIT/Mailozaurr (MIT license)
$Credential = ConvertTo-GraphCredential -ClientID $ClientID -ClientSecret $ClientSecret -DirectoryID $DirectoryID
# Sending email
Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = '[email protected]' } -To '[email protected]' `
-Credential $Credential -HTML $Body -Subject 'This is another test email 1' -Graph -Verbose -Priority High
# sending an email with From as a string (it won't matter for Exchange )
Send-EmailMessage -From '[email protected]' -To '[email protected]' `
-Credential $Credential -HTML $Body -Subject 'This is another test email 2' -Graph -Verbose -Priority LowThe only difference between using Standard SMTP and SMTP with Basic auth is renaming Send-MailMessage to Send-EmailMessage, adding a Graph switch, and changing SMTP Server, SMTP port to Graph API application which unfortunately requires some effort. But it's no longer necessary to play with what Microsoft offers as an alternative :-)
As part of the blog post, I'm also showing how you no longer have to use HTML/CSS to build nice-looking emails, and you can skip having to learn it, so it doesn't look ugly.
r/usefulscripts • u/MadBoyEvo • Jan 16 '22
[PowerShell] Mentioning users when sending notifications to Microsoft Teams using PowerShell
Just wanted to let you all know it's now possible to send notifications to Microsoft Teams using PowerShell and mention a specific person. I've modified my PowerShell module that makes it easy to do so.
Blog post with know-how: https://evotec.xyz/mentioning-users-in-notifications-using-psteams-powershell-module/
Sources: https://github.com/EvotecIT/PSTeams
And some code:
New-AdaptiveCard -Uri $Uri {
New-AdaptiveContainer {
New-AdaptiveTextBlock -Text 'Publish Adaptive Card schema' -Weight Bolder -Size Medium
New-AdaptiveColumnSet {
New-AdaptiveColumn -Width auto {
New-AdaptiveImage -Url "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg" -Size Small -Style person
}
New-AdaptiveColumn -Width stretch {
New-AdaptiveTextBlock -Text "Przemysław Kłys <at>Przemysław Kłys</at>" -Weight Bolder -Wrap
New-AdaptiveTextBlock -Text "Created {{DATE(2017-02-14T06:08:39Z, SHORT)}}" -Subtle -Spacing None -Wrap
}
}
}
New-AdaptiveContainer {
New-AdaptiveTextBlock -Text "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation." -Wrap
New-AdaptiveFactSet {
New-AdaptiveFact -Title 'Board:' -Value 'Adaptive Card'
New-AdaptiveFact -Title 'List:' -Value 'Backlog'
New-AdaptiveFact -Title 'Assigned to:' -Value 'Matt Hidinger'
New-AdaptiveFact -Title 'Due date:' -Value 'Not set'
}
}
# we need to tell PSTeams to match <at> tags to the user's profile using UPN or AAD ID
New-AdaptiveMention -Text 'Przemysław Kłys' -UserPrincipalName '[email protected]'
} -FullWidthEnjoy :-)
r/usefulscripts • u/MadBoyEvo • May 12 '19
[PowerShell] What do we say to writing Active Directory documentation?
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:
PSWinDocumentation.AD - https://github.com/EvotecIT/PSWinDocumentation.AD - the module that provides all the Active Directory data as one command.
Dashimo - https://github.com/EvotecIT/Dashimo - a module that is able to wrap that data into HTML
Emailimo - https://github.com/EvotecIT/Emailimo - a module that is able to wrap that data into Email and send it over
Documentimo - https://github.com/EvotecIT/Documentimo - a module that is able to wrap that data into WORD document (no word required)
Excelimo - https://github.com/EvotecIT/Excelimo - a module that is able to wrap that data into EXCEL document
Example output
HTML Version: https://evotec.xyz/wp-content/uploads/2019/05/DashboardActiveDirectory.html
DocX Version: https://evotec.xyz/wp-content/uploads/2019/05/Starter-AD.docx
Xlsx Version: https://evotec.xyz/wp-content/uploads/2019/05/Run-Demo02-1.xlsx (minimal)
Small code sample 1:
$Forest = Get-WinADForestInformation -Verbose -PasswordQuality
$ForestSmall 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"
$ForestYou can install it using:
Install-Module PSWinDocumentation.AD -ForceDatasets 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 PSWinReportingV2Enjoy :-)




r/usefulscripts • u/MadBoyEvo • Apr 01 '19
[PowerShell] Everything you wanted to know about Event Logs and then some
r/usefulscripts • u/vocatus • Dec 16 '22
[BATCH] Recursively convert all .rar and .zip files to .7z (max compression)
I surprisingly couldn't find a script for this anywhere, so I wrote one myself.
This script recursively converts all .rar and .zip archive files to the superior .7z format, set for highest compression.
Can specify formats to convert (in the VARIABLES section in the top of the script). Defaults are
.rarand.zipAfter each file is converted, the original archive is deleted, leaving only the new
.7zarchiveLogs by default to
c:\logs\(can be changed in the VARIABLES section)Starts from the directory it was launched from and recurses down subdirectories from that point
>> Script on Github <<
I used this script to convert the entire eXoDOS games package from Zip to 7-Zip, which saved GBs of space by the time it was done. Hope it's helpful!
r/usefulscripts • u/atoomepuu • May 24 '19
[PowerShell] Script to View and Delete Local Profiles
I've spent the last few days writing this. I'd very much appreciate any critiques or advice for improving it. And please let me know if it is helpful!
This script uses XAML to build a GUI to list profiles on a remote computer. You can select profiles and delete them. It uses CIM instances to get the profiles and remove them.
I got started on PowerShell GUIs by this post WPF GUIs for Beginners by /u/FarsideSC and this was my first real project with what I learned.
r/usefulscripts • u/MadBoyEvo • Feb 20 '20
[PowerShell] Active Directory DFS Health Check with PowerShell
Last few months I've been working on 2 PowerShell modules - ADEssentials and Testimo. One provides detailed, fully automated commands to deliver different AD cmdlets. The other one uses those to deliver automated reporting.
Extended information in the blog post: https://evotec.xyz/active-directory-dfs-health-check-with-powershell/
Sources for both:
With Get-WinADDFSHealth command you can a simple summary of your DFS Health

But also additional details you can expand on

Invoke-Testimo, on the other hand, delivers the results in form Pass/Fail making it easy to quickly asses if your DFS is working or not without spending more then 5 minutes per day on it.

And if you're really into the full report - Invoke-Testimo does that as well

But it also is able to do a lot more as you can tell it to run multiple reports at once:
Invoke-Testimo -Sources DCDFS,DCLDAP,DCLDAPInsecureBindings,DomainGroupPolicyMissingPermissions -ShowReportAnd that is just the tip of an iceberg.
Hope you like this one. Both ADEssentials and Testimo are under Active development.
r/usefulscripts • u/MadBoyEvo • Dec 29 '19
[PowerShell] Merging, splitting and creating PDF files
It's that time of the year where this will be my last blog post and module for 2019. I had this ready for a few weeks already but wanted to fix some minor bugs that were bugging me just a bit too much.
I was thinking that it would be great to add a new PSWrite module into my portfolio so today I'm adding (officially) PSWritePDF.
Long story: https://evotec.xyz/merging-splitting-and-creating-pdf-files-with-powershell/
Peek into what's in the long story:
Development happens on GitHub: https://github.com/EvotecIT/PSWritePDF so feel free to join in.
It's divided into two types:
Standalone functions such as Split-PDF, Merge-PDF or Convert-PDFtoText
Bundled functions working like PSWriteHTML where they are not supposed to be used separately mainly to create PDF files (for now - as I am not yet sure how to approach reading PDF
Some features:
Extract text from PDF
# Get all pages text
Convert-PDFToText -FilePath "$PSScriptRoot\Example04.pdf"
# Get page 1 text only
Convert-PDFToText -FilePath "$PSScriptRoot\Example04.pdf" -Page 1Merge two or more PDF files
$FilePath1 = "$PSScriptRoot\Input\OutputDocument0.pdf"
$FilePath2 = "$PSScriptRoot\Input\OutputDocument1.pdf"
$OutputFile = "$PSScriptRoot\Output\OutputDocument.pdf" # Shouldn't exist / will be overwritten
Merge-PDF -InputFile $FilePath1, $FilePath2 -OutputFile $OutputFileGet some details about PDF
$Document = Get-PDF -FilePath "C:\Users\przemyslaw.klys\OneDrive - Evotec\Support\GitHub\PSWritePDF\Example\Example01.HelloWorld\Example01_WithSectionsMix.pdf"
$Details = Get-PDFDetails -Document $Document
$Details | Format-List
$Details.Pages | Format-Table
Close-PDF -Document $DocumentSplit PDF
Split-PDF -FilePath "$PSScriptRoot\SampleToSplit.pdf" -OutputFolder "$PSScriptRoot\Output"Creating PDF - it works, but I guess it's not prime time ready. It's a bit ugly in how it looks.
New-PDF -MarginTop 200 {
New-PDFPage -PageSize A5 {
New-PDFText -Text 'Hello ', 'World' -Font HELVETICA, TIMES_ITALIC -FontColor GRAY, BLUE -FontBold $true, $false, $true
New-PDFText -Text 'Testing adding text. ', 'Keep in mind that this works like array.' -Font HELVETICA -FontColor RED
New-PDFText -Text 'This text is going by defaults.', ' This will continue...', ' and we can continue working like that.'
New-PDFList -Indent 3 {
New-PDFListItem -Text 'Test'
New-PDFListItem -Text '2nd'
}
}
New-PDFPage -PageSize A4 -Rotate -MarginLeft 10 -MarginTop 50 {
New-PDFText -Text 'Hello 1', 'World' -Font HELVETICA, TIMES_ITALIC -FontColor GRAY, BLUE -FontBold $true, $false, $true
New-PDFText -Text 'Testing adding text. ', 'Keep in mind that this works like array.' -Font HELVETICA -FontColor RED
New-PDFText -Text 'This text is going by defaults.', ' This will continue...', ' and we can continue working like that.'
New-PDFList -Indent 3 {
New-PDFListItem -Text 'Test'
New-PDFListItem -Text '2nd'
}
}
} -FilePath "$PSScriptRoot\Example01_WithSectionsMargins.pdf" -ShowSome screenshots


Enjoy ;-)
r/usefulscripts • u/MadBoyEvo • Apr 01 '19
[PowerShell] Meet Dashimo - PowerShell Generated Dashboard
r/usefulscripts • u/vocatus • Oct 21 '14
[BATCH] Tron v3.7.0 (2014-10-22) (add verbose & shutdown flags; add RogueKiller)
Background
Tron is a script that "fights for the User"; basically automates a bunch of scanning/disinfection/cleanup tools on a Windows system. I got tired of running these utilities manually on individual machines, and decided to just script the whole thing. I hope this helps other techs and admins.
Stages of Tron:
0. Prep: rkill, TDSSKiller, WMI repair, sysrestore clean, oldest VSS set purge
Tempclean: TempFileCleanup,
CCLeaner,BleachBit,backup & clear event logs,Windows Update cache cleanupDisinfect:
RogueKiller,Vipre Rescue Scanner,Sophos Virus Removal Tool,Malwarebytes Anti-Malware,DISM image check (Win8/2012 only),sfc /scannowDe-bloat: removes a variety of OEM bloatware; customizable list is in
\resources\stage_3_de-bloat\oem\programs_to_target.txt; removes default Metro apps (Win8/8.1/2012 only)Patch: Updates 7-Zip, Java, and Adobe Flash/Reader and disables nag/update screens (uses some of our PDQ packs); then installs any pending Windows updates
Optimize:
chkdsk(if necessary), Defrag%SystemDrive%(usually C:); skipped if system drive is an SSDManual stuff: Contains additional optional tools that can't currently be automated (
ComboFix,AdwCleaner,aswMBR,autoruns, etc.)
Saves a log to C:\Logs\tron.log (configurable).
Example Screenshots
Welcome Screen | New version detected | Help | Config dump | Dry run
Changelog (full changelog on Github)
v3.7.0 (2014-10-22)
! tron.bat:prep: Fix faulty disk health check (was exiting regardless what user chose). Thanks to/u/Tyrannosaurus_flex! tron.bat:date and time: Reset CUR_DATE after finishing virus scans, since they take so long and we sometimes cross into a new day (therefor leaving CUR_DATE incorrect). Thanks to/u/ScubaSteve* tron.bat:prep: Minor update to log header and trailer: Stamp what mode we're in (safe, safe with network, etc) and the location of the log file+ tron.bat:prep: Enable "legacy" boot menu on Windows 8 and up (re-enable F8 functionality)+ tron.bat:Feature: Add shutdown flag (-o) and corresponding DO_SHUTDOWN variable to poweroff system when Tron finishes. Overrides auto-reboot (-r) if set. Thanks to/u/Stealth5325and/u/Fogest+ tron.bat:Feature: Add verbose flag (-v) and corresponding VERBOSE variable. Displays, when possible, verbose/debug output from each program Tron calls (Sophos, Vipre, etc). NOTE: Tron will take much longer with this option enabled+ stage_2_disinfect:roguekiller: Add RogueKiller (CMD version). Thanks to/u/bodkov* stage_2_disinfect:mbam: Update MBAM link to reflect new installer/ stage_2_disinfect:DISM: Add /NoRestart flag to dism scan. It wasn't forcing a reboot, but added just in case it got any funny ideas* stage_4_patch:jre: Update JRE links to reflect new installers* stage_4_patch:jre: Update Adobe links to reflect new installers* Misc: updates for various Stage 6 tools
Download
Three download options:
Primary: Mirror the BT Sync repo (get fixes/updates immediately) using the read-only key:
BYQYYECDOJPXYA2ZNUDWDN34O2GJHBM47
Make sure the settings for your Sync folder look like this (or this if you're on the v1.3.x version).
Download a .7z pack from one of the mirrors:
| Mirror | HTTP | HTTPS | Host |
|---|---|---|---|
| Official | link | link | /u/SGC-Hosting |
1 | link | link | /u/ellisgeek
2 | --- | link | /u/danodemano
3 | link (geolocated) | --- | /u/andrewthetechie
4 | link | --- | /u/jamesrascal
3. Script only:
The master script (tron.bat) is available on Github here. Note: this is only the script and doesn't include the utilities Tron relies on to function. Simply downloading the script won't work - you need contents of the \resources folder and it must be organized how tron.bat expects.
Command-Line Support
Tron has full command-line support. All flags are optional, can be combined, and override their respective script default when used.
Usage: tron.bat [-a -c -d -o -p -r -s -v] | [-h]
Optional flags (can be combined):
-a Automatic/silent mode (no welcome screen)
-c Config dump (display current config. Can be used with other
flags to see what WOULD happen, but script will never execute
if this flag is used)
-d Dry run (run through script but don't execute any jobs)
-o Power off after running (overrides -r if used together)
-p Preserve power settings (don't reset power settings to default)
-r Reboot automatically (auto-reboot 30 seconds after completion)
-s Skip defrag (force Tron to ALWAYS skip Stage 5 defrag)
-v Verbose. Display as much output as possible. NOTE: Significantly slower!
Misc flags (must be used alone)
-h Display this help textIntegrity
checksums.txt contains SHA-256 checksums for every file and is signed with my PGP key (0x82A211A2; included). You can use this to verify package integrity if necessary.
Please suggest modifications and fixes; community input is helpful and appreciated.
Tips: 1JZmSPe1MCr8XwQ2b8pgjyp2KxmLEAfUi7
r/usefulscripts • u/The_one_the_only_God • Nov 15 '12
Okay! So TIL /r/scriptswap exists. Rather than deleting this subreddit, it'll now just be 100% scripts for system administration.
fuck.
r/usefulscripts • u/MadBoyEvo • Sep 14 '20
[PowerShell] Visually display Active Directory Trusts using PowerShell
Last week I've released PowerShell cmdlets for Visual Nested Group Membership. This time I'm releasing two new cmdlets to deal with Active Directory Trusts.
Get-WinADTrust
Show-WinADTrust
They differ a bit from your standard ActiveDirectory cmdlets providing more information and giving some visual representation.
Here's a blog post about it describing features and use cases: https://evotec.xyz/visually-display-active-directory-trusts-using-powershell/
I've attached screenshots to show what you can expect from it. The cmdlets allow you to traverse trusts recursively if it's possible.
You would use it like:
Get-WinADTrust | ft
Get-WinADTrust -Recursive | ftOr to show
Show-WinADTrust -Online -Verbose -RecursiveI also added one cool feature where you can control conditional formatting based on on your needs in the table. With just 2-3 more lines you can control output just like you would normally do in PSWriteHTML.
Show-WinADTrust -Online -FilePath $PSScriptRoot\Reports\TrustsWithColors.html -Verbose {
TableHeader -Names 'TrustBase', 'TrustType', 'TrustTypeAD' -Color Blue -Title 'Types'
TableCondition -Name 'TrustDirection' -BackgroundColor red -Color white -Value 'Bidirectional' -Operator eq -ComparisonType string
TableCondition -Name 'Level' -BackgroundColor blue -Color white -Value 0 -Operator eq -ComparisonType number
}The same thing applies to cmdlets described in Visually display Active Directory Nested Group Membership using PowerShell - Evotec but I am too lazy to showcase how it works there.


r/usefulscripts • u/atoomepuu • Jun 03 '19
[PowerShell] Automate Deleting Old Local Profiles
A couple people express interest in seeing a script to automate cleaning up old local profiles on computers. This is one I wrote and run monthly via task scheduler. My organization sees employees moving around a lot, so this has been really handy to keep the computers clean.
It works by getting a list of computers from a file, and it will use Runspace to open multiple threads to delete profiles older than a certain number of days. This script is set for 30 days, but you can change that. The multi-threading allows the script to clean up a lot of computers at once. I went from the script taking hours to complete to a few minutes. It usually takes 5 to 15 minutes to go through the ~400 computers at my organization.
It isn't perfect, it uses LastUseTime to determine when how long a profile hasn't been used, but sometimes a program or service will go in and update a profile even if the profile isn't being used.
Here it is. Please let me know if you have any issues with it or if you see any ways to improve it. And if it is useful, please let me know!
r/usefulscripts • u/Tekwulf • Mar 27 '17
[Powershell] Will it be quicker to send your data via the network or via carrier pigeon?
We found out one of our colleagues is still on 512kb/s when the rest of us are on fibre, so I wrote this powershell primarily to mock him.
The script asks you for a few input parameters and then tells you how many pigeons it will take to transport your data and how long it will take them. It then offers a comparison based on your bandwidth
The values are based on 80kmph average speed of a carrier pigeon and 3x32GB usb sticks as the max carry weight of the pigeon (75g)
###::: This script prompts for data inputs and then calculates whether sending your data via carrier pigeon would be faster than sending it via the internet
###::: ask what bandwidth you have in mbps
$bandwidth = Read-Host -Prompt 'what is your bandwidth in mbps?'
###::: ask how much data there is in GB
$dataload = Read-Host -Prompt 'How much data do you wish to transfer in GB?'
###::: how many KM the data will travel
$distance = Read-Host -Prompt 'How many KM must the data travel?'
###::: convert roughly to megabits
$dataloadmbits = ($dataload / 0.0001)
$Pigeonspeed = [math]::round($distance / 80,2)
$pigeoncount = [math]::ceiling($dataload / 96)
$datatransfer = [math]::round(($dataloadmbits / $bandwidth) / 3600,2)
echo "it will take $pigeoncount pigeons $pigeonspeed hours to carry your data"
echo "compared to $datatransfer hours on your bandwidth"r/usefulscripts • u/I_script_stuff • May 27 '16
[powershell] Generate up to 5,000 "Real looking" ad accounts at once script. (xpost from /r/powershell)
Posted this over there a few days ago. Figured I'd post it here:
So I was looking to do some testing for an AD migration, or maybe automate a few pain points I've been running into. In order to do this I needed "Real" names for my ad users. I threw together this script for the lab network.
The script has a few parts the first part are the global functions that will change per use case.
#preset variables for the script:
$date = Get-date -format M.d.yyyy
#AD specific info
$ou="OU=LANDING,DC=DEFAULTDOMAIN,DC=COM"
$principlename = "@DEFAULT.com"
$description = "Test Account Generate $date"
#Number of accounts generated:
$Number_of_users = "5000"
#Supported Nationalities: AU, BR, CA, CH, DE, DK, ES, FI, FR, GB, IE, IR, NL, NZ, TR, US
#Comma seperated values for multiple ie:
#$nationalities ="US,DK,FR"
$nationalities ="US"The second part is 2 functions I wrote:
generate : Creates an AD password acceptable for the basic policy
find_ad_id: Confirms that the Sam account name is not already taken. This currently attempts First letter of the first name full last name, and then crawls through the first name before giving up and logging the error.
The rest is simply pulling Json data from randomuser.me.
Now my lab AD instance looks a lot less lonely. edit: added a link to my blog with full write up
r/usefulscripts • u/icoco_ • Jul 07 '21
Now you can Retrieve Office 365 Audit Logs for up to 365 Days for All the Subscription Types
self.office365r/usefulscripts • u/TheLazyAdministrator • Jun 25 '18
[PowerShell] Office 365 HTML Tenant Report (Interactive)
I wanted to just share a script (available on GitHub for everyone to contribute too!) that will generate an interactive HTML report for your Office 365 tenant.
Here is the actual report if you want to view what the results look like
Company Info
Global Administrator
Strong Password Enforcement
Recent E-mails in your tenant
Domains
Groups
Licenses
Users
Shared Mailboxes
Contacts
Mail Users
Resource Mailboxes
and a whole lot more!
If you want the report to contain user mailboxes lastlogontime you can find it here but it may take longer to run
If there is anything you think should be added please feel free to comment or message me or even contribute on GitHub. If you are looking for something for tailored to fit your needs please let me know!