Category: Microsoft

Powershell and MP3’s

I’ve been trying in vain to organize my substantial MP3 collection.  I know that in the age of streaming MP3’s are passe, but I just can’t quit ’em.  I listen to a lot of music that isn’t readily available for streaming.

One of the things I’m nitpicky about is Genre tagging.  I like that stuff to be correct.  Thing is, sometimes I get lazy.  So, I dug in to see if I could hack out a quick script to scan subdirectories in my collection and root out MP3’s with incorrect or missing Genre tags. This is a very raw little script with zero error handling.  It examines the first file in every subdir, and writes to an output file every directory where that first file’s genre tag doesn’t match what it should.  It requires taglib-sharp.dll.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# uses taglib-sharp.dll
[Reflection.Assembly]::LoadFrom("E:\taglib-sharp.dll")

$outfile = "outfile.csv"
$basedir = "I:\SORTED\Classic Rock"
$subdirs = Get-ChildItem $basedir -attributes D

foreach ($subdir in $subdirs) {
$file = Get-ChildItem $subdir.fullname -Filter *.mp3 | Select-Object -First 1
$ff=$file.fullname
$f = [TagLib.File]::Create("$ff")
$genre = $f.Tag.Genres
$outt = "$subdir `t $genre"
$outt
if ($outt -NotMatch 'Classic Rock') {
$outt | out-file $outfile -append
}
$f = ""
}

SQL Powershell tools

I’m not sure why MS makes it so convoluted to install these tools on a server that isn’t running SQL.  Regardless, head here:

https://www.microsoft.com/en-us/download/details.aspx?id=29065

And don’t click download.  All that gets you is a text file.  Instead, head down the page and expand Install Instructions.  From there, search for and download the following modules:

  • Microsoft® System CLR Types for Microsoft® SQL Server® 2012 (SQLSysClrTypes.msi)
  • Microsoft® SQL Server® 2012 Shared Management Objects (SharedManagementObjects.msi)
  • Microsoft® Windows PowerShell Extensions for Microsoft® SQL Server® 2012 (PowerShellTools.msi)

If you get a 2503 or 2502 error while trying to install, as I did, you may not have sufficient rights.  Try either killing explorer.exe and restarting it with admin privs or invoking the msi from within an elevated command prompt.

Then just install modules a la:

Import-Module sqlps -DisableNameChecking

Windows: Updating existing ODBC Data Source Drivers

For some reason there still isn’t any easy way to update the driver used on a previously defined ODBC data source in Windows. There’s no option when stepping through the configuration. I suppose you’re expected to delete and recreate the data sources, specifying the new driver at that time. But what if you have dozens, or hundreds, of existing sources?

Do it though the registry.
Continue reading

Detect unresponsive applications using Powershell

Change the variables, save as a ps1 and schedule this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$to  = "user@email.com", "user2@email.com"
$from  = "user@email.com"
$smtp = "address of SMTP server"
$engine = $env:computername
$log = "C:\pathto\log.txt"
$now=Get-Date -format "dd-MMM-yyyy HH:mm"

$Processes = Get-Process -EA Stop          
$nProcesses = @($Processes | ? { $_.Responding -eq $false })
if($nProcesses) {          
  foreach($nProcess in $nProcesses) {          
   $nProcess | select Name, id, MainWindowTitle, Responding  
                Write-Host "Non-Responsive Processes found!"
                $msg = "Non responsive processes found on $engine! -- $nProcess"
                $body = "Non responsive processes found on $engine!    

                $nProcess"

                Add-content $log -value $now
                Add-content $log -value $msg
                Send-Mailmessage -From $from -To $to -Subject $msg -Body $body -Priority High -dno onSuccess, onFailure -SmtpServer $smtp
 }          
 }

OpenVPN reconnect

My OpenVPN likes to have difficulty and go yellow from time to time.  The problem with this is twofold – I have any and all downloads stop at the absence of VPN, and when I’m not home connecting to my server is more difficult when VPN has hundged up.  The simplest fix for now is just to restart/reconnect VPN on the daily.

I use OpenVPN with PIA.
Continue reading

Windows 10 – Can’t enable System Restore

System Restore.JPG

For some reason on my most recent build of Win 10 (don’t get me started) the option to enable System Restore was grayed out.  I fixed it by running the following in a admin level CMD prompt:

1
2
3
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore" /v "DisableSR" /f
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore" /v "DisableConfig" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients" /v " {09F7EDC5-294E-4180-AF6A-FB0E6A0E9513}" /t REG_MULTI_SZ /d "1" /f

The first two lines didn’t find those keys, FYI.  Still, the third enabled my ability to set up System Restore.

Windows 10 – Here comes ads

I’m kinda shocked by it, but it looks like Microsoft’s going to be pushing ads into the File Explorer in Windows 10.

The good news is, for now, you can turn it off. Within File Explorer, click on View > Options > Change folder and search options. Click the View tab, scroll down to Show sync provider notifications, and uncheck it.