Skip to content

Instantly share code, notes, and snippets.

View shinjijai's full-sized avatar

shinjijai shinjijai

View GitHub Profile
@shinjijai
shinjijai / Get-BaseOU.ps1
Last active May 11, 2018 14:32
Get a list of OU with filter
function Format-DisplayList {
<#
.DESCRIPTION
Display an array larger than certain members into nice column(s) for
easy readability. Added the ability to either use a number system or dashes
to display the list.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,
@shinjijai
shinjijai / Connect-Exchange.ps1
Last active April 24, 2018 16:58
Function that'll connect to either on premise Exchange or Office 365 Exchange
#Requires -Version 4.0
#Requires -modules ActiveDirectory
function Connect-Exchange {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,
HelpMessage="User admin credentials")]
[System.Management.Automation.PSCredential]$Credential,
[Parameter(Mandatory=$false)]
$URI = "https://outlook.office365.com/powershell-liveid/",
@shinjijai
shinjijai / Find-DuplicateFiles.ps1
Last active April 17, 2018 17:17
Takes an array of folder locations and exports a CSV file with the file hash, name and directory name.
$FolderLocation = @("FilePath1", "FilePath2", "FilePath3")
$AllFiles = @()
$FileList = @()
foreach($RootFolder in $FolderLocation) {
$AllFiles += Get-ChildItem -Path $RootFolder -File -Recurse
}
foreach($File in $AllFiles) {
$FileHash = Get-FileHash $File.PSPath | Select-Object Hash -ExpandProperty Hash
$FileInfo = [PSCustomObject]@{
Folder = $File.DirectoryName
@shinjijai
shinjijai / Disable-ExpiredAccounts.ps1
Last active January 17, 2018 20:08
Disable User accoiunts that are expired
#Requires -Version 4.0
#Requires -modules ActiveDirectory
function Send-AlertsMessage {
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[String]$ToAddress,
[Parameter(Mandatory=$false)]
[String]$FromAddress = "_SERVICEACCOUNT@BLAH.COM",
[Parameter(Mandatory=$false)]
@shinjijai
shinjijai / New-SecurePassFile.ps1
Last active October 10, 2017 16:25
Store encrypted password into a file
function New-SecurePass{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[System.Security.SecureString]$SecurePassword,
[Parameter(Mandatory=$false)]
[string]$FileName = "EncryptedPassword",
[Parameter(Mandatory=$false)]
[string]$KeyFilePath = ".\",
[Parameter(Mandatory=$false)]