Skip to content

Instantly share code, notes, and snippets.

@StefanKoell
StefanKoell / VSCode-Extensions.md
Last active August 12, 2021 08:00
Experts Live US 2019
@NakedPowerShell
NakedPowerShell / gist:9711e57e18fa4c4cd0fed148497f900e
Last active July 13, 2019 02:18
Script to generate all the exploration I normally do when I want to install a new PowerShell module
Function Show-ModExplore {
<#
.SYNOPSIS
Generate all the exploration I normally do when I want to install a new PowerShell module
.DESCRIPTION
Script to generate all the exploration I normally do when I want to install a new PowerShell module
CREATE DATABASE [٠০౦০٠];
GO
USE [٠০౦০٠];
GO
CREATE SCHEMA [٠০౦০٠];
GO
CREATE TABLE [٠০౦০٠].[٠০౦০٠]([٠০౦০٠] NVARCHAR(20), [۰০౦০٠] NVARCHAR(20), [٠০౦০۰] NVARCHAR(20), [۰০౦০۰] NVARCHAR(20));
GO
CREATE UNIQUE CLUSTERED INDEX [٠০౦০٠] ON [٠০౦০٠].[٠০౦০٠]([٠০౦০٠], [۰০౦০٠], [٠০౦০۰], [۰০౦০۰]);
GO
@nicholasdille
nicholasdille / Test-ShouldProcess.ps1
Created July 17, 2017 19:55
Skeleton for ShouldProcess in PowerShell functions
Function New-Something {}
Function Test-ShouldProcess {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')]
Param(
[Parameter()]
[switch]
$Force
)
@richardszalay
richardszalay / Reset-BashPassword.ps1
Last active December 3, 2020 08:38
Reset-BashPassword.ps1
# Resets the password for the default LXSS / WSL bash user, based on https://askubuntu.com/a/808425/697555
$lxssUsername = (Get-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss).DefaultUsername
lxrun /setdefaultuser root
bash -c "passwd $lxssUsername"
lxrun /setdefaultuser $lxssUsername
@adamdriscoll
adamdriscoll / task.json
Created May 15, 2017 11:32
VSCode task.json to add a build command to package a PowerShell script as an exe
{
"version": "0.1.0",
"tasks": [
{
"taskName": "build",
"command": "powershell",
"args": ["Merge-Script -Script '${file}' -Bundle -OutputPath '${fileDirname}\\out' -OutputType Executable"],
"isBuildCommand": true,
"showOutput": "silent"
}
@barsv
barsv / logger.ps1
Last active January 17, 2024 12:39
Logging in powershell with log rotation
# all logging settins are here on top
$logFile = "log-$(gc env:computername).log"
$logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL")
$logSize = 1mb # 30kb
$logCount = 10
# end of settings
function Write-Log-Line ($line) {
Add-Content $logFile -Value $Line
Write-Host $Line
@tonysneed
tonysneed / nano-docker.md
Last active August 20, 2019 20:45
Install Docker on Windows Nano Server

Install Docker on Windows Nano Server

Connect remotely to the nano server

  1. Open PowerShell as Administrator
  2. Test-WSMan xx.xxx.xxx.xx
  3. Enable-PSRemoting
  4. Enter public IP address of nano server: $ip = "xx.xxx.xxx.xx"
    Set-Item WSMan:\localhost\Client\TrustedHosts "$ip" -Force
  5. Enter-PSSession -ComputerName $ip -Credential "~\Administrator"
@wim-beck
wim-beck / resetPwd.ps1
Last active March 15, 2021 02:03
Reset AD password
param($AccountName)
# Reset a pwd, requires reset pwd rights on the obj:
Set-AdAccountPassword -Identity $AccountName -Reset -NewPassword (Read-Host -asSecureString "Enter the new password")
# Change a pwd, knowing the current password
Set-AdAccountPassword -Identity $AccountName -OldPassword (Read-Host -asSecureString "Enter the current password") -NewPassword (Read-Host -asSecureString "Enter the new password")
@jangins101
jangins101 / Parsing IIS Logs with PowerShell
Created June 23, 2015 17:18
Parsing IIS Logs with PowerShell
#
# Originally from: "http://sbrickey.com/Tech/Blog/Post/Parsing_IIS_Logs_with_PowerShell"
#
# Define the location of log files and a temporary file
$LogFolder = "C:\inetpub\logs\LogFiles\W3SVC123"
$LogFiles = [System.IO.Directory]::GetFiles($LogFolder, "*.log")
$LogTemp = "C:\inetpub\logs\LogFiles\W3SVC123\AllLogs.tmp"
# Logs will store each line of the log files in an array