Skip to content

Instantly share code, notes, and snippets.

View VertigoRay's full-sized avatar
🔌
😏

Raymond Piller VertigoRay

🔌
😏
View GitHub Profile
@VertigoRay
VertigoRay / top.sls
Created August 23, 2013 00:43
pillar top.sls
base:
'*':
- is_test_computer
dev:
'is_test_computer:True':
- match: pillar
- apps.dsconfigad
- apps.munki
<#
.SYNOPSIS
Get Computers by Last Logged on User via SCCM.
.DESCRIPTION
Queries SCCM for the list of computer’s whose last logged on user matches the supplied SamAccountName.
.PARAMETER SamAccountName
For users, this is typically their EUID. Non-user accounts may vary.
.PARAMETER SiteName
SCCM Server Site Name.
.PARAMETER SCCMServer
$forestName = ([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Name
$ADsPath = [ADSI]"GC://$forestName"
$Search = New-Object System.DirectoryServices.DirectorySearcher($ADsPath)
$Search.Filter = "(&(objectCategory=User)(SamAccountName=user0123))"
$Search.FindAll()
try {
foreach ($res in $Search.FindAll())
{
$User = $res.GetDirectoryEntry()
$NewObject = New-Object PSObject
Add-Member -InputObject $NewObject NoteProperty 'DistinguishedName' $User.DistinguishedName
Add-Member -InputObject $NewObject NoteProperty 'SamAccountName' $User.SamAccountName
$OutputList += $NewObject
}
@VertigoRay
VertigoRay / sig.ps1
Last active December 22, 2015 20:09
Geeky signature line I stumbled across and modified for myself …
[string](0..9|%{[char][int](32+("54698284737179506589").substring(($_*2),2))})-replace "\s{1}\b"
[System.Collections.ArrayList] $already_done = @()
Get-Content .\AppData\Local\CloudStation\log\daemon.log -Wait | ?{ $_ -match '\[ERROR\]' } | %{
$_ -match '(\\Users\\[^\\]+\\CloudStation\\[^\]]+)' | Out-Null
if ($Matches[1] -and ($already_done -inotcontains $Matches[1])) {
Write-Host ($Matches[1] | Out-String)
Rename-Item (Resolve-Path $Matches[1]) "_$(Split-Path $Matches[1] -Leaf)"
while (-not (Test-Path $Matches[1])) {
Start-Sleep -Seconds 1
}
Remove-Item "$(Split-Path $Matches[1] -Parent)\_$(Split-Path $Matches[1] -Leaf)" -Force
@VertigoRay
VertigoRay / Django: User Email Validation without a DB
Last active May 17, 2016 03:27
Typically, when you want to validate an e-mail address, you store an activation key and expiration date in the user profile table. So you can validate it one time. Then what? Just keep storing it forever? Clear it out and have the empty columns? I wanted a disposable key that didn't have to be stored in a database. This is my solution ... http:/…
C:\Temp>env\Scripts\python.exe manage.py shell
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from myapp.settings import EMAIL_KEY_EXPIRY_TIME
>>> from user.helpers import signing_dumps_w_entropy, signing_loads_w_entropy, get_uri
>>> import urllib.parse
>>>
>>> email = 'VertigoRay@example.com'
>>> key = signing_dumps_w_entropy(email)
@VertigoRay
VertigoRay / InstallFirefox.ps1
Last active June 8, 2016 15:31
You'll want to sign the code so you can run it without changing the execution policy to unrestricted. Sample Usage: InstallFirefox.ps1 22.0 http://go.vertigion.com/PowerShell-InstallFirefox
Param (
[parameter(
Position = 0,
Mandatory = $true,
HelpMessage = 'This is the version number, such as "22.0". Valid version numbers can be found here: http://mzl.la/1c9hPmo'
)]
[string] $version,
[parameter(
Position = 1,
Mandatory = $false,
@VertigoRay
VertigoRay / CatchLineNumbers.ps1
Last active January 15, 2017 06:01
The `$MyInvocation.ScriptLineNumber` variable is not the Current Line Number. It’s the Line number from where the function that you’re in was called. Actual line numbers can be caught for an error if you catch them. Used in this comment: http://goo.gl/7oeSEL
function a {
param(
[string]$UninstallString = 'thing'
)
$MyInvocation
Write-Host -Fore Cyan "$($here.File) $($MyInvocation.MyCommand):$($MyInvocation.ScriptLineNumber)"
b
try {
Throw('Thing!!!!')
@VertigoRay
VertigoRay / Install.vbs
Last active February 23, 2017 06:00
This is a simple Install Wrapper. I use it with SCCM 2012 to allow STDOUT to be captured and sent to a log file, since STDOUT appears to be lost when deploying software as an SCCM 2012 Application.
Option Explicit
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' FIRST THINGS FIRST:
' Change this DeploymentTypeName to match the Deployment Type Name used in the Application.
' - It's just used to for the log file name.
' - For Uninstall action, append ".x" to name, such as: Application - Install.x
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim DeploymentTypeName
DeploymentTypeName = "CAS Remote - Install"
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~