r/usefulscripts • • Feb 11 '16

[CSV File] FCC Telemarketer and RoboCall Blacklist for Google Contacts 02/08/2016

Thumbnail
pastebin.com
18 Upvotes

r/usefulscripts • • Feb 09 '16

[PowerCLI] Storage vMotion a VM with 2 disks

18 Upvotes

X-post from /r/PowerCLI

Hello, I recently came across a need to storage vMotion a VM that had 2 disks on two different Luns and quickly realized that Move-VM couldn't handle this. So I threw a quick function together to be able to handle 2 disks. It could easily be modified to handle more, but two was all I needed and I figured was more common config than 3 or more disks. You just need to provide the LUN names where the disks reside and the corresponding LUN names where you want each one to go. The only caveat is I didn't write it to take into account if the VM has multiple disks on the same LUN. The script will detect this and exit with an error. Hope someone might find it helpful.

http://pastebin.com/EMs6V4RK

EDIT: I realized I hadn't tested this script in the situation where I might only want to move 1 of the 2 disks of a VM. Well, I just ran it where I had the original and destination LUN name the same for one of the disks and it doesn't process that disk at all and cuts the time of the task down. So it will still function to move only one disk, you'll just need to keep the LUN name the same for the corresponding original and destination names of the disk you don't want to move.


r/usefulscripts • • Dec 19 '15

[BASH] Simple Google Dynamic DNS update script with logging

Thumbnail
pastebin.com
18 Upvotes

r/usefulscripts • • Sep 11 '15

