Skip to content

Instantly share code, notes, and snippets.

View brettmillerb's full-sized avatar
🏠
Working from home

Brett Miller brettmillerb

🏠
Working from home
View GitHub Profile
@brettmillerb
brettmillerb / Set-IncrementDirection
Created January 29, 2018 23:44
Set-IncrementDirection
function Set-IncrementDirection {
Param (
[Parameter(Mandatory = $true,
Position = 0,
ValueFromPipeline,
ValueFromPipelineByPropertyName)]
[int]$value,
[switch]$decrease
)
if ($PSBoundParameters.ContainsKey('decrease')) {
@brettmillerb
brettmillerb / Powershell.json
Last active February 8, 2018 16:04
VSCode Snippets
"Select-Expression": {
"prefix": "Select-Expression",
"body": [
"Select-Object @{name='${PropertyName}';expression={{\\$_.${Property}}}"
],
"description": "Creates a PSCustomObject"
},
"PSCustomObject": {
"prefix": "PSCustomObject",
"body": [
$users = get-aduser -filter {memberof -like '*'} -Properties memberof
$hash = @{}
foreach ($user in $users) {
$hash.add($user.samaccountname,$user)
}
@brettmillerb
brettmillerb / Ma-Funkshin.Tests.ps1
Created April 17, 2018 05:49
Local Region Pester Tests
Discrybe 'Ma Funkshin' {
Context 'Checkin Piramatas' {
It 'Shud Gan Radge if nen priveydid' {
{Dee-Summit} | Shud -GanRadge
}
It 'Shud write oot to screen if piramita yoosed' {
Dee-Summit -String 'Ootput' | Shud -Bee 'Ootput'
}
}
@brettmillerb
brettmillerb / HTMLTable.ps1
Last active May 16, 2018 10:47
Create Simple HTML Table
$content = Get-ADGroupMember -Identity 'domain admins' | select name, samaccountname | ConvertTo-Html -Fragment
@"
<html>
<head>
<title>test</title>
<style type='text/css'>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
function Do-Something {
param (
[Parameter(Mandatory = $True
Position = 0)]
[string]$Param1,
[Parameter(Mandatory = $False,
Position = 1)]
[string]$Param2
)
function Set-CustomACL {
<#
.SYNOPSIS
Sets a Custom ACL on a provided folder
.DESCRIPTION
Sets ACl permissions on a provided folder recursively
.PARAMETER User
The user to add to the ACL
@brettmillerb
brettmillerb / O365-Snippet.json
Created July 23, 2018 14:12
O365 License VSCode Snippet
"365-LicenseObject": {
"prefix": "O365-LicenseObject",
"body": [
"\\$enabledplans = 'SHAREPOINTWAC','YAMMER_ENTERPRISE','SHAREPOINTSTANDARD'",
"",
"#Get the licensesku and create the Disabled ServicePlans object",
"\\$licensesku = Get-AzureADSubscribedSku | Where-Object {\\$_.SkuPartNumber -eq '${License}'} ",
"\r",
"#Loop through all the individual plans and disable all plans except the one in \\$enabledplans",
"\\$disabledplans = \\$licensesku.ServicePlans | ForEach-Object -Process { ",
@brettmillerb
brettmillerb / New-PassPhrase.ps1
Last active August 2, 2018 14:31
Generate New Passphrases instead of Passwords
function New-PassPhrase {
<#
.SYNOPSIS
Generate PassPhrase for account logins
.DESCRIPTION
Generate a PassPhrase from a pre-defined list of words instead of using random character passwords
.PARAMETER Length
Length of PassPhrase to be generated
function Get-ADSystemInfo{
<#
.LINK
https://technet.microsoft.com/en-us/library/ee198776.aspx
#>
$properties = @(
'UserName',
'ComputerName',
'SiteName',
'DomainShortName',