Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Logged into org account

Brett Miller brettmillerb

💭
Logged into org account
View GitHub Profile
View Set-IncrementDirection
function Set-IncrementDirection {
Param (
[Parameter(Mandatory = $true,
Position = 0,
ValueFromPipeline,
ValueFromPipelineByPropertyName)]
[int]$value,
[switch]$decrease
)
if ($PSBoundParameters.ContainsKey('decrease')) {
View Powershell.json
"Select-Expression": {
"prefix": "Select-Expression",
"body": [
"Select-Object @{name='${PropertyName}';expression={{\\$_.${Property}}}"
],
"description": "Creates a PSCustomObject"
},
"PSCustomObject": {
"prefix": "PSCustomObject",
"body": [
View Get-Users.ps1
$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 Apr 17, 2018
Local Region Pester Tests
View Ma-Funkshin.Tests.ps1
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
Create Simple HTML Table
View HTMLTable.ps1
$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;
View MandatoryParams.ps1
function Do-Something {
param (
[Parameter(Mandatory = $True
Position = 0)]
[string]$Param1,
[Parameter(Mandatory = $False,
Position = 1)]
[string]$Param2
)
View Set-CustomACL.ps1
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 Jul 23, 2018
O365 License VSCode Snippet
View O365-Snippet.json
"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 Aug 2, 2018
Generate New Passphrases instead of Passwords
View New-PassPhrase.ps1
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
View ADSystemInfo.ps1
function Get-ADSystemInfo{
<#
.LINK
https://technet.microsoft.com/en-us/library/ee198776.aspx
#>
$properties = @(
'UserName',
'ComputerName',
'SiteName',
'DomainShortName',