r/usefulscripts • u/mindlessgrenade • Apr 11 '20
r/usefulscripts • u/MadBoyEvo • Aug 21 '18
[PowerShell] PSWriteWord - Module to create Microsoft Word documents from PowerShell without Word installed
I've been working on new version of PSWriteWord and it's somewhat ready.
There are lots of changes but 3 nice ones:
- Added what I call blocks that allows me to create PSWinDocumentation project (new, unreleased version that is) with ease
- Format-TransposeTable that allows HashTable to PSCustomObject and back transposing object back and forth (you can use it outside of Word as well). It's useful function.
- Changed Add-WordTable to behave similar way as Format-Table works. In other words if you do $Object | Format-Table you should see similar output if you send that object to Add-WordTable. There is also -Transpose switch which uses above command to rotate data in table.
Link to changes: https://evotec.xyz/pswriteword-version-0-5-1/
Link to module page: https://evotec.xyz/hub/scripts/pswriteword-powershell-module/
Github sources: https://github.com/EvotecIT/PSWriteWord




r/usefulscripts • u/jjkmk • Apr 12 '18
[Request] Looking for a bat / powershell script to give domain user local admin for an hour.
Want to add a domain user to the local administrators group for a set amount of time.
Whats the best way to approach this?
r/usefulscripts • u/codeofdusk • Aug 07 '17
freeswitch-fcc-blacklist: automatically add entries from the FCC robocall blacklist to FreeSWITCH
r/usefulscripts • u/theMightyMacBoy • Dec 23 '16
[Powershell] Ping TCP port on Server and force VM restart if no reply
r/usefulscripts • u/ItsGotToMakeSense • Jun 10 '16
I'm just learning batch scripting and whipped up a system info report. I think it's pretty useful but there's probably room for improvement.
It outputs a lot of system information to a txt file, including serial #, make/model, installed memory, and shared files/printers.
Feel free to take a look, try it out, and let me know what you feel could be done to improve it.
UPDATE!
Here's an improved version: New and improved!
It now includes a lot more info; motherboard, GPU, storage devices, and installed software. works a little cleaner now and is easier to customize where it will save the output. It defaults to the user's desktop currently but you only need to change one line if you want it to save elsewhere.
Still doesn't require admin permissions to run, as long as the user has write permission on the chosen folder.
r/usefulscripts • u/[deleted] • Dec 10 '14
[BATCH] Silent INstaller
Hi everyone. Just did some updates to the silent installer batch file I use and thought I'd share it. Easy to update, only lines that need to be edited for updated applications are at the top under :: Configure.
Installs the following (x86 or x64 based on %PROCESSOR_ARCHITECTURE%):
LibreOffice
Firefox
Adobe Flash
Adobe Reader
Adobe Air
NotePad++
Google Chrome
MS Silverlight
VLC Media Player
7-zip
Java
3 files (RUN_ME.bat, sin.bat, sudo.cmd):
https://github.com/thecamelsanus/SINScript
Images:
Main
http://i.imgur.com/M6WNE3n.png
Version list
http://i.imgur.com/hLZyUr3.png
Start
http://i.imgur.com/lTgTvY0.png
End
http://i.imgur.com/plRrFu8.png
Lot's of credit to /u/vocatus and his TRON script!
You can either grab the script and populate the folder with installs yourself or download here(preset install names are a bit messy, will fix later): https://mega.co.nz/#!n942AYrb!WPIc04CASTushbyaOLmeSJzi2Iu2IfPOQteHuoCFbnA
md5: https://github.com/thecamelsanus/SINScript/blob/master/md5
r/usefulscripts • u/ITSX • Nov 11 '14
[BATCH] Send a remote message popup to another windows box
I wrote this a while ago when we had a need to find the physical location of computers on wifi using shared credentials. It should be powershell, but I'm not there yet(the book has been on my shelf for a year, it's funny that I still haven't had a month of lunches). It uses PSTools locally and wscript on the remote host. Replace DOMAIN and DOMAIN2 with your company domain name(s)
@echo off
cls
echo You need to have admin rights on the remote machine to send a message with this script, and PSTools installed on your local machine.
echo.
echo.
echo Whats the name of the computer you want to send a message to?
set /p _strCompName=""
ping -n 1 %_strCompName% | FIND "TTL=" >NUL
IF errorlevel 1 GOTO SystemOffline
echo What message do you want to display?
set /p _strMessage=""
echo.
echo sending %_strMessage% to %_strCompName%
echo.
echo Set objShell = Wscript.CreateObject("WScript.Shell")>cismsg.vbs
echo strText = "%_strMessage%">>cismsg.vbs
echo intButton = objShell.Popup(strText,0,"CIS",4096)>>cismsg.vbs
xcopy cismsg.vbs \\%_strCompName%\c$\cis /y /i /q
IF ERRORLEVEL 1 goto err
del cismsg.vbs
echo.
psexec /accepteula \\%_strCompName% -i -s -d wscript "C:\CIS\cismsg.vbs"
IF ERRORLEVEL 1 goto err
echo.
for /f %%g in ('psloggedon /accepteula \\%_strCompName% -l -x ^| find /i "DOMAIN"^|^| find /i "DOMAIN2"') do set _varUserName=%%g
Echo Message displayed to %_varUserName%
pause>nul
exit
:SystemOffline
That computer doesn't appear to be online.
pause
exit
:err
echo Something went wrong. You might not have rights on the target machine.
pause
exitr/usefulscripts • u/BrianMichaelArthur • Jan 20 '22
[QUESTION] When you save a script for later where do you save it?
I struggled with the title of this post, but hopefully that wont keep people from reading on.
I realize a lot of people use Git or Git hub to store scripts but what about scripts you haven't used?
"This script looks useful but i don't need it right now so i am going to save it for later"
I currently use Joplin as my personal wiki and it does OK, but I am always on the lookout for something better.
r/usefulscripts • u/jcunews1 • May 01 '20
[VBscript] I miss DEBUG's binary editor so much, so I made one
NDebug v1.0.1. Is Not a Debugger.
DOS DEBUG clone mainly for binary file editing (as a hex editor).
Differences:
No disassembler and assembler functions.
No executable program/code.
No disk sector, I/O port, and expanded memory (EMS).
No CPU flag register, and CPU/FPU mode.
Memory is simulated using zero filled buffer.
CPU registers are simulated.
Default segment for loading file is 0000.
E commands list parameter is required.
L command accepts file name as third parameter.
Support file size up to 256MB.
Effective CPU registers:
CS:IP = Starting address of file for L & W commands
BX:CX = Size of file for L & W commands
DS = Default segment for C, D, E, F, M, and S commands.
SI = Number of 1MB memory storages. From 2 up to 256. Default is 2.
DI = Index of memory storage. Default is 0. i.e.:
DI:DS:AX = 001 1234:5678 = 1 179B8 = linear address 1179B8.
Usage: NDebug.vbs [file]
For a list of commands, run script and type ? at the prompt.
r/usefulscripts • u/thetacom • Dec 27 '19
[PowerShell] Get-Pi(e) Function
Happy Holidays! Treat yourself to a piece of pi(e) with this custom #PowerShell Function. It's as easy as Get-Pi or Get-Pie, depending on your mood. Whether you need one piece or a thousand digits, this custom function has you covered.
#pi #pie #programming
r/usefulscripts • u/MadBoyEvo • Jan 06 '19
[PowerShell] PSDiscord - Send messages to Discord service
Cross-platform PowerShell Discord Module that allows you to send messages to channel via Webhooks.
Overview: https://evotec.xyz/hub/scripts/psdiscord-powershell-module/
Sources: https://github.com/EvotecIT/PSDiscord

