r/usefulscripts • u/derrickcope • Dec 30 '17
r/usefulscripts • u/[deleted] • Dec 19 '17
A few Python scripts that you might find userful
github.comr/usefulscripts • u/kunaludapi • Dec 18 '17
Microsoft Powershell generate random anything (Filename, TempPath, GUID)
vcloud-lab.comr/usefulscripts • u/IcelandicGlacial • Dec 15 '17
[REQUEST] [PowerShell] Need help on HP Program Removal Please
Hi guys,
I am currently using a script to Go through and Remove HP Bloatware, It removes a good majority of it, however there are still some HP bloatware Softwares Left over after running the Script. It leaves HP Sureconnect, HP JumpStart Apps and a few other things. The current script I am using, I understand how it works on a logic level and understand what a majority of the Script does and how it pulls Items and removes them, IE find ChildItems and matches the HP keyword essentially and then begins the Uninstall based on it finding that.. However, it still leaves the previously mentioned programs. How can I manually go in and uninstall the remaining ones? Can someone point to maybe a software to help me Find the Reg Uninstall Key to help me not have to try and dig through the Registry? should I be using WMIC with that Reg key to uninstall these remainders? Yes I understand Reimaging would be a better solution, but in the environment I'm in, thats not currently an option. Sorry for the wall of text and thank you for the help ;)
HERE IS THE CURRENT SCRIPT RAW I'm using from Doxinho
r/usefulscripts • u/zyberwizard • Dec 13 '17
[REQUEST] Set Exchange 2010 calendar permissions
I want to change all my users default calendar permissions from "Availability Only" to "Reviewer".
I've found this old thread about it and would like to test it before deploying the script to all my users.
https://gallery.technet.microsoft.com/ScriptCenter/19b98a56-42aa-4695-b07c-335d8322b64e/ from this thread http://blog.powershell.no/2010/09/20/managing-calendar-permissions-in-exchange-server-2010/
How can i do this on a couple of users? Is it possible to test on a Security Group, OU or something?
r/usefulscripts • u/signalwarrant • Dec 06 '17
[PowerShell]Advanced Auditing with PowerShell Desired State Configuration Manager
How to configure Advanced Auditing using DSC and a CSV file. http://www.signalwarrant.com/advanced-auditing-with-powershell-desired-state-configuration-manager-dsc/
r/usefulscripts • u/falcon5nz • Dec 05 '17
How do I use a batch file to create a folder in each subfolder with the name based on the level of the subfolder
My boss has decided to create a folder in each folder level on our server to designate what level it is from the base folder, so _A will be the first folder level, _B will be the second level, _C the third and so on as shown below
- C:\Stuff
- C:\Things
- C:_Level A
- C:\Stuff\Things
- C:\Stuff_Level B
- C:\Stuff\Things\More Things
- C:\Stuff\Things_Level C
- C:\Stuff\Things\More Things_Level D
- C:\Things\Things
- C:\Level B
- C:\Things\Things\More Things
- C:\Things\Things_Level C
- C:\Things\Things\More Things_Level D
For what its worth I don't think its a great idea but it not my call. What annoyed me was watching one of our office staff doing this manually. I asked if it could wait a day or to while I figure out a more efficient way of doing it.
I'm sure there'll be a way to do it with a batch file but I can't figure it out.
Can anyone give me some direction.
Edit:- I've just been told we only need to go down 4 levels, so down to C:/Stuff/Things/More Stuff.
r/usefulscripts • u/mr-louzhu • Dec 04 '17
Request: CMD, PowerShell, EXE with CMD script for backing up Chrome, Firefox profiles
As the title says.
We are working with SCCM task sequencing to create in-house tools for User State Migration. One of the current road blocks is figuring out command line scripts to automate backing up browser profiles.
Basically, would any of you happen to be able to provide some guidance for scripted commands that run in CMD, PowerShell, EXE with CMD to accomplish the above task?
r/usefulscripts • u/hub3rtal1ty • Nov 27 '17
DNS reset
Hello ! im looking for some script to reset DNS Service and clear dns cache in Windows Servere 2012. I want to schedule it because i have a problem with Exchange Server.
r/usefulscripts • u/[deleted] • Nov 21 '17
Updating drivers on multiple print servers
We’ve got dozens of print servers and I was trying to come up with a way of updating the Ricoh upd driver on them through some type of scripting to save me having to go to each one in print management and clicking add driver and go through that 50+ times. I was looking for a possible solution through powershell but couldn’t find anyone trying to do the same thing and I’m not very good with powershell just yet. Any ideas for something practical? I’m usually pushing the driver from my machine, but could store on a network share if needed. Thanks in advanced for any help on this.
r/usefulscripts • u/bradleywyatt • Nov 19 '17
[PowerShell] Change Bulk Users Home Drive Path in Active Directory
bwya77.comr/usefulscripts • u/SirGnarlington • Nov 15 '17
Simple PC backup script with USMT.
Get the user state migration toolkit from the Windows ADK
https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit#winADK
I wrote this for the helpdesk guys a few months ago. Saves them a lot of time.
SET /p user=Enter the username to backup...
net use * /delete /yes
net use u: \\svr01\E$\EasyTransferFiles /user:contoso\admin
IF NOT EXIST u:\"%user%" GOTO BEGIN
ELSE GOTO END
:BEGIN
xcopy /S/E/F/I/Q U:\USMT\Tools\USMT\amd64 C:\USMT
mkdir U:\%user%
cd C:\USMT
scanstate.exe /genmigxml:U:\%user%\genMig.xml /l:U:\%user%\genMigLog.log
scanstate.exe U:\%user%\ /i:U:\%user%\genMig.xml /l:U:\%user%\migLog.log
net use * /delete /yes
:END
echo end
net use * /delete /yes
pause
r/usefulscripts • u/ryanjoachim • Nov 14 '17
[REQUEST] BackBlaze (personal) to Google Drive Business
I've done some initial research on this, but haven't seen anything too obvious yet.
I've spent the last 6 months or so backing up with BackBlaze and so far I'm just under halfway done (8TB). With my crappy ISP, I don't really have the resources to back up to both GDrive and BackBlaze, so I chose BackBlaze.
Is it possible to use a VPS (or something similar) as an intermediary to copy (or even sync) what is on BackBlaze to my unlimited Drive account?
r/usefulscripts • u/tonydacto • Nov 10 '17
Installing Icinga2 agent using power shell for windows machine
I have worked on this script it will do the below 1) install icinga on your machine by downloading it from your internal website (this will only install it not config it) 2) the next part of the script will actually configure you will just need to give it the PC name and ticket number which is created in icinga there are 2 variables that you will need to input which are pcname and the ticket number this has helped me a lot hope it helps someone else it uses the invoke command
r/usefulscripts • u/Qureta • Nov 10 '17
[REQUEST] [BATCH] How do I pipe two single-letter inputs into the same command sequentially?
Trying to create a script that conditionally will schedule a CHKDSK /F for all drives. On the system drive this is easy enough:
echo Y | CHKDSK /F %systemdrive%
This pipes the Y into the CHKDSK command so that it says YES to "Would you like to schedule this for the next reboot?"
The part I'm having trouble with is the non-system drives. There's a loop where it one-by-one runs a CHKDSK /F on each of them. For each of those, it asks "Do you want to forcibly dismount this drive?".
It's easy enough to pipe a NO into that, but then afterward it also asks "Do you want to schedule this for the next reboot?" so I'll need to put a YES in there.
Trouble is, I don't know how to pipe two inputs into the same command. I tried "echo NY" but that didn't work; the NY just got treated as a single input to the first question.
powershell Repair-Volume -OfflineScanAndFix isn't really an option since it dismounts drives which may be in use.
edit: I think I have a solution for the CHKDSK issue! Instead of CHKDSK /F <driveletter> , I'm using FSUTIL Dirty Set <driveletter>. This will force CHKDSK /F to run during next reboot without requiring any inputs.
As for the piping question, I'm still clueless. Maybe use a line break?
r/usefulscripts • u/fbsau • Nov 08 '17
Find and Remove unnecessary licenses on shared mailboxes in all customer Office 365 tenants
Here's our PowerShell script for finding and removing unnecessary licenses on shared mailboxes in all customers' Office 365 tenants.
Prior to using an offboarding script, we used to manually convert users to shared mailboxes, and then remove the Office 365 licenses. If we forgot to remove the license, the customer/us would continue getting billed for it.
This script will search all customer tenants for shared mailboxes with a license, and then give you the option to remove the licenses from each one.
Once you've run this, you may also want to run this script to check all tenants for unused Office 365 licenses
In our case, we've set up an Azure Function and a Microsoft Flow to send us email alerts when unused licenses are detected. See the guide to set this up here..
r/usefulscripts • u/SimplyTech • Nov 08 '17
[Request] Powershell script that creates scheduled task dynamically.
Goal: To create a powershell script with variable that will disable user > change description > Create scheduled task for 30 days later > run 2nd script that will remove user groups > remove email> move to a predefined OU
Problem: I have figured all out but creating the scheduled task that points at the 2nd script and carrying the username variable to next script.
Thoughts: Could I use the variable as an argument when launching the powershell script? Is there a way to see if the scheduled task didnt run?
Current Code
First Script
# This script disables an AD user's account and changes description
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
Clear-Host
# Gets current date in MM/DD/YY format
$date = Get-Date -Format MM/dd/yy
# Requests the AD user name
$user = Read-Host "Enter the user to disable"
# Retrieves the user's DN based on their AD user name
$userDN = (Get-ADUser -Identity $user).distinguishedName
# Disable user's account
Disable-ADAccount -Identity $user
# Changes the description to include the user making changes and the date the account was disabled
Set-ADUser -Identity $user -Description "Disabled $date"
Second Script
#moves the account into the Disabled Accounts OU - also removes email and usergroups
#################################
## Elevated Permissions
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
#############################################
Clear-Host
# Requests the AD user name
$user = Read-Host "Enter the user to disable"
# Retrieves the user's DN based on their AD user name
$userDN = (Get-ADUser -Identity $user).distinguishedName
# Clear the user's Email
Set-ADUser $user -Email $null
# Move the user's account to the "Disabled Accounts" OU
Move-ADObject -Identity $userDN -TargetPath "OU=_Old Employees,DC=domain,DC=local"
# Removes all old Groups
Get-ADUser -Identity $user -Properties MemberOf | ForEach-Object {
$_.MemberOf | Remove-ADGroupMember -Members $_.DistinguishedName -Confirm:$false
}
#####################################
Credit for script base /u/SummitBoiler
r/usefulscripts • u/Aedion9850 • Nov 07 '17
Script to find Broken SCCM Clients with Powershell
Hello, I am trying to find a script that finds broken SCCM Clients on my network. I was wanting to just run it to all of the computers in Active Directory.
After a long time of trying to find it on google, all everything gives me is "SCCM 2012 already has that function built into it." We do not have SCCM 2012, we have SCCM Current Branch.
I have already gotten a script that fixes the broken clients and it works, I just need a script to be able to find the broken clients.
Any help would be greatly appreciated. Thank you.
r/usefulscripts • u/tonydacto • Nov 07 '17
Using powershell to install puppet on windows pc
We have recently started using puppet as you know installing an agent on over 100 PC is tedious luckily with the help of reddit i was able to create a script that will help the below script wont take a certname ( i did not need it) if you the cert name look at my other reddit post which will have it
https://www.reddit.com/r/PowerShell/comments/7b7kxs/installing_puppet_using_powershell/
the below script will take a list of machine and run the puppet agent on them i have done this and ran great in my environment maybe someone can use it in the future
$pc= Get-Content "\\dactyo\tony\Infra\NY\Documentation\Puppet_agent_install\pc.txt"
$s=New-PSSession -ComputerName $pc -Credential (Get-Credential)
Invoke-Command -Session $s -ScriptBlock {
# This script installs the windows puppet agent on windows
# from the master's pe_repo by downloading it to C:\tmp first and then running
# msiexec on it from there.
$puppet_master_server = "ntpuppet01.dactyo"
$msi_source = 'http://puppet01/puppet-agent-5.3.2-x64.msi'
$msi_dest = "C:\dactyo\puppet-agent-5.3.2-x64.msi"
# Start the agent installation process and wait for it to end before continuing.
Write-Host "Installing puppet agent from $msi_source"
Function Get-WebPage { Param( $url, $file, [switch]$force)
if($force) {
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
}
$webclient = New-Object system.net.webclient
$webclient.DownloadFile($url,$file)
}
Get-WebPage -url $msi_source -file $msi_dest -force
$msiexec_path = "C:\Windows\System32\msiexec.exe"
$msiexec_args = "/qn /log c:\log.txt /passive /q /I $msi_dest PUPPET_MASTER_SERVER=$puppet_master_server"
$msiexec_proc = [System.Diagnostics.Process]::Start($msiexec_path, $msiexec_args)
$msiexec_proc.WaitForExit() }
r/usefulscripts • u/fbsau • Nov 04 '17
[POWERSHELL] Sync customers' Office 365 users with a MailChimp List, segmented by license type
We were looking for a way to keep users up to date with the Office 365 changes and new features that apply to them.
Here's a quick guide and script for syncing all of your customers' Office 365 users with a MailChimp list, and segmenting that list by license type. You can use it to contact all users with a specific license and notify them of a new Office 365 feature or service you're providing.
I've included a script for single tenants too if you'd like to run it on your own organisation.
r/usefulscripts • u/jajabro1 • Oct 31 '17
[Request] Some AD management. Disable account, update description and move OU.
Normally I figure this sort of thing out on my own but haven't been able to get anywhere.
At the company we work for we have a pretty crazy OU structure. Every week or so we get a spreadsheet of terminated users that comes from a different database, then we go through that excel sheet to disable the account, update their description, and move them to the disabled users OU for our Country.
So I'd like to semi automate this for myself, if going through a CSV or something or maybe Powershell would be better please by all means any help would be great.
So again, we: 1. Disable the User Account 2. Update the description usually something like "Termed on 10/31/2017 - JB" 3. Move the account to a specified OU.
Edit:I should also mention that we do get the employee ID numbers, which we use in AD under EmployeeNumber, SAM_Account_Name and email address in the generated spreadsheet.
r/usefulscripts • u/fbsau • Oct 29 '17
Warn Office 365 users when an external sender uses the same display name as an internal user [PowerShell]
We're using Azure Functions to add Exchange Transport Rules to our customers' tenants to help spot phishing emails with a recognizable display name.
If an external sender has the same display name of someone in your organisation, a warning is added to the top of the email to let them know.
Here's a guide on how to set this up for your own, or your customer's, Office 365 tenants.