Skip to content

Instantly share code, notes, and snippets.

View RandomNoun7's full-sized avatar
🚁
Puppetizing and PowerShelling all the things.

Bill Hurt RandomNoun7

🚁
Puppetizing and PowerShelling all the things.
View GitHub Profile
#Requires -Version 4
function Get-SNMPAgent
{
<#
.SYNOPSIS
Reads the SNMP Agent string value from a Windows computers registry.
.DESCRIPTION
Uses the Microsoft.Win32.RegistryKey class to open registry keys on remote computers even if WinRM is not enabled.
Output is a series of PSObject's with two string properties: computer and agent.
@RandomNoun7
RandomNoun7 / Invoke-BHSqlQuery.ps1
Created March 30, 2016 00:13
Custom Invoke SQL Query Script after I got annoyed with SQLPS from SQL 2008r2
function Invoke-BHSQLProc
{
param
(
[cmdletBinding()]
[string]$server = $env:COMPUTERNAME,
[parameter(Mandatory = $true)]
[string]$dbname,
[parameter(Mandatory = $true)]
[string]$proc,

Keybase proof

I hereby claim:

  • I am randomnoun7 on github.
  • I am bhurt (https://keybase.io/bhurt) on keybase.
  • I have a public key ASA9h9C7D2wRavUVa1WzdWtNP36VZgUs5x0Bz72dN7IQLwo

To claim this, I am signing this object:

@RandomNoun7
RandomNoun7 / should_be_broken.txt
Created December 21, 2017 20:30
should_not_break ran ok on windows2012. Should_be_broken ran on 2008 and failed to skip properly.
Printing Environment
BEAKER_debug=true
BEAKER_destroy=no
BEAKER_keyfile=~/.ssh/id_rsa-acceptance
BEAKER_PE_DIR=http://enterprise.delivery.puppetlabs.net/2017.3/ci-ready
BEAKER_setfile=spec/acceptance/nodesets/default.yml
BUNDLE_BIN=.bundle/bin
BUNDLE_PATH=.bundle//gems
EVENT_NOEPOLL=1
@RandomNoun7
RandomNoun7 / Pipelines-Rest-Example.ps1
Last active September 25, 2018 07:15
Pipelines New App Example
$apiToken = $env:ApiToken
$username = $env:Username
$apiUrl = $env:ApiUrl
$appsUri = "https://$apiUrl/$Username/apps?apiToken=$ApiToken"
$appsCollection = Invoke-RestMethod -Uri $appsUri
Write-Output "Existing Apps"
Write-Output $appsCollection.apps.name
@RandomNoun7
RandomNoun7 / evaluation.md
Last active November 20, 2018 22:52
virtualdesktops-sqlservewalwayson Evaluation

Does the module work?

I was not able to get the module to function. It looks like the module should probably work if the underlying dsc resources worked properly. As far as I can tell we have vendered in a version of a dsc resource called dsc_userrightsassignment that has a bug. It is unable to assign rights to local administrator account. When searching for that account to give it rights, it uses a set of functions defined in a file called SecurityPolicyResourceHelpers.psm1. We are currently vendoring version 2.2.0 of that dsc resource module. Latest is 2.5.0, and the diff (You will have to search for DSCResources/SecurityPolicyResourceHelper/SecurityPolicyResourceHelper.psm1 to find the file diff in question.) has a lot of improved code including proper error handling which would most likely solve the error.

The error in question prevents the run from completing.

@RandomNoun7
RandomNoun7 / sort-testing.ps1
Last active November 7, 2019 15:23
Sort build stages
$events = @(
[PSCustomObject]@{type = 'phase'; name = 'Build API'; parentID = '1'; id = '2'}
[PSCustomObject]@{type = 'task'; name = 'Checkout'; parentID = '3'; id = '5'}
[PSCustomObject]@{type = 'task'; name = 'Nuget Tool Installer'; parentID = '3'; id = '6'}
[PSCustomObject]@{type = 'task'; name = 'use .NET Core SDK'; parentID = '3'; id = '7'}
[PSCustomObject]@{type = 'job'; name = 'Build API'; parentID = '2'; id = '3'}
[PSCustomObject]@{type = 'task'; name = 'Initialize Job'; parentID = '3'; id = '4'}
[PSCustomObject]@{type = 'Stage'; name = 'Deploy C1'; parentID = ''; id = '8'}
[PSCustomObject]@{type = 'Phase'; name = 'Deploy API to SIT'; parentID = '8'; id = '9'}
[PSCustomObject]@{type = 'job'; name = 'Deploy API C1'; parentID = '9'; id = '10'}
@RandomNoun7
RandomNoun7 / github_org_runner_scanner.ps1
Created June 17, 2020 21:15
Scan Github Org For Internal Runners
Install-Module PowerShellForGithub
# Enter anything for username, and your token for the password.
# This sets it globally for all future runs.
Set-GitHubAuthentication
$repos = Get-GithubRepository -OrganizationName puppetlabs
foreach ($repo in $repos) {
$runner = Invoke-GHRestMethod -UriFragment "/repos/$($_.full_name)/actions/runners" -Method Get -ErrorAction SilentlyContinue
{
"puppet_task_version": 1,
"supports_noop": false,
"description": "Stop or restart a service or list of services on a node.",
"parameters": {
"service": {
"description": "The name of the service, or a list of service names to stop.",
"type": "Variant[Array[String],String]"
},
"norestart": {