Powershell to find Text in PDF and Word

In continuation to my previous article on PowerShell to find hyperlink texts in ppt, here I am going to show how to find hyperlinks in Word or PDF files. Sample code below, tweak it for your purpose and drop me a comment if you need help.


$FilePath= "C:\Users\xxx\" 
$OurDocuments = Get-ChildItem -Path "$FilePath" -Filter "*.pdf" -Recurse #change to .doc* for word

$Word = New-Object -ComObject word.application
$Word.Visible = $false
$i = 0

$OurDocuments | ForEach-Object {
try {
    $Document = $Word.Documents.Open($_.FullName,$false,$true) 
    #"Processing file: {0}" -f $Document.FullName
    
    try{
    $Document.Hyperlinks | ForEach-Object {
        if ($_.Address -like "https://domain.com*" -or $_.Text -like "https://domain.com*") 
        {
                "Found issues {0} `r`n" -f $Document.Fullname 
                "Found issues {0} `r`n" -f $_.Address
                "Found issues {0} `r`n" -f $_.Hyperlinks
                break
         } 
      

    }
    }catch{Write-Host "Error has occured while accessing" $Document.FullName}
    }
    catch{Write-Error $Document.FullName}

   #"Completed processing {0} `r`n" -f $Document.Fullname
    
  Write-Progress -Activity "Searching Hyperlinks" -Status "Progress:" -PercentComplete ($i/$OurDocuments.count*100)
  $i++
}

$Word.Quit()
[gc]::collect()
[gc]::WaitForPendingFinalizers()

PowerShell to find HyperLink Text in PowerPoint

Recently I faced a scenario where I needed to find if a particular url is used in hyperlink in 100s of ppt. Opening ppt and looking for the ppt is cumbersome,  so wrote a small PowerShell to find the url. Here is the PowerShell Script code



$FilePath= "C:\Users\xxx\Path"
Add-Type -AssemblyName Office
$ppt = New-Object -ComObject powerpoint.Application
$DocumentsLib = Get-ChildItem -Path "$FilePath" -Filter "*.ppt*" -Recurse
$Doc = New-Object -ComObject powerpoint.Application

$i=0
$DocumentsLib | ForEach-Object {

Write-Host $_.FullName
$Doc = $ppt.Presentations.Open($_.FullName,$Null,$Null,[Microsoft.Office.Core.MsoTriState]::msoFalse)
$Slides = $Doc.Slides
Foreach ($Slide in $Slides) {
    $Slide.Hyperlinks | ForEach-Object {
       
        if ($_.Address -like "*texttofind*" -or $_.Text -like "texttofind*") 
        {
           write-host $_.Address
           write-host "Found"
            break
        }
               
 }
}
#$Doc.Save()
#$Doc.Close($false)
#$ppt = $null
 Write-Progress -Activity "Searching Hyperlinks" -Status "Progress:" -PercentComplete ($i/$DocumentsLib.count*100)
  $i++
}
[gc]::collect()
[gc]::WaitForPendingFinalizers() 

Drop Database in Oracle

Steps to drop a container database in oracle

Step 1 : Connect to the database as sysdba
bash#$ sqlplus / as sysdba

Step 2 : Shutdown the database
SQL> shutdown immediate;

Step 3 : Start mount the database with exclusive restrict to avoid the database being opened
SQL> startup mount exclusive restrict;

Step 4 : Drop database
SQL> drop database;

Getting Started with MariaDB

In our previous post, we demonstrated steps to install MariaDB Server on Ubuntu, in this article, we are going to show how to create database in MySQL/MariaDB. We are going to talk about DDL(Data Definition Language), how to create tables and authorize users to access them.

Start your mariadb-server and follow the steps

Creating Databases, Tables, and Authorized Users

Step 1: Connect to your mariadb-server and run below sql. This can be done via mysql client or any other tools like Heidisql, phpmyadmin etc. This is going to create a new database in your server. 
CREATE DATABASE myFirstDB;
Check if the database already exists and create
CREATE DATABASE IF NOT EXISTS myFirstDB;
To list all the databases in a server.
SHOW DATABASES;
To connect to your database
USE DATABASE_NAME;
Once you have selected your database, use following to create user
CREATE USER 'username'@'localhost' IDENTIFIED BY 'user_password';
To create a user that can connect from any host, use the '%' wildcard as a host part:
CREATE USER 'username'@'%' IDENTIFIED BY 'user_password';
No you can login to your MariaDB using the new user and password
mysql -h localhost -P port -u username -p user_password 

Running Total In SQL Server

Running total refers to the sum of values in all cells of a column that precedes the next cell in that particular column. Using Window Funct...