Skip to content

Instantly share code, notes, and snippets.

View DevOpsDrum's full-sized avatar

Mike DevOpsDrum

View GitHub Profile
@DevOpsDrum
DevOpsDrum / Block-Sleep
Last active April 20, 2022 15:02
Prevent Windows user session from going idle
<#
.SYNOPSIS
Prevent current Windows user session from going idle.
.DESCRIPTION
Prevent current Windows user session from going idle by calling [System.Windows.Forms.SendKey]::SendWait('') method every 30 seconds within a background job.
.EXAMPLE
PS> Block-Sleep | Out-Null
Calls the Block-Sleep function with default parameter values, and Out-Null prevents output to console if not desired.
Add function and call to function in PS profile to block sleep when PowerShell window is open.
.NOTES
@DevOpsDrum
DevOpsDrum / Invoke-SqlJob.ps1
Last active January 4, 2022 17:12
Run SQL Job and Wait for Completion
<#
.DESCRIPTION
Run SQL job and wait for it to complete
.EXAMPLE
script/function -SqlInstance "whatver" -JobName "whatever"
#>
Invoke-SqlJob
{
[CmdletBinding()]
param (
@DevOpsDrum
DevOpsDrum / Invoke-SqlCmdNoModule.ps1
Created January 4, 2022 17:10
Run SQL Command without SQLServer module
<#
.Description
Execute SQL command without using the SQLServer PowerShell Module. Restriced to using windows auth in this version.
.Example
If expecting a result set returned:
Invoke-SqlCmdNoModule -ServerInstance '' -Database '' -Query ''
If not expecting a result set returned:
Invoke-SqlCmdNoModule -ServerInstance '' -Database '' -Query '' -NonQuery