Tag Archives: scripts

Use Active Directory to retrieve computer last logon date

If you need to see when a computer last logged onto your domain, here is a quick command to achieve that using PowerShell Active Directory shell: Get-ADComputer -identity [COMPUTER NAME] -Properties * | FT Name, LastLogonDate To look at all computers in your network. Change the -Identity switch for the -Filter switch: Get-ADComputer -Filter *…
Read more

Insert data into two tables of different databases on same instance

If both databases reside on the SAME MySQL server (and use the same user and password to connect). You simply establish the connection without picking a database, then put the name of the database in front of the table name like: INSERT INTO myDBname.myTableName (myKey) VALUES (myValue); If you have a connection to one database…
Read more

FTP PowerShell Script

Automated PS script to run a FTP via Windows Task Scheduler using: Powershell.exe -ExecutionPolicy Bypass -command ".'C:path\to\SCRIPTNAME.ps1' optional argument -WindowStyle Hidden For console testing, use Set-ExecutionPolicy RemoteSigned   or --bypass   [sourcecode language="plain"] # Location where csv file is to be created, with results from query. $dir = Get-ChildItem -Path "PATH TO DIRECTORY HERE" | Sort-Object…
Read more

Transferring a WordPress Site

If you are needing to transfer an entire WordPress site (entire meaning EVERYTHING) than here is the plugin you need! https://wordpress.org/plugins/duplicator/ Install it, activate it. Go and make a backup/transfer of your entire site Upload the 2 files it creates, installer.php and the backup zip file to your new site Go to your new site…
Read more

Scheduling your Server to Automatically Reboot

Navigate to Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks. You should now see the Add Scheduled Task Wizard on the Right. Choose run a program when prompted on what to do... click the Browse button. By default, the browse button will bring you to the root of the C: drive. Navigate to WINDOWS -> system32 and locate the file named ‘shutdown.exe’. Highlight it,…
Read more

Display code snippets in your WordPress Posts

A good plugin to use if you are wanting to display code snippets in your post is SyntaxHighlighter Evolved.  It will very nicely display: PHP, MySQL, HTML, etc... code in a nicely formatted code box. Setup only takes about 30 seconds, than for immediate basic usage just warp any code you want in <pre> </pre>…
Read more

Check to see if MySQL record exists

If you have ever had script that you need to check before updating/deleteing a MySQL record here is a quick code to check: if(mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE id = '$userid'"))) { // Code inside if block if userid is already there }
Read more

Swapping Column Values in MySQL

If you ever need to swap column values in MySQL here is how: UPDATE TABLE s1, TABLE s2 SET s1.SWAP_A=s1.SWAP_B, s1.SWAP_B=s2.SWAP_A WHERE s1.KEY=s2.KEY Check out this article to read more.
Read more