Skip to content

Instantly share code, notes, and snippets.

View rodmhgl's full-sized avatar
🐒
Just monkeyin' around

Rod Stewart rodmhgl

🐒
Just monkeyin' around
View GitHub Profile
@rodmhgl
rodmhgl / Create-PowerShellHere.ps1
Created January 9, 2017 16:55
Create PowerShell Here Right-Click Explorer Option
<#
.SYNOPSIS
Creates a right-click (or shift right-click) explorer menu option to open Powershell at the selected location
.DESCRIPTION
Creates a right-click (or shift right-click) explorer menu option to open Powershell at the selected location
.EXAMPLE
.\Create-PowerShellHere.ps1
Will create a right-click menu with the default text, "Open PowerShell Here"
.EXAMPLE
function Export-Log {
<#
.Synopsis
Writes tab-separated log messages to a specified file.
.DESCRIPTION
Writes tab-separated log messages to a specified file.
.EXAMPLE
Export-Log -messagetype ERROR -logfile c:\temp\log.csv -message "Encountered error performing operation."
Will log an error message to the log located in c:\temp\log.csv
.EXAMPLE
@rodmhgl
rodmhgl / tasks.json
Last active May 23, 2017 21:55
I always end up with that one customer who wants me to email them the PS1 file. I've always hated having to do the manual copy and rename, so let's automate it until they get actual source control.
{
"version": "0.1.0",
"tasks": [
{
"taskName": "build",
"command": "powershell",
"args": [
"-ExecutionPolicy",
"Unrestricted",
"Merge-Script -Script '${file}' -Bundle -OutputPath '${fileDirname}\\out' -OutputType Script;",
@rodmhgl
rodmhgl / Get-GitTips.ps1
Last active June 30, 2017 22:14
Grabs a random tip from the Git-Tips Github repository
Function Get-GitTip {
<#
.SYNOPSIS
Grabs a random tip from the Git-Tips Github repository
.DESCRIPTION
Grabs a random tip from the Git-Tips Github repository
Designed to be used as part of my $profile to receive a daily tip
.PARAMETER URI
@rodmhgl
rodmhgl / Reset-Password.ps1
Last active July 12, 2017 23:41
For James Espinoza - Help Desk script to reset user's password
[cmdletbinding()]
param(
# Give the user the opton to user a -User command line parameter
[string]$User = $(Read-Host "Enter a samAccountName")
)
# Show $User details on console
# Consider which properties you actually need
# Using * is a memory hog and unnecesary
try {
@rodmhgl
rodmhgl / getSpace.ps1
Last active August 17, 2017 15:44
Just playing around
function getSpace {
[cmdletbinding()]
param(
[string]$space = ' ',
[string]$separator = '-',
[int]$depth
)
Write-Output $(($space + $separator) * $depth)
}
@rodmhgl
rodmhgl / Show-Blocks.ps1
Created November 7, 2017 00:58
Just demoing Begin, Process, End with some pseudo-code
Function Give-UserLicense ($User) {
#return $true
}
Function Add-UserLicenses {
param(
[Parameter(
Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromPipeline = $true
)][String[]]$Username
@rodmhgl
rodmhgl / jobdemo.ps1
Last active November 8, 2017 15:13
Quick PowerShell Jobs Demo
# functions.ps1 contains functions like Get-Services, Get-Process,
# Get-CustomFunction1, Get-CustomFunction2, etc. that execute
# locally on the remote computer. Output is ex
function Get-CustomFunction {
sleep 2
write-output $true
}
$NetBiosName = "DOMAIN"
(Get-Acl c:\temp).Access |
Where-Object {
($_.IdentityReference -split '\\') -eq $NetBiosName
} |
ForEach-Object {
$SAMAccountName = ($_.IdentityReference -split '\\')[1]
$Class =( Get-ADObject -Filter {Samaccountname -eq $SAMAccountName}).objectclass
switch ($Class) {
@rodmhgl
rodmhgl / Data.xml
Last active April 2, 2018 16:02
XPath Troubleshooting
<?xml version="1.0" encoding="utf-8"?>
<bpr:release xmlns:bpr="http://www.blueprism.co.uk/product/release">
<bpr:name>BPRelease v3</bpr:name>
<bpr:release-notes>
</bpr:release-notes>
<bpr:created>2018-03-31 04:20:16Z</bpr:created>
<bpr:package-id>4</bpr:package-id>
<bpr:package-name>BPRelease_Info Troubleshooting</bpr:package-name>
<bpr:user-created-by>admin</bpr:user-created-by>
<bpr:contents count="2">