r/usefulscripts • u/kunaludapi • Oct 04 '17
Powershell Fun and Trick to show Text message as ascii ar
r/usefulscripts • u/Elementix • Jul 28 '16
[POWERSHELL] Monitor a folder (and subfolders) for folder/file changes and additions, then email the results
Created this to better manage our software management program, and see when someone drops something into the folder. Maybe someone can find a use for it in their organization too.
Keep in mind that you may need to add the -credential portion to the bottom "send-mailmessage" line if your SMTP server requires authentication. My situation doesn't require it.
EDIT: Another thing...renaming a file or folder apparently doesn't change the date modified, so those changes won't be seen by this.
https://gist.github.com/anonymous/b9148fd67100b607d0e51e713e181f93
r/usefulscripts • u/[deleted] • Nov 21 '15
[Batch] Backup script
Thought I'd share a script i have for basic backups.
RUN_ME.bat : http://pastebin.com/9LZ6qtZG
backup.bat : http://pastebin.com/1Df44Gae
Save both to a folder, double click RUN_ME.bat
A few pictures:
http://i.imgur.com/Hk2gFRl.png
http://i.imgur.com/SZARoks.png
http://i.imgur.com/2MX6olP.png
http://i.imgur.com/icyeqsN.png
some notes: won't work on xp, not sure about Vista. I've only tried it on 8 and 10 but should work without issue on 7.
edit- updated to include Outlook.pst. Check line 24 of backup.bat to verify the file path is correct for you
r/usefulscripts • u/[deleted] • Apr 30 '15
[PowerShell] - Show local admins, users in remote access group, and recent network logins
Must be run on the local computer. Currently, not setup to remotely query.
write-output "`r`nLocal admin user group members`r`n----------`r`n"
#Get local admins group
Invoke-Command {
net localgroup administrators |
where {$_ -AND $_ -notmatch "command completed successfully"} |
select -skip 4
}
write-output "`r`n"
write-output "`r`nRemote desktop users group members`r`n----------`r`n"
#show users in local remote desktop users group
Invoke-Command {
net localgroup "remote desktop users" |
where {$_ -AND $_ -notmatch "command completed successfully"} |
select -skip 4
}
write-output "`r`n"
# Extract info from logs
$allRDPevents = Get-WinEvent -FilterHashtable @{Logname = "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational" ; ID = 1149,1150,1148} -ErrorAction SilentlyContinue
$RDPevents = @()
foreach ($event in $allRDPevents)
{
$result = $type = $null
switch ($event.ID)
{
1148 { $result = "failed" }
1149 { $result = "succeeded" }
1150 { $result = "merged" }
}
if($event.Properties[1].Value -ne $null -and $event.Properties[1].Value.length -gt 0 ){
$RDPevents += New-Object -TypeName PSObject -Property @{
ComputerName = $env:computername
User = $event.Properties[0].Value
Domain = $event.Properties[1].Value
SourceNetworkAddress = [net.ipaddress]$Event.Properties[2].Value
TimeCreated = $event.TimeCreated
Result = $result
}
}
}
# Display results
write-output "`r`nNetwork logons in the past 7 days`r`n----------`r`n "
$RDPevents | Sort-Object -Descending:$true -Property TimeCreated | Format-Table -AutoSize -Wrap == Output ==
Local admin user group members
----------
Administrator
Domain Admins
Remote desktop users group members
----------
username
username
group
Everyone
Network logons in the past 7 days
----------
SourceNetworkAddress Domain TimeCreated Result ComputerName User
-------------------- ------ ----------- ------ ------------ ----
192.168.107.87 DOMAIN 4/30/2015 8:26:23 AM succeeded server username
192.168.107.87 DOMAIN 4/29/2015 1:53:21 PM succeeded server username
192.168.111.184 DOMAIN 4/29/2015 12:45:36 PM succeeded server administrator
192.168.107.87 DOMAIN 4/29/2015 10:04:18 AM succeeded server username
192.168.107.87 DOMAIN 4/28/2015 3:11:32 PM succeeded server usernamer/usefulscripts • u/creamersrealm • Dec 12 '14
[POWERSHELL] Adding off domain computers to a AD domain with automatic name incrementing
I needed to develop this script so that we could have IT techs take preimaged computers and join them to our domain. The problem is their accounts are not allowed to join anything to the domain.
The script checks if it is being ran as admin Then it will check if the computer is on a domain if not it will help you build a computer name. Our naming convention is site-(lap)username(instance)
The script first checks if .Net 4.5 is installed and then if powershell 4.0 is installed as it is required for the script to function if it is not it will install them for you (I used the code from http://www.reddit.com/r/PowerShell/comments/2oazt5/install_powershell_4_and_prerequisites/ to integrate this portion)
It builds a site list from a directory with a folder for each site name Then it asks for a username and is it a laptop (yes,1, sure are valid answers to the laptop question)
It then checks the domain if the computer exists and if it does it increments the number until the computer name does not exist.
It then changes the name of the computer and then reboots Rerun the script and it will join to the domain
If you rerun it again it will check and realize the computer is on a domain and not let you do anything else.
The variables start at line 140 (I had to do this for the update function to work.)
Downloads:
Generate Creds (Has to be ran in ISE): https://github.com/creamers/MiscPowershell/blob/master/Generate-Secure%20Credentials.ps1
Renaming Script: https://github.com/creamers/MiscPowershell/blob/master/Computer-Rename.ps1
I hope this helps someone else out.
Thanks for the gold!
r/usefulscripts • u/Sekers • Sep 29 '22
[POWERSHELL] M365 Teams Membership Sync
Since we don't currently have the licensing for dynamic membership rules for Azure AD groups, I wrote a PowerShell script that will allow us to map M365 and Azure groups to Teams groups and Teams Private Channel groups and then keep them in sync. You can also change the configuration so that it only adds members and not remove them. It's the first release as well as my first time using the Microsoft Graph API so any suggestions are welcome.
M365 Teams Membership Sync (https://github.com/Sekers/Useful-Scripts/tree/main/Microsoft%20365/Teams%20Membership%20Sync)
A PowerShell script that syncs members of Microsoft 365 and Azure AD groups to M365 Team & Team Channel groups. This script can be used to dynamically update Team and Team Channel members from groups. This is useful if you do not have the licensing necessary for dynamic membership rules for Azure AD groups. It also has the added benefit of logging + email alerts and optionally skipping the removing of members who no longer are in the mapped group(s), allowing them to remain members of Teams and Channels they have previously been added to.
Features
Adds mapped group members to Teams and Channels (Private Channels only).
Optionally removes members who no longer are mapped to a Team or Channel (allows for user exceptions if enabled).
Optionally allows for group recursion/nesting.
Written to take advantage of the latest Microsoft Microsoft Graph API PowerShell module.
Easily update settings using JSON config files.
Authentication options:
Delegated Permissions (run using a signed-in user).
Application Permissions (application consented by an administrator and authenticated by certificate or secret).
Optional non-blocking logging & email alerting (see prerequisite modules).
Debugging options.
r/usefulscripts • u/MadBoyEvo • Feb 27 '22
[PowerShell] Converting advanced object to flat object
I wrote a small blog post about a simple command ConvertTo-FlatObject. This function provides an easy way to convert advanced PowerShell Objects into flat objects that you can often encounter.
$Object3 = [PSCustomObject] @{
"Name" = "Przemyslaw Klys"
"Age" = "30"
"Address" = @{
"Street" = "Kwiatowa"
"City" = "Warszawa"
"Country" = [ordered] @{
"Name" = "Poland"
}
List = @(
[PSCustomObject] @{
"Name" = "Adam Klys"
"Age" = "32"
}
[PSCustomObject] @{
"Name" = "Justyna Klys"
"Age" = "33"
}
)
}
ListTest = @(
[PSCustomObject] @{
"Name" = "Justyna Klys"
"Age" = "33"
}
)
}Exporting such objects to CSV or HTML would require heavy parsing on your side, and this is a standard for Graph calls, Azure AD, Office 365, and other objects returned by a lot of commands.
$Object3, $Object4 | ConvertTo-FlatObject | Export-Csv -Path "$PSScriptRoot\test.csv" -NoTypeInformation -Encoding UTF8Of course, I've updated PSWriteHTML with support for it:
$Object3, $Object4 | Out-HtmlView -Filtering -FlattenObjectThis function should help you deal with those objects in a much easier way. It's not perfect of course, but it may save you time when you want to quickly assess something.
Blog post: https://evotec.xyz/powershell-converting-advanced-object-to-flat-object/
Sources for PSWriteHTML: https://github.com/EvotecIT/PSWriteHTML
Sources for function: https://github.com/EvotecIT/PSSharedGoods/blob/master/Public/Converts/ConvertTo-FlatObject.ps1
r/usefulscripts • u/attero_ • Apr 06 '21
[AutoHotkey] emulate macOS shortcuts on Windows
r/usefulscripts • u/mindlessgrenade • Aug 11 '20
[Terraform / Ansible ] AWS full stack: Apache NiFi with Encryption and Autoscaling
r/usefulscripts • u/MadBoyEvo • Jan 01 '20
[PowerShell] Sending information to Event Log with extended fields using PowerShell
Recently when writing Powershell Script that is deleting some computers from Active Directory I thought it would be beneficial for SIEM tools to be able to track this action.
PowerShell offers built-in command Write-EventLog but it does it in a limited way allowing one to send only Message (one field). This makes it hard to track additional data - for example, ComputerName, Action, SerialNumber, or any other data that you may find useful.
The following post covers this scenario https://evotec.xyz/sending-information-to-event-log-with-extended-fields-using-powershell/ and with command Write-Event allows you to send it the way you want to.
This blog is an extension of my earlier blog about Event Logs: https://evotec.xyz/powershell-everything-you-wanted-to-know-about-event-logs/ - but this one will take an hour of your life if you want to read thru it and understand what it covers.
What this blog post doesn't cover is sending to Event Log using named parameters. Named parameters are much harder and from what I read they require much bigger preparations, some compilation so I thought I would leave it for another day ;-)
Usage:
Write-Event -LogName 'Application' -EntryType Information -ID 1000 -Source 'MySuperSexyApp' -AdditionalFields 'Add me', 'And me' -Message 'This is very long message that includes: addme, and me'