Thursday, September 3, 2020

Suppress Hash Marks in Compress-Archive and Expand-Archive

When using Compress-Archive and Expand-Archive in Powershell 5.0 and above, the scripts output a series of hashmarks to show progress. This can take up a lot of vertical screen real estate since each mark occupies its own line:

Compress-Archive -Path example_file.txt -DestinationPath example_file.zip -Force;
  #
  #
  #
  #
  #

To suppress these, redirect the information stream to null:

Compress-Archive -Path example_file.txt -DestinationPath example_file.zip -Force 6> $null;

and Enjoy the Silence

Thursday, June 7, 2018

Powershell speaks

Add-Type -Assembly System.Speech; $voice = New-Object -TypeName 'System.Speech.Synthesis.SpeechSynthesizer'; $voice.Speak("I've got a P H D in pain and a master's in disaster.");

Powershell file hashing

PS C:\> dir c:\ -Recurse | ? {$_.GetType().Name -eq 'FileInfo'} | % {$_.FullName + '|' + $_.Length.To String() + '|' + $_.Name + '|' + $_.Extension + '|' + (Get-FileHash -Path $_.FullName -Algorithm SHA1).Hash } > .\filehashes.txt

Tuesday, September 26, 2017

Powershell batch resizing jpg/jpeg

Several resources online demonstrate resizing or otherwise filtering an image using built-in Windows COM components, such as this MSDN article and this TechNet article. I wanted to do this in Powershell without relying on other scripts or modules. However, following the guidance using WIA.ImageFile and WIA.ImageProcess were giving me an error "The parameter is incorrect" when attempting to apply a resize.
The solution turned out to be simple. If you don't set both the width and height, that's what you'll get. Below is my version of the resizing script, which takes all the files in your current directory and saves them all out scaled down to 720p resolution (for an old TV I'd like to use as a big digital photo frame). I was unable to find out how to control the output quality with originals around 4MB and 6000x4000 in size weighing in at at a svelte 200KB post-conversion. Without further ado,
$jpgImg = New-Object -ComObject WIA.ImageFile;
$filter = New-Object -ComObject WIA.ImageProcess;
$filter.Filters.Add($filter.FilterInfos("Scale").FilterID);
$filter.Filters[1].Properties("MaximumWidth").Value = 1280;
$filter.Filters[1].Properties("MaximumHeight").Value = 720;
dir | % {$file = $_; $jpgImg.LoadFile($file.FullName); $jpgImg = $filter.Apply($jpgImg); $jpgImg.SaveFile('C:\Users\example_user\Desktop\example_folder\' + $file.Name);}

Wednesday, January 28, 2015

Resolving ORA-12638: Credential retrieval failed

Thanks to DBTricks and this article helping me solve ORA-12638: Credential retrieval failed today.
If you have
SQLNET.AUTHENTICATION_SERVICES = (NTS)
in your sqlnet.ora file, try changing it to
SQLNET.AUTHENTICATION_SERVICES = (NONE)

Thursday, October 2, 2014

How to stop the research pane from popping up in Outlook 2010

Press Alt-F11 to bring up the VB code editor
Press Ctrl-G to go to the immediate window (executes code as you type it)
Enter these commands to

1)verify research is enabled,
2)disable the research pane and
3)confirm it's now disabled

msgbox(Application.ActiveWindow.CommandBars("Research").Enabled)
Application.ActiveWindow.CommandBars("Research").Enabled = False
msgbox(Application.ActiveWindow.CommandBars("Research").Enabled)

Wednesday, May 28, 2014

Win7 forcing sync folders offline

Maximum PC Guides article on forcing your Win7 Sync'd folder to work offline while connected to the network. This is a great way to boost performance if, for example, you're connected to VPN on the other side of the country just so you can get to a NAS down the street from your house.