Skip to content

Instantly share code, notes, and snippets.

John JFFail

Block or report user

Report or block JFFail

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JFFail
JFFail / Export-ADContacts.ps1
Created Jun 1, 2019
Sample of getting required properties from an AD object and storing a multi-value attribute properly in a .csv file.
View Export-ADContacts.ps1
# Get the objects with the required attributes and storing proxyAddresses properly in the .csv file.
Get-ADObject -Filter { objectClass -eq "contact" } -Server myserver.mydomain.net -SearchBase "OU=Contacts,DC=mydomain,DC=net" -SearchScope OneLevel -Properties name,givenName,sn,displayName,telephoneNumber,proxyAddresses,targetAddress,mail,mailNickname,company,department,l,physicalDeliveryOfficeName,postalCode,st,streetAddress,title | Select-Object name,givenName,sn,displayName,telephoneNumber,targetAddress,mail,mailNickname,company,department,l,physicalDeliveryOfficeName,postalCode,st,streetAddress,title,@{name="proxyAddresses"; expression={$_.proxyAddresses -join ";"}} | Export-Csv -Path .\sample.csv -Encoding ASCII -Append -NoClobber -NoTypeInformation
# Shows how to then use the proxyAddresses attribute in the future.
$allContacts = Import-Csv -Path .\sample.csv
foreach($singleContact in $allContacts) {
$proxyAddresses = $singleContact.proxyAddresses.Split(";")
}
@JFFail
JFFail / NumberClass.ps1
Created Apr 30, 2016
Example of how to overload operators with classes in PowerShell.
View NumberClass.ps1
class Number {
[int] $value = 0
Number() {
#Does nothing.
}
Number([int]$somethingElse) {
$this.value = $somethingElse
}
@JFFail
JFFail / GarageDoor.cs
Created Apr 26, 2016
Reddit Daily Programmer #260 - Garage Door Opener
View GarageDoor.cs
//Reddit Daily Programmer #260 - Easy
//https://www.reddit.com/r/dailyprogrammer/comments/4cb7eh/20160328_challenge_260_easy_garage_door_opener/
using System;
namespace DoorOpener
{
class DoorOpener
{
//Create an enumerated set for my sanity in figuring the state of the door.
enum DoorState { open, closed, opening, closing, stoppedOpening, stoppedClosing, emergencyOpening, openBlocked };
@JFFail
JFFail / change-lightswitch.ps1
Created Mar 2, 2016
Solution To Reddit Daily Programmer #255 - Playing With Light
View change-lightswitch.ps1
#https://www.reddit.com/r/dailyprogrammer/comments/46zm8m/20160222_challenge_255_easy_playing_with_light/
#Function for flipping the switches.
function FlipSwitch ($Array,$Position)
{
$currentBoolean = $Array[$Position]
if($currentBoolean)
{
$newValue = $false
}
@JFFail
JFFail / state-employee.ps1
Created Feb 16, 2016
Silly script to figure out where state employees will go to lunch based on whether or not it's pay day!
View state-employee.ps1
#Making a class for where state employees go for lunch. This does NOT account for holidays affecting when you get paid.
class StateEmployee
{
#Base properties.
[string] $firstName = ""
[string] $lastName = ""
[bool] $payDay = $false
#Default empty constructor. Seriously, don't use this.
StateEmployee()
@JFFail
JFFail / up_arrow.vbs
Created Feb 10, 2016
VBScript for the laziest possible way to continuously re-run your last command in a shell.
View up_arrow.vbs
Option Explicit
Dim objShell
set objShell = CreateObject("WScript.Shell")
While true
objShell.AppActivate("powershell")
objShell.SendKeys "{Up}"
WScript.Sleep 200
objShell.SendKeys "{Enter}"
WScript.Sleep 5000
Wend
@JFFail
JFFail / date-dilemma.ps1
Created Dec 17, 2015
Solution To Reddit Daily Programmer #245 Easy - Date Dilemma
View date-dilemma.ps1
#https://www.reddit.com/r/dailyprogrammer/comments/3wshp7/20151214_challenge_245_easy_date_dilemma/
#Solution to Reddit Daily Programmer 245 Easy.
#Function to parse from the user's specified format into a standard one.
#Void, dumps to STDOUT.
function ParseDate
{
param (
$UserFormat
)
@JFFail
JFFail / AbunDef.cs
Created Nov 30, 2015
Solution To Reddit Daily Programmer Easy #243 - Abundant and Deficient Numbers
View AbunDef.cs
using System;
using System.Collections;
//https://www.reddit.com/r/dailyprogrammer/comments/3uuhdk/20151130_challenge_243_easy_abundant_and/
//Reddit Daily Programmer Easy Challenge #243 - Abundant and Deficient Numbers
namespace AbunDef
{
class Program
{
@JFFail
JFFail / typoglycemia.cs
Created Nov 23, 2015
Reddit Daily Programmer #240 Easy - Typoglycemia
View typoglycemia.cs
using System;
using System.Collections;
using System.IO;
using System.Text.RegularExpressions;
namespace Typoglycemia
{
class Program
{
static void Main(string[] args)
@JFFail
JFFail / gameOfThrees.cs
Created Nov 3, 2015
Solution To Reddit Daily Programmer #239 - A Game Of Threes
View gameOfThrees.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GameOfThrees
{
class Program
{
You can’t perform that action at this time.