This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.1.0", | |
"tasks": [ | |
{ | |
"taskName": "build", | |
"command": "powershell", | |
"args": [ | |
"-ExecutionPolicy", | |
"Unrestricted", | |
"Merge-Script -Script '${file}' -Bundle -OutputPath '${fileDirname}\\out' -OutputType Script;", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remote Code | |
$SB = { | |
param($file) | |
$SHA1 = New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider | |
$stream = [System.io.file]::Open($file, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read) | |
$hash = [System.BitConverter]::ToString($SHA1.ComputeHash($stream)) | |
$hash = $hash.replace('-','') | |
$hash = "0x$hash" | |
$stream.Close() | |
return $hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-RSFileHash { | |
<# | |
.Synopsis | |
Returns an MD5 filehash when given a file path | |
.DESCRIPTION | |
Returns an MD5 filehash when given a file path | |
.EXAMPLE | |
Get-RSFileHash -Filename c:\temp\filetohash.txt | |
.EXAMPLE | |
Get-ChildItem c:\temp\*.txt | get-rsfilehash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$DN = 'CN=Username,OU=OrganizationalUnit,DC=lab,DC=local' | |
$pattern = '(?i)DC=\w{1,}?\b' | |
([RegEx]::Matches($DN, $pattern) | ForEach-Object { $_.Value }) -join ',' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Reset-RDPListener { | |
param($ComputerName) | |
$ts = Get-WMIObject -class win32_Terminalservicesetting -comp $ComputerName | |
$ts.SetAllowTSConnections($false) | |
$ts.SetAllowTSConnections($true) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-RealName { | |
param ($SAMAccountName) | |
Get-QADUser -SamAccountName $SAMAccountName | select samaccountname, displayname, office, telephonenumber | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-SamAccountName { | |
param ($DisplayName) | |
Get-QADUser -DisplayName "*$DisplayName*" | select samaccountname, displayname, office, telephonenumber | |
} |