Skip to content

Instantly share code, notes, and snippets.

View devblackops's full-sized avatar
🎯
Lookin' for code in all the wrong places

Brandon Olin devblackops

🎯
Lookin' for code in all the wrong places
View GitHub Profile
@devblackops
devblackops / adauth.ps1
Created February 8, 2019 04:35
PoshBot middleware hook to mark a command as approved is the user is in a certain AD group
param(
$Context,
$Bot
)
$user = $Context.Message.FromName
$adGroup = 'botusers'
$userGroups = (New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$user)))")).FindOne().GetDirectoryEntry().memberOf
if (-not ($userGroups -contains $adGroup)) {
@devblackops
devblackops / Steps.md
Last active August 29, 2022 07:33
PoshBot container in Kubernetes

PoshBot and Kubernetes

This gist is a quick example of how to run PoshBot inside Kubernetes using minikube. This will deploy PoshBot v0.11.3 inside a Linux container and expose most configuration options as environment variables. The Slack bot token is stored as a Kubernetes secret.

Secrets

Create a Kubernetes secret which includes your Slack bot token. This secret will be later be exposed to the pod as the POSHBOT_SLACK_TOKEN environment variable.

@devblackops
devblackops / Get-PerformanceCounter.ps1
Last active February 14, 2018 07:42
Solution to Iron Scripter puzzle 5
function Get-PerformanceCounter {
[cmdletbinding(DefaultParameterSetName = 'Computer')]
param(
[parameter(
ParameterSetName = 'Computer',
ValueFromPipeline = $true
)]
[ValidateNotNullOrEmpty()]
[Alias('Name')]
@devblackops
devblackops / Get-BlogXmlFeed.ps1
Last active January 31, 2018 07:55
Iron Scripter Prequel 3
function Get-BlogXmlFeed {
<#
.SYNOPSIS
Returns posts from the PowerShell.org (or other blog) XML feed.
.DESCRIPTION
Returns posts from the PowerShell.org (or other blog) XML feed and optionally opens the post link in the browser or displays the raw HTML.
.PARAMETER Uri
The XML feed URI to retrieve.
.PARAMETER OpenIn
Open post link in the operating systems' default browser or display the raw HTML.
@devblackops
devblackops / ComputerInformation.format.ps1xml
Last active March 2, 2018 18:55
Iron Scripter Prequel 2
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>ComputerInformation</Name>
<ViewSelectedBy>
<TypeName>ComputerInformation</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@devblackops
devblackops / Get-MonitorDetail.ps1
Last active January 15, 2018 04:57
Iron Scripter Prequel 1
function Get-MonitorDetail {
[OutputType('MonitorDetail')]
[cmdletbinding()]
param(
[parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias('Name')]
[string[]]$ComputerName = $env:COMPUTERNAME,
[System.Management.Automation.CredentialAttribute()]
[pscredential]$Credential

Keybase proof

I hereby claim:

  • I am devblackops on github.
  • I am devblackops (https://keybase.io/devblackops) on keybase.
  • I have a public key ASDd4DO8BeRC7l3kECkdj8Z6NHEdIeP0dNK50DRr1sBWUwo

To claim this, I am signing this object:

@devblackops
devblackops / Shorten-Url.ps1
Created September 7, 2017 03:51
PoshBot function to shorten a url
function Url {
[PoshBot.BotCommand(
Command = $false,
TriggerType = 'Regex',
Regex = '^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)|[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}[^ ]+'
)]
[cmdletbinding()]
param(
[parameter(Mandatory, ValueFromRemainingArguments)]
[object[]]$Arguments,
@devblackops
devblackops / Custom-Attribute.ps1
Last active January 23, 2017 17:12
Custom attributes attached to PowerShell function
Add-Type -TypeDefinition @"
namespace PoshBot {
public class BotCommand : System.Attribute {
public string Description { get; set; }
}
}
"@
function Foo {
[PoshBot.BotCommand(Description = 'This is a custom function description')]

OVF Thoughts

Here are few thoughts on potential improvements to the Operation Validation Framework module for executing Pester tests.

These ideas are meant to improve the flexibility of the Operation Validation Framework by adding the capability to override parameters used in Pester tests with user provided values. This would allow generic OVF modules that test core Infrastructure technologies to be published to public repositories like the PowerShell Gallery while allowing the user to tailor the tests to their environment.

Pester script defaults