Skip to content

Instantly share code, notes, and snippets.

View oledid's full-sized avatar
😃
On duty

Ole Morten Didriksen oledid

😃
On duty
View GitHub Profile
@oledid
oledid / Run cmd from task scheduler without flashing console window.md
Created September 11, 2024 19:37
Run cmd from task scheduler without flashing console window.md

Windows: I want to run a command line script from task scheduler without opening a console window. How?

Task scheduler:

  • Program/script: powershell.exe
  • Add arguments: -windowstyle hidden -command "C:\Full\Path\To\Script.cmd"
  • Start in: (optional)

Also, set powershell execution policy first to be able to run powershell scripts

There are other ways to solve this, but this will let you "Run only when user is logged on".

@oledid
oledid / Get thumbprint of invalid SSL cert using old powershell.ps1
Created September 5, 2024 10:17
Get thumbprint of invalid SSL cert using old powershell
$myUrl = "https://my-url-with-invalid-cert"
Function Get-SSLThumbprint {
param(
[Parameter(
Position=0,
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
@oledid
oledid / Disable windows update reboot.cmd
Last active August 28, 2024 09:05
Disable windows update reboot.cmd
rem Source: https://answers.microsoft.com/en-us/windows/forum/all/how-to-disable-windows-11-automatic-reboots/d7766f02-59a1-48f4-af6e-761345704ead?page=1
rem Author: Michael 'The Curate'
rem Howto:
rem This script works by adjusting your 'Active hours'. You should schedule it to run every hour with the task scheduler.
rem To not get an "annoying popup" when it gets run you need to be running it "whether user is logged in or not"
rem You probably also need administrative privileges to edit the registry
for /f %%i in ('powershell "((get-date).Hour+18) %% 24"') do set startHour=%%i
for /f %%i in ('powershell "((get-date).Hour+12) %% 24"') do set endHour=%%i
@oledid
oledid / CreateIndexesForForeignKeysWithMissingIndex.sql
Last active June 3, 2024 19:14
MS SQL: Creates or updates a procedure which creates SQL script to create indexes for foreign keys which does not have an index.
-- MS SQL, SQL Azure
CREATE OR ALTER PROCEDURE CreateIndexesForForeignKeysWithMissingIndex
AS
BEGIN
WITH FK_Indexes AS (
SELECT
fk.name AS ForeignKey,
tp.name AS TableName,
fk.parent_object_id AS TableObjectID,
fkc.parent_column_id AS ColumnID,
@oledid
oledid / How to fix local account password not synced with connected microsoft account password.md
Last active April 14, 2023 18:11
How to fix local account password not synced with connected microsoft account password

How to fix local account password not synced with connected microsoft account password

May fix rare problems connecting to RDP

Source: Karl Grear1's response here https://answers.microsoft.com/en-us/windows/forum/all/remote-desktop-connection-logon-attempt-failed/9bfe09b6-87dd-41a6-ba62-2b65a6b64bce

If you do not know your local account name run PowerShell or Command Prompt and run the command 'whoami'

Hold down the shift key, and right click on a shortcut of your choice. I used PowerShell, but Notepad or some other small application should work.

@oledid
oledid / ms_description.reg
Last active April 14, 2023 09:07
Show MS_Description in SQL Management Studio (SSMS) designer
Windows Registry Editor Version 5.00
; Please read https://stackoverflow.com/questions/10537610/how-do-i-add-the-description-property-to-the-table-designer-view-in-ssms
; before running this file
[HKEY_CURRENT_USER\Software\Microsoft\SQL Server Management Studio\19.0_IsoShell\DataProject]
"SSVPropViewColumnsSQL70"="1,2,6,17;"
"SSVPropViewColumnsSQL80"="1,2,6,17;"
@oledid
oledid / make-vc-keys.ps1
Created June 14, 2021 11:15 — forked from srvrguy/make-vc-keys.ps1
A PowerShell script to make a 2048-bit RSA keypair. Saves the files in XML format in the user's document directory.
# Create a 2048-bit RSA Keypair in XML format
#
# @author Michael Johnson <[email protected]>
# @copyright 2016 SnapMD, Inc.
# @license https://opensource.org/licenses/BSD-2-Clause Simplified BSD License
<#
Copyright (c) 2016, SnapMD, Inc.
All rights reserved.
@oledid
oledid / resubmit-failed-logic-app-runs.ps1
Last active October 25, 2022 18:37
Resubmit failed logic app runs
############################################################
# Resubmit failed logic app runs
############################################################
# Sources:
# https://github.com/Azure/logicapps/tree/master/scripts/resubmit-all-failed-runs
# https://github.com/Azure/azure-powershell/issues/7752
import-module Az
@oledid
oledid / Manage-App-Service-Plan.md
Created April 23, 2021 18:15 — forked from mmckechney/Manage-App-Service-Plan.md
PowerShell and CLI to manage App Service Plan sizing

Manage App Service Plan count and SKU

Get the number of worker nodes serving the app service plan

(Get-AzAppServicePlan -ResourceGroupName "<resource group name>" -Name "<app service plan name>").Sku.Capacity