Set default program for opening files without extensions in Windows
Oct 29, 2019
For some reason, downloading the request / result CSV files for a Salesforce “Bulk Data Load” job returns CSV files with the file extension missing, so you can’t just click to open them. This became super annoying during a troublesome data load so I decided to fix it once and for all. Open cmd as admin and enter the following:
assoc .="No Extension"
ftype “No Extension"="C:\ProgramData\chocolatey\lib\csvfileview\tools\CSVFileView.exe” “%1"
Obviously substitute in your favourite CSV editor (unless by some bizarre coincidence, you also like CSVFileView and install everything with chocolatey).
Powershell - normalizing line endings for all files in a directory
Oct 22, 2019
If you’re working with a git repository, a much better way to solve this is by changing the core.autocrlf setting. In this case I didn’t have that option, and needed a quick way to update thousands of files so the EOL chars would match in a binary diff tool. Here’s my slightly modified version of this SO answer:
$items = get-childitem -Path “C:\path\to\dir" -Recurse -File
foreach($original_file in $items)
$text = [IO.
Connecting to Sharepoint with Powershell when MFA is enabled
Oct 20, 2019
If you’re using multifactor auth, the usual login method mentioned in the SPOService documentation isn’t going to work (using Get-Credential) and you’ll get an error saying “Connect-SPOService : The sign-in name or password does not match one in the Microsoft account system”.
The correct process is rather bizarre:
$orgName = “organizationname"
connect-sposervice -url “https://$orgName-admin.sharepoint.com"
Then you’ll get the same Azure AD auth popup that you’d get with Connect-AzureRmAccount and Microsoft’s other Powershell modules.
Azure Devops CLI - removing old branches after squash merges
Oct 15, 2019
We had a git repo with hundreds of already-merged branches which I wanted to clean up. They’d all been merged via “squash merges”, meaning there was no merge commit to easily link back to the source branches. I wanted to delete these unnecessary branches, but only the ones that had definitely already been merged into the master branch via a pull request (PR). Below is how I used the Azure Devops CLI to get a list of them.
Set 'Windows spotlight' lockscreen images as desktop wallpapers without installing anything
Oct 06, 2019
I ended up moving the code for this post into my github since I’m using it myself ;) Get it from here:<br/ >https://github.com/mwanchap/configs/blob/master/Scripts/Windows%20Spotlight%20Wallpapers.ps1
Once you’ve cloned it, the only things you need to do are:
Decide where you want the wallpaper images to goUpdate the $location variable in the script with that location (I’m using ~\Pictures\Spotlight Wallpapers)Run the scriptOpen windows background settings and set the background type to “slideshow”, pointed at that locationRun the script at startup if you want to get new images all the time (optional but recommended)
ImageProcessor security config for Umbraco + Azure Storage Emulator
Sep 29, 2019
This is only going to work if you’re using ImageProcessor with Umbraco to deal with images being loaded from blob storage in the Azure Storage Emulator. Took me a while to get the settings right, the way I figured it out was:
firstly, use Azure Storage Explorer to find the URL for your emulated blob container and make sure that works by requesting from there directlyFind the URL it’s attempting to use by catching the ImageProcessingExceptions that get thrown when it can’t find the file
The quickest, easiest way to make and connect to an Azure VM
Aug 15, 2019
$creds = Get-Credential
$vmname = “TestVM"
$vm = New-AzureRmVm -Name $vmname -Credential $creds -Location “AustraliaEast” -Size “Standard_DS3_v2” # obviously change size and location as required
$fqdn = $vm.FullyQualifiedDomainName;
$username = $creds.UserName;
"full address:s:$fqdn” | out-file “~\desktop$vmname.rdp”;
"username:s:$vmname$username” | out-file “~\desktop$vmname.rdp” -Append;
Recurring issues in Visual Studio projects
Aug 15, 2019
Common issues and solutions to errors I come across in Visual Studio on a semi-regular basis:
"Could not find a part of the path … bin\roslyn\csc.exe"
Run this in Package Manager Console:
Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r
"Creation of the virtual directory http://localhost:12345/ failed with the error: Cannot create the Web site"
Update .csproj file and set the following:
In the <VisualStudio> element, set the following:
Useful git stuff
Jul 18, 2019
View diff for a specific file between two specific branches
git difftool branch_from branch_to – ‘.\file_to_examine’
Get the maximum length of every field in a CSV, Excel etc
Jun 30, 2019
While setting up tables in our data warehouse for use with some external APIs, it was getting a little tedious to figure out the max length of some long fields to get the write size for CREATE TABLE statements, so I wrote this little script to calculate it for me. Yeah, it’s kinda messy, so sue me (or don’t). You can swap out the import-csv part to also import from Excel or whatever else