Skip to content

Instantly share code, notes, and snippets.

View v2kiran's full-sized avatar

Kiran Reddy v2kiran

View GitHub Profile
@v2kiran
v2kiran / always-running-scheduled-task.ps1
Created September 10, 2025 18:26 — forked from gregjhogan/always-running-scheduled-task.ps1
Windows scheduled task that stays running forever and restarts if it dies
$folder = "C:\folder"
$cmd = "powershell.exe "
$args = "-NoLogo -NonInteractive -WindowStyle Maximized -File script.ps1"
$user = "username-to-run-as"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval (New-TimeSpan -Minutes 1)
$action = New-ScheduledTaskAction -WorkingDirectory $folder -Execute $cmd -Argument $args
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -MultipleInstances IgnoreNew -RestartInterval (New-TimeSpan -Minutes 1) -RestartCount 999 -ExecutionTimeLimit (New-TimeSpan -Seconds 0)
$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive
$task = New-ScheduledTask -Principal $principal -Action $action -Settings $settings -Trigger $trigger
@v2kiran
v2kiran / winrm-https-self-signed-cert.ps1
Created August 22, 2025 18:31 — forked from gregjhogan/winrm-https-self-signed-cert.ps1
Configure WinRM HTTPS w/ self-signed certificate
# configure
$cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName $env:COMPUTERNAME
Enable-PSRemoting -SkipNetworkProfileCheck -Force
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In)" -Name "Windows Remote Management (HTTPS-In)" -Profile Any -LocalPort 5986 -Protocol TCP
# connect
Enter-PSSession -ComputerName {X.X.X.X} -Credential (Get-Credential) -SessionOption (New-PsSessionOption -SkipCACheck -SkipCNCheck) -UseSSL
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0",
"parameters": {
"vnet": {
"type": "string",
"defaultValue": "resource-group/vnet-name"
},
"ipAddress": {
"type": "string",
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0",
"parameters": {
"sku": {
"type": "string",
"defaultValue": "B1"
}
},
"variables": {