Skip to content

Instantly share code, notes, and snippets.

View Splaxi's full-sized avatar

Mötz Jensen Splaxi

  • Essence Solutions P/S
  • Denmark
  • X @splaxi
View GitHub Profile
Remove-Item "$env:APPDATA\GitHub Desktop\window-state.json" -Force
@Splaxi
Splaxi / Test-InstalledModules.ps1
Created November 29, 2018 11:01
Test all modules versions against PSGallery
#Inspired from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules against the PSGallery and see if a never version is available
$mods = Get-InstalledModule
foreach ($mod in $mods) {
Write-Host "Checking $($mod.name)"
$latestAvailable = Find-Module $mod.Name -ErrorAction SilentlyContinue
if($null -eq $latestAvailable) { continue }
@Splaxi
Splaxi / Update-InstalledModules.ps1
Created November 29, 2018 11:03
Test all modules versions against PSGallery and Updated them
#Inspired from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules against the PSGallery and see if a never version is available.
#If newer version is available it will update it
$mods = Get-InstalledModule
foreach ($mod in $mods) {
Write-Host "Checking $($mod.name)"
$latestAvailable = Find-Module $mod.Name
if ($mod.version -eq $latestAvailable.version) {
@Splaxi
Splaxi / Test-InstalledModuleMultiples.ps1
Last active November 29, 2018 11:16
Test all modules for multiple installed versions
#Copy & pasted from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules for multiple versions installed on the machine
$mods = Get-InstalledModule
foreach ($Mod in $mods) {
Write-Host "Checking $($mod.name)"
$latest = Find-Module $mod.name
$specificmods = Get-InstalledModule $mod.name -allversions
Write-Host "$($specificmods.count) versions of this module found [ $($mod.name) ]"
@Splaxi
Splaxi / Remove-OldModuleVersions.ps1
Created November 29, 2018 11:17
Removes old module versions
#Copy & pasted from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules for multiple versions installed on the machine.
#All versions that are below the highest will be uninstalled
$mods = Get-InstalledModule
foreach ($Mod in $mods) {
Write-Host "Checking $($mod.name)"
$latest = Get-InstalledModule $mod.name
$specificmods = Get-InstalledModule $mod.name -allversions
Write-Host "$($specificmods.count) versions of this module found [ $($mod.name) ]"
@Splaxi
Splaxi / Clear-LytFiles.ps1
Last active April 24, 2020 11:37
Clear lyt files from Remote Desktop Manager
Get-ChildItem -Path "C:\Users\$env:USERNAME\AppData\Local\Devolutions\RemoteDesktopManager" -Filter "*lyt" -Recurse | Remove-Item -Force -ErrorAction SilentlyContinue
#Window pane / Window tab - clear design, only navigation. Exit
Get-ChildItem -Path "C:\Users\$env:USERNAME\AppData\Local\Devolutions\RemoteDesktopManager" -Filter "*lyt" -Recurse | Remove-Item -Force -ErrorAction SilentlyContinue
@Splaxi
Splaxi / Get-SamAccount.ps1
Last active March 11, 2019 21:45
Get-SamAccount.ps1
$temp = Read-Host "Fill in DOMAIN\USERNAME"
if(($temp.Length - ($temp.IndexOf("\")) + 1) -gt 20) {
$temp.Substring(0, $temp.IndexOf("\")+1) + $temp.Substring($temp.IndexOf("\")+1, 20)
} else {
$temp
}
@Splaxi
Splaxi / Uninstall-ModuleOldVersion
Last active October 13, 2021 09:05
Helper function to remove old module versions
function Uninstall-ModuleOldVersion {
[CmdletBinding()]
[OutputType()]
param (
[Parameter(Mandatory = $false, Position = 1)]
[string] $Module = "*"
)
#Copy & pasted from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules for multiple versions installed on the machine.
@Splaxi
Splaxi / Insert-EntittyToAzureStorageTable.ps1
Created May 10, 2019 18:16
Sample how to write to Azure Storage Table
Add-Type -AssemblyName System.Web
$storageAccountName = "VALUE"
$tableName = "countries"
$sasToken = "?sv=2018-03-28....."
$partitionKey = "All"
$entityKey = "PartitionKey={0},RowKey={1}"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@Splaxi
Splaxi / DropAllViews.sql
Created September 17, 2019 07:28
Drop all views
SELECT ' Drop view ' + s.NAME + '.' + v.NAME
FROM sys.views v
JOIN sys.schemas s
ON v.[schema_id] = s.[schema_id]
WHERE v.type = 'V'