Author Archives: Greg

Azure PowerShell: Deploy Linux Custom Script Extension

Here’s how you can deploy an Azure VM Extension via PowerShell: # Before running this, upload your bash script to an Azure storage account container, grab its name and key via PowerShell or the Azure portal   Login-AzureRmAccount   $Subscription … Continue reading

Posted in Azure, Bash, PowerShell | Leave a comment

So, you can’t delete a folder in Windows because of “Path too long” errors?

If you have got yourself into a situation where you can’t delete a directory in Windows because the folder structure is too deep for Windows, you can use robocopy to save the day. Here’s a little snippet for wiping out … Continue reading

Posted in Batch Files, Windows | Leave a comment

DOS to Linux line endings in VIM

Switching between Windows and Linux machines every day, you’ll undoubtedly end up with files in the Linux system with DOS line endings. You can easily change the line endings in the editor VIM using the following commands: :w ++ff=dos :w … Continue reading

Posted in Bash, Linux | Leave a comment

PowerShell: Extract Files from Zip Archive

Here’s a quick PowerShell snippet to extract files from a .zip archive: Add-Type -Assembly System.IO.Compression.FileSystem   $PathToZipFile = "C:\temp\myarchive.zip" $ExtractPattern = "*.log" $ExtractDirectory = "C:\temp\extracted"   New-Item -ItemType Directory -Path $ExtractDirectory -Force | Out-Null   $ZipFile = [IO.Compression.ZipFile]::OpenRead($PathToZipFile) $ZipFile.Entries | … Continue reading

Posted in PowerShell | Leave a comment

T-SQL: Find Out Who Has Locks In Your Databases

Here are a couple of ways to see who is locking up your SQL Server database. First, the undocumented system stored procedure sp_who2 gives you a few more columns than the documented sp_who. And second, this custom query gives a … Continue reading

Posted in T-SQL | Leave a comment

Azure PowerShell: Copy All Files in Blob Storage to Local Directory

Here’s a Azure PowerShell script that downloads all blobs in a storage container to your local disk:   $storageAccountName = "mysuperstorage" $containerName = ‘my-blobs’ $destinationFolder = ‘C:\temp\my-blobs’   New-Item -ItemType Directory -Force -Path $destinationFolder   Login-AzureRmAccount   $storageAccountContext = (Get-AzureRmStorageAccount … Continue reading

Posted in Azure, PowerShell | Leave a comment