This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #$packageParameters = $env:chocolateyPackageParameters | |
| $packageParameters = "var1 = val1;var2=`"val2 with spaces -`"" | |
| $match_pattern = "(?<key>(\w+))\s*=\s*(?<value>([`"'])?([\w- _\\:\.]+)([`"'])?)" | |
| # Now parse the packageParameters using good old regular expression | |
| if ($packageParameters -match $match_pattern ) { | |
| $results = $packageParameters | Select-String $match_pattern -AllMatches | |
| $results.matches | % { | |
| Set-Variable -Name $_.Groups['key'].Value.Trim() -Value $_.Groups['value'].Value.Trim() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "syscall" | |
| "unsafe" | |
| ) | |
| var ( | |
| kernel32 = syscall.NewLazyDLL("kernel32.dll") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| set -e | |
| #Re-run the script if not using sudo/root | |
| detect_current_uid() { | |
| echo $(id -u) | |
| } | |
| rerun_script_as_root() { | |
| if [ $(detect_current_uid) -ne "0" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| # A SHORT DESCRIPTION OF YOUR SCRIPT GOES HERE | |
| # USAGE: | |
| # DESCRIPTION OF ENV VARS HERE | |
| ############################################################################### | |
| set -e # exit on command errors (so you MUST handle exit codes properly!) | |
| set -o pipefail # capture fail exit codes in piped commands | |
| #set -x # execution tracing debug messages | |
| # Get command info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Import-Module -Name D:\Temp\ACME-posh\ACMEPowerShell.psd1 | |
| $domain = "mydomain.com" | |
| $certificiatePassword = "abcd1234" | |
| $email = "[email protected]" | |
| $vault = "D:\Vault\{0}\{1}" -f $domain, [guid]::NewGuid() | |
| mkdir $vault | |
| cd $vault | |
| Initialize-ACMEVault -BaseURI https://acme-v01.api.letsencrypt.org/ | |
| New-ACMERegistration -Contacts mailto:$email |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param ([string]$SrcDBInstance, [string]$DestDBInstance, [string]$DBName) | |
| #Functions | |
| function Exec-Query ([string]$DBServer,[string]$DBName,[string]$Query) { | |
| $SqlConnection = New-Object System.Data.SqlClient.SqlConnection | |
| $SqlConnection.ConnectionString = "Server=$DBServer;Database=$DBName;Integrated Security=True" | |
| $SqlCmd = New-Object System.Data.SqlClient.SqlCommand | |
| $SqlCmd.CommandTimeout = 0 | |
| $SqlCmd.CommandText = $Query | |
| $SqlCmd.Connection = $SqlConnection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Host.UI.RawUI.WindowTitle = "-=Windows Update=-" | |
| $Script = $MyInvocation.MyCommand.Definition | |
| Write-Host -NoNewline "Checking for Updates..." | |
| $UpdateSession = New-Object -Com Microsoft.Update.Session | |
| $UpdateSearcher = $UpdateSession.CreateUpdateSearcher() | |
| $SearchResult = $UpdateSearcher.Search("IsInstalled=0 and Type='Software'") | |
| For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++) { | |
| $Update = $SearchResult.Updates.Item($X) |
NewerOlder