Yeah - I’m lovin’ the powerhell goodness…

But I need a way to remember all of these bits and bobs of snippets.
I guess this is what the internet is for!

This will obviously update as I find more



Basics

ExecutionPolicy

Get-ExecutionPolicy -?  

Set-ExecutionPolicy -? 

#Unrestricted 
#Default 

Install Chocolatey

Just do it, ok?

chocolatey - install

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) 

Working with SqlServer

I think this part will end up as its own post…
Install SQL Server Powershell module

Install-Module -Name SqlServer -AllowClobber

Change password

I think this could be useful in docker instances…?

Pureinfotech - Change account password with powershell

$Password = Read-Host "Enter the new password" -AsSecureString

$UserAccount = Get-LocalUser -Name "admin"
$UserAccount | Set-LocalUser -Password $Password

Comments and more

Comments and more in powershell

This only works at the start of scripts, but is pretty cool

#Requires -RunAsAdministrator
#Requires -Version 5.0 

Filesystem basics

Delete a folder

if (Test-Path -Path $Folder) {
    Remove-Item $Folder -Recurse -Force
}

Test Net Framework installed

This is a bit crap

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/versions-and-dependencies

Get-Childitem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'

#461814 is for Net472

Can test with mcr.microsoft.com/dotnet/framework/runtime:4.8


Credits

Pester

Secrets

Cheers!