[Request][Batch] Shut down windows telemetry (and maybe windows 10 compatibility updates

18 Upvotes

I'm not sure if this is the right place to be asking as I won't have access to stuff like WSUS that many of you use, but I've been looking into stuff like this for blocking all the new windows 10 and new telemetry stuff.

It looks like I can uninstall those updates if already present, I know with vbs I can hide updates, the services should be trivial, and I think I can disable the tasks via command line too with setting a variable as a password and echoing it to schtasks.

I'm just wondering if anyone else has already done this and could save me the effort, if I'm heading about this the wrong way because I'm missing something, or if I should just do this and post the script here when I'm done.


r/usefulscripts • • Mar 17 '15

[REQUEST] A script to automatically connect to a wireless network without any user interaction

18 Upvotes

I need a script to make some Win7 kiosk machines automatically connect to one of four different SSID/WPA key combinations (those strings can be plaintext in the script) as soon as they power up in their environment. There will be no HID input on the device (besides touch, but I'd prefer it to be completely automated and run each time on startup). I've tried "netsh wlan export" and "netsh wlan add profile" after sysprep with no success so far, but maybe someone will have a better idea or simpler way of achieving this. Thanks in advance!


r/usefulscripts • • Mar 12 '15

[BASH] Runs a program and records performance stats multiple times outputting a table then computes averages and confidence intervals

Thumbnail
gist.github.com
18 Upvotes

r/usefulscripts • • Feb 07 '15

[POWERSHELL] Get-AuditLogOverhead.ps1 - Calculates how much Exchange database storage is consumed by mailbox audit logging

Thumbnail
exchangeserverpro.com
18 Upvotes

r/usefulscripts • • Jul 21 '14

[POWERSHELL] Windows Server Backup Email Report

Thumbnail
github.com
18 Upvotes

r/usefulscripts • • Jun 03 '14

[VBScript] Scan Active Directory OU and Report Information (Logged In User, IP Address and more!) [SCRIPT UPDATE]

Thumbnail
pastebin.com
18 Upvotes

r/usefulscripts • • Dec 29 '13

[PYTHON] Automated Backup System for Websites

Thumbnail abs-for-websites.sourceforge.net
18 Upvotes

r/usefulscripts • • Nov 15 '12

[SQLSERVER] Fail over all mirrored databases

Thumbnail
pastebin.com
18 Upvotes

r/usefulscripts • • Feb 28 '24

How can I automate my task

17 Upvotes

I have task involving 200-300 servers

I am required to run a handful of commands and take a screenshot for the output Screenshots only, no text And I have to do them individually

Meaning: Run Command A

Wait for output Screenshot output Save screenshot

Run command B

Wait for output Screenshot output Save screenshot

——

I will be accessing these servers via a windows jump host, in which I can use any shell application such as putty or mobaxteme

All the username and passwords to access the servers are the same

The series of commands for all the server are also the same

Limitations and availablities

No admin rights on jump host, so only portable application are available(not officially) so yhr application has to be potable and to stay in my thumb drive

I cannot install any application on the AIX servers either

I can scp/ssh from one AIX server to the other in the whole subnet

What I intend to accomplish, it doesn’t have to exact this is just want I can think off at the moment The end goal are the screenshots

Example : gather screenshots on dir size

  1. login to the server via terminal

  2. run command ‘df -g’

  3. wait for output

  4. screenshot output

  5. save output with a specific file name to a specific folder

  6. close terminal

Proceed to next server till 300th server rinse and repeat till all requested screenshots

So far I am able to automate logging in and run the command using a simple batch script which launches putty.exe

However I have still yet to figure out how can I incorporate automating taking the screenshots

Does anyone have any tips ? Or suggestions?


r/usefulscripts • • Sep 03 '23

[PowerShell] Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML

17 Upvotes

I've written a new blog post about a new feature in PSWriteHTML that lets you create HTML reports but mix it up with markdown content. This allows you to choose your preferred way to create content.

Here's an example showing tables, calendar, logo and markdown. Hope you enjoy this one

$ProcessSmaller = Get-Process | Select-Object -First 5

New-HTML {
    New-HTMLTabStyle -BorderRadius 0px -TextTransform capitalize -BackgroundColorActive SlateGrey
    New-HTMLSectionStyle -BorderRadius 0px -HeaderBackGroundColor Grey -RemoveShadow
    New-HTMLPanelStyle -BorderRadius 0px
    New-HTMLTableOption -DataStore JavaScript -BoolAsString -ArrayJoinString ', ' -ArrayJoin

    New-HTMLHeader {
        New-HTMLSection -Invisible {
            New-HTMLPanel -Invisible {
                New-HTMLImage -Source 'https://evotec.pl/wp-content/uploads/2015/05/Logo-evotec-012.png' -UrlLink 'https://evotec.pl/' -AlternativeText 'My other text' -Class 'otehr' -Width '50%'
            }
            New-HTMLPanel -Invisible {
                New-HTMLImage -Source 'https://evotec.pl/wp-content/uploads/2015/05/Logo-evotec-012.png' -UrlLink 'https://evotec.pl/' -AlternativeText 'My other text' -Width '20%'
            } -AlignContentText right
        }
    }
    New-HTMLSection {
        New-HTMLSection -HeaderText 'Test 1' {
            New-HTMLTable -DataTable $ProcessSmaller
        }
        New-HTMLSection -HeaderText 'Test 2' {
            New-HTMLCalendar {
                New-CalendarEvent -Title 'Active Directory Meeting' -Description 'We will talk about stuff' -StartDate (Get-Date)
                New-CalendarEvent -Title 'Lunch' -StartDate (Get-Date).AddDays(2).AddHours(-3) -EndDate (Get-Date).AddDays(3) -Description 'Very long lunch'
            }
        }
    }
    New-HTMLSection -Invisible {
        New-HTMLTabPanel {
            New-HTMLTab -Name 'PSWriteHTML from File' {
                # as a file
                New-HTMLSection {
                    New-HTMLMarkdown -FilePath "$PSScriptRoot\..\..\readme.md"
                }
            }
            New-HTMLTab -Name 'ADEssentials from File' {
                New-HTMLSection {
                    New-HTMLMarkdown -FilePath "C:\Support\GitHub\ADEssentials\readme.md"
                }
            }
        } -Theme elite
    }

    New-HTMLFooter {
        New-HTMLSection -Invisible {
            New-HTMLPanel -Invisible {
                New-HTMLImage -Source 'https://evotec.pl/wp-content/uploads/2015/05/Logo-evotec-012.png' -UrlLink 'https://evotec.pl/' -AlternativeText 'My other text' -Class 'otehr' -Width '50%'
            }
            New-HTMLPanel -Invisible {
                New-HTMLImage -Source 'https://evotec.pl/wp-content/uploads/2015/05/Logo-evotec-012.png' -UrlLink 'https://evotec.pl/' -AlternativeText 'My other text' -Width '20%'
            } -AlignContentText right
        }
    }
} -ShowHTML:$true -Online -FilePath $PSScriptRoot\Example-Markdown1.html

r/usefulscripts • • Apr 19 '23

[PowerShell Core] Scrolling-menu navigation.

17 Upvotes

I doubt I'm the first, but I made this to hopefully make SSH easier.

https://www.dropbox.com/s/7ron8yeqsj1i7re/nav.PS1?dl=0

Basically, a bunch of Get-Key If's.
Arrow up/down to scroll up/down, backspace to cd .., c/v to copy/paste, home to Get-PSDrive, pg-up/pg-down to scroll up/down 10, space or ctrl+C to end script in current directory.

Recommend saving in the $home directory.


r/usefulscripts • • Apr 25 '21

[VBSCRIPT][QUESTION] Macro Using Variables in SQL Statement before sending request to SQL Database

17 Upvotes

I'm working with our business ERP which sits on an MSSQL Database. The ERP has a Macro feature built into most modules and uses VBScript to write the Macro. I'm far from being any kind of programmer but being a small company this is a task that has been put on me. Started on Friday and have learned a lot but I keep getting hung up on a certain task I'm trying to complete.

Working within the module that we use to create part numbers I'm trying to create a Macro that uses an SQL Statement to see if the Part ID is referenced in another table. If yes, do nothing, if no, MsgBox (I'd actually eventually like to take it as far as "if no" then go complete a task in another module automatically. But one step at a time).

I have successfully reached out to the SQL database and pulled information in as recordsets. I'm not 100% sure but feel confident that my mistake lies within how I'm trying to define the variable within the SQL statement. The variable being equal to the Part ID that the user is currently viewing.

This thing has gone through at least 100 revisions. For all I know I was closer on the first try than the current version but here's what I currently have:

____________________

Dim TRK

TRK = ID

strCnn = "driver=SQL Server;server=[server];uid=[user];pwd=[user];database=VETEST"

strsql = "SELECT PART_ID FROM TRACE_PROFILE WHERE PART_ID = '" & TRK & "'"

Set rst = CreateObject("ADODB.Recordset")

rst.Open strsql, strCnn

if rst.EOF=true then

MsgBox "Truck Part Trace needs setup!"

End if

rst.Close

____________________

Clarifications:

- Dim TRK is me just trying to create a Dim that can be used within the SQL Statement

- TRK = ID is me trying to define the Dim as the field in the ERP module. In this case "ID" is the Part ID. I'm trying to change the SQL to match the part ID the user is currently viewing.

- if rst.EOF=true... is me trying to get a MsgBox to pop if this part ID does not appear in the other table (this Macro executes when the user clicks save).

- I am currently getting the message pop on every attempt for part ID's that do and do not have records in the other table. This is why I believe the issue is within the variable of the SQL Statement. Seems like the variable is not being recognized and maybe the statement is actually searching the text I have in the statement, which would not exist for any record and result in the MsgBox happening on every save.


r/usefulscripts • • Nov 26 '20

[nirCMD] Changing volume without CMD popping up?

17 Upvotes

I have a macro keypad that allows me to remap keys to open programs. I wanted to change chrome volume so I wrote this and saved it as "volume_up.bat" :

nircmd changeappvolume chrome.exe 0.1

It works well with the volume changing appropriately with every keypress. The only minor issue is that every keypress makes a cmd window pop up for a split second. Is there a different way that I can run this script to prevent that or is it just something inevitable with trying to run something like this?


r/usefulscripts • • Sep 28 '18

[BASH] Jenkins update script

17 Upvotes

Got tired of manually downloading and updating the war file, so I wrote this little script to do it a little easier.

https://gist.github.com/krusem/81af9386cfb29c18abda229aa7cc2c0c


r/usefulscripts • • Aug 13 '18

[PowerShell] Skype for Business Delegated Permissions

Thumbnail
sconstantinou.com
17 Upvotes

r/usefulscripts • • Jun 16 '18

[Request] Looking for a script (or scripts) to automatically update a Google calendar from a CSV every time the CSV is saved (or just regularly)

17 Upvotes

r/usefulscripts • • Apr 20 '18

[request] Need to run powershell script from CD drive. Need to find CD Drive letter or path.

17 Upvotes
**Context**
Building Windows Servers from ISO via Powershell and PowerCli.
Script pulls in a .JSON file with requirements to variables.
Often times there is multiple disks created and initialized via PowerCli.

Update I forgot to mention I am using the Autounattend.xml to call the powershell script. <FirstLogonCommands> <SynchronousCommand wcm:action="add"> <CommandLine>Powershell .\Install\ExtraInstall_Cleanup.ps1</CommandLine> <Order>4</Order> <RequiresUserInput>true</RequiresUserInput> <Description>ExtrasAndCleanup</Description> </SynchronousCommand> </FirstLogonCommands>

After the process is done installing and drives are available.
A Script(Powershell) is run from the CD-Rom drive to install extra cleanup and tweaks.

Example:

    Function VCPP {
     $InstallVCPP = @'
     Set-Location D:\
    $Install = "\install"
    $VCinstall = "\vcinstall\"
    $2008 = "2008\"
    $2010 = "2010\"
    $2012 = "2012\"
    $2013 = "2013\"
    $2015 = "2015\vc_redist."
    $VCRed = "vcredist_x"

  #install Visual C++
   Start-Process -FilePath ( $Install + $VCinstall + $2008 + $VCRed + "86.exe") -ArgumentList "/qb"
   Start-Process -FilePath ( $Install + $VCinstall + $2008 + $VCRed + "64.exe") -ArgumentList "/qb"
   Start-Process -FilePath ( $Install + $VCinstall + $2008 + $VCRed + "86sp1.exe") -ArgumentList "/qb"
   Start-Process -FilePath ( $Install + $VCinstall + $2008 + $VCRed + "64sp1.exe") -ArgumentList "/qb"
   Start-Process -FilePath ( $Install + $VCinstall + $2010 + $VCRed + "86.exe") -ArgumentList "/passive /norestart"
   Start-Process -FilePath ( $Install + $VCinstall + $2010 + $VCRed + "64.exe") -ArgumentList "/passive /norestart"
   Start-Process -FilePath ( $Install + $VCinstall + $2012 + $VCRed + "86.exe") -ArgumentList "/passive /norestart"
   Start-Process -FilePath ( $Install + $VCinstall + $2012 + $VCRed + "64.exe") -ArgumentList "/passive /norestart"
   Start-Process -FilePath ( $Install + $VCinstall + $2013 + $VCRed + "64.exe") -ArgumentList "/install /passive /norestart"
   Start-Process -FilePath ( $Install + $VCinstall + $2015 + "x64.exe") -ArgumentList "/install /passive /norestart"
   Start-Process -FilePath ( $Install + $VCinstall + $2015 + "x86.exe") -ArgumentList "/install /passive /norestart"
   write-host "Visual C++ sucks" -BackgroundColor Green -ForegroundColor Blue
   '@

    Invoke-VMScript -VM $VM -ScriptText $InstallVCPP -GuestCredential $cred -ScriptType Powershell
    }



I have the Powershell script hard coded to D:\ however I get failures if that drive letter is used for the other variables.
So Sql cluster install requirements need the D:\ to be a datastore for that particular Automated build.
As you can imagine the script will fail. 

Example:
   Function EDrive {
    $Script = @'
   Stop-Service -Name ShellHWDetection
   Get-Disk |
   Where-Object {$_.partitionstyle -eq 'raw'} |
   Initialize-Disk -PartitionStyle MBR -PassThru |
   New-Partition -AssignDriveLetter -UseMaximumSize |
   Format-Volume -FileSystem NTFS -NewFileSystemLabel '--' -Confirm:$false
   Start-Service -Name ShellHWDetection
   Write-Host 'The script completed successfully' -ForegroundColor Green -BackgroundColor Red
   '@

    Invoke-VMScript -VM $VM -ScriptText $script  -GuestCredential $cred -ScriptType Powershell
   }

This goes through a For-each loop for every new VM created.

How do I get the Set-Location to know what the CD-Rom Drive is to run the above script and not error out?

r/usefulscripts • • Oct 09 '17

[REQUEST] SQL Express mail notification

17 Upvotes

Hello, im looking for a mail notification script for SQL Express backup. I know that powershell will be the best, maybe someone have good script for that ?


r/usefulscripts • • Jun 29 '17

Powershell Script for checking Citrix version and then update on clients.

17 Upvotes

The script is semi automated in the way that i have to put in the $citrixnewver= every time a new citrix version comes out. From Citrix version 4.8 that just came out, it now supports auto updating, but not silent. I have reported back from a customer that the script mostly works fine, but also fails to install the newest version on some clients. Any tips and tricks to improve this? My clients are not through a domain but have agents installed on them that make me able to run scheduled PS scripts. They do not have a public server either.

$citrixNewVer = "14.8.0.1010" $citrixver = "0.0" $cdviewer = "C:\Program Files (x86)\Citrix\ICA Client\CDViewer.exe" if (Test-Path $cdviewer) { $citrixver = (Get-Command $cdviewer).FileVersionInfo.FileVersion } if (Compare-Object $citrixNewVer $citrixver) { Invoke-WebRequest -Uri "https://downloadplugins.citrix.com/Windows/CitrixReceiver.exe" -OutFile "C:\Temp\CitrixReceiverWeb.exe" Start-Process -FilePath C:\Temp\CitrixReceiverWeb.exe /silent -wait Start-Process -FilePath 'C:\Program Files (x86)\Citrix\ICA Client\SelfServicePlugin\SelfService.exe' -ArgumentList '-showAppPicker' }


r/usefulscripts • • Jun 19 '17

[request] Check is a process is running, if not, launch an executable

17 Upvotes

I've got a licensing application that wont launch on server startup, someones got to log in to the license server and launch this application.

I want to see if this can be scripted to check if the process is running, I'll have a service account setup to run this script, then launch if it is not running.

Any help is greatly appreciated.

EDIT: the appropriately named Non-Sucking Service Manager was the fix. Thanks everyone!


r/usefulscripts • • Feb 19 '17

[Request] List of all appointments across company in Outlook

17 Upvotes

I received a request from an executive to compile a list in Excel of all meetings taking place in the company. His hypothesis is that there are too many meetings (can't say I disagree).

So I need a script that extracts the name, start date, end date, start time, end time, attendee names, and attendee emails. Can anyone point me in the right direction? All I can find are resources to extract my calendar or shared calendars... I need everyone's calendar data. Thanks!