Skip to content

Instantly share code, notes, and snippets.

@devops-hacks
devops-hacks / Start-KeepAwake.ps1
Created December 11, 2024 10:53
Keep windows system busy (as if user working) to prevent it from sleeping, auto-logoff, powering down etc.
# Prevent the system from sleeping
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class PowerUtilities {
[DllImport("kernel32.dll", SetLastError = true)]
public static extern uint SetThreadExecutionState(uint esFlags);
public const uint ES_CONTINUOUS = 0x80000000;
public const uint ES_SYSTEM_REQUIRED = 0x00000001;
public const uint ES_DISPLAY_REQUIRED = 0x00000002;
@devops-hacks
devops-hacks / DownloadFilesFromRepo.ps1
Created March 18, 2021 13:26 — forked from zerotag/DownloadFilesFromRepo.ps1
PowerShell function to download files from a GitHub repository
function DownloadFilesFromRepo {
<#
.SYNOPSIS
This function retrieves the specified repository on GitHub to a local directory with authentication.
.DESCRIPTION
This function retrieves the specified repository on GitHub to a local directory with authentication, being a single file, a complete folder, or the entire repository.
.PARAMETER User