Skip to content

Instantly share code, notes, and snippets.

View jberezanski's full-sized avatar

Jakub Bereżański jberezanski

View GitHub Profile
@jberezanski
jberezanski / choco-update2.log
Created April 17, 2014 20:23
chocolatey bug - Package depending on newer Chocolatey is installed using existing Chocolatey
**********************
Windows PowerShell Transcript Start
Start time: 20140416201911
Username : S9T-JB\jberezanski
Machine : S9T-JB (Microsoft Windows NT 6.1.7601 Service Pack 1)
**********************
Transcript started, output file is .\choco-update2.log
PS C:\> C:\Chocolatey\chocolateyinstall\chocolatey.ps1 install elevate.native -debug
DEBUG: Running 'Chocolatey-Install' for elevate.native with source: '', version: '', installerArguments:''
DEBUG: Running 'Chocolatey-NuGet' for elevate.native with source:''. Force? False
@jberezanski
jberezanski / setup-server.ps1
Created May 28, 2014 21:24
Script to setup Chocolatey and install packages in one go, at machine scope, compatible with Azure VM script extension.
#Requires -Version 3
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 3
# setup Chocolatey and apply patches
Write-Host 'Installing Chocolatey'
$Env:ChocolateyInstall = "$Env:SystemDrive\chocolatey"
$Env:ChocolateyBinRoot = "$Env:ChocolateyInstall\tools"
[Environment]::SetEnvironmentVariable('ChocolateyInstall', $Env:ChocolateyInstall, 'Machine')
@jberezanski
jberezanski / bla.cs
Last active February 2, 2019 00:25
PS exe output and error redirection
namespace Test
{
using System;
using System.Linq;
class Program
{
public static void Main(string[] args)
{
// pipe buffers seem to be around 4100 bytes on my system
@jberezanski
jberezanski / ChocolateyValidator.cs
Created November 16, 2014 23:03
Chocolatey package validation
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Xml;
using System.Xml.Linq;
function Grant-Permissions
{
[CmdletBinding()] Param([string] $Path, [hashtable] $Grants, [switch] $BlockInheritance, [switch] $CopyInheritedRights, [switch] $RemoveAllExistingPermissions, [string] $Inheritance = 'ObjectInherit,ContainerInherit')
Resolve-Path $Path
$acl = (Get-Item $Path).GetAccessControl('Access')
if ($BlockInheritance) { $acl.SetAccessRuleProtection($true, $false) }
if ($RemoveAllExistingPermissions) { $acl.Access | % { $acl.RemoveAccessRuleAll($_) } }
$Grants.GetEnumerator() | % { $acl.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule $($_.Key),$($_.Value),$Inheritance,'None','Allow')) }
(Get-Item $Path).SetAccessControl($acl)
(Get-Acl $Path).Access | Format-Table -AutoSize | Out-String
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
$targetComputer
)
workflow repro
{
Param (
[string] $EAP = 'Stop'
C:\> cinst -force -verbose -debug rsat
!!ATTENTION!!
The next version of Chocolatey (v0.9.9) will require -y to perform
behaviors that change state without prompting for confirmation. Start
using it now in your automated scripts.
For details on the all new Chocolatey, visit http://bit.ly/new_choco
VERBOSE: Loading module from path 'C:\ProgramData\chocolatey\chocolateyinstall\helpers\chocolateyInstaller.psm1'.
VERBOSE: Importing function 'Get-BinRoot'.
VERBOSE: Importing function 'Get-CheckSumValid'.
@jberezanski
jberezanski / rdcman 2.2 license.txt
Created February 22, 2016 10:03
RDCMan 2.2 license
MICROSOFT SOFTWARE LICENSE TERMS
MICROSOFT REMOTE DESKTOP CONNECTION MANAGER NONE
These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft
· updates,
· supplements,
· Internet-based services, and
· support services
for this software, unless other terms accompany those items. If so, those terms apply.
By using the software, you accept these terms. If you do not accept them, do not use the software.
If you comply with these license terms, you have the rights below.
@jberezanski
jberezanski / Program.cs
Created March 16, 2016 09:59
Windsor TypedFactory conventions
using System;
using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
namespace WindsorFactories
{
class Program
{
static void Main(string[] args)
@jberezanski
jberezanski / JB_CredentialEcho.psm1
Last active March 18, 2016 10:15
WMF 4.0 DSC credential decryption bug in Get-DscConfiguration
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[System.String]
$Name,