SSMS Quick Install from PowerShell
Waned to share PowerShell snippet to download SQL Management Studio (SSMS) with one liner and the AKA MS redirect service. Cheers

Code
iwr https://aka.ms/ssmsfullsetup -outfile ssms.exe; .\ssms.exe
Screenshot


Waned to share PowerShell snippet to download SQL Management Studio (SSMS) with one liner and the AKA MS redirect service. Cheers
iwr https://aka.ms/ssmsfullsetup -outfile ssms.exe; .\ssms.exe
All scheduled PowerShell files should generate LOGs. “Start-Transcript” is a great cmdlet for this. Adding a few more features can boost operations support. LOGs answer essentials support questions like:
Below is code template I recommend to for scheduled PowerShell jobs to generate a LOG. Key features include:
Thank you to @ToddKlindt for improvements to formula and elapsed time. Cheers.
function Main() { ### YOUR CODE HERE } # Open Log $prefix = $MyInvocation.MyCommand.Name $host.UI.RawUI.WindowTitle = $prefix $stamp = Get-Date -UFormat "%Y-%m-%d-%H-%M-%S" Start-Transcript "$PSScriptRoot\log\$prefix-$stamp.log" $start = Get-Date Main # Close Log $end = Get-Date $totaltime = $end - $start Write-Host "`nTime Elapsed: $($totaltime.tostring("hh\:mm\:ss"))" Stop-Transcript
https://github.com/spjeff/spadmin/blob/master/Practical-PowerShell-LOGs.ps1
When running PowerShell administration jobs for many hours within RDP session, we are open to risk of accidental pause. Other admins might RDP into server, click around, switch windows, and accidentally pause.
Disabling the default “Quick Edit” PowerShell window feature ensures protection for script to continue uninterrupted.
Cheers.
Quick post about detecting if PowerShell PNP is available on the local PC and installing is missing (for new systems) to make PS1 script more portable across servers.(1) Detect command (2) Install module if missing (3) Import module. Cheers
# Load PNP module, the right way Add-Type -Assembly "System.IO.Compression.FileSystem" -ErrorAction SilentlyContinue | Out-Null $pnp = Get-Command Connect-PnPOnline -ErrorAction SilentlyContinue if (!$pnp) { Install-Module "SharePointPnPPowerShellOnline" -Force } Import-Module "SharePointPnPPowerShellOnline" -ErrorAction SilentlyContinue | Out-Null