Skip to content

Instantly share code, notes, and snippets.

View arbickerstaff's full-sized avatar

Ashley Bickerstaff arbickerstaff

  • Glasgow, Scotland
View GitHub Profile
@arbickerstaff
arbickerstaff / ToBase64String.ps1
Created April 29, 2016 13:57
Convert an image into a Base64 String within PowerShell
$content = Get-Content -path C:\blah.png -encoding byte
$base64 = [System.Convert]::ToBase64String($content)
$base64 | Out-File C:\encoded.txt
@arbickerstaff
arbickerstaff / EmptyGroup.ps1
Created April 18, 2016 08:34
Get all Empty AD Groups
Get-ADGroup -Filter * -Properties Members | where { $_.Members.Count -eq 0 }
@arbickerstaff
arbickerstaff / PasswordLastSet.ps1
Created April 18, 2016 08:27
Prompt for username input then check when password was last changed. Send to screen.
$UserNameEntry = Read-Host -Prompt 'Enter Username'
$PasswordLastSet = (Get-ADUser -Identity $UserNameEntry -Properties PasswordLastSet).PasswordLastSet
Write-output ($UserNameEntry + " : " + $PasswordLastSet)
@arbickerstaff
arbickerstaff / Date.ps1
Created April 18, 2016 08:25
Date Formmating
# Date Formatting
$datestring = (Get-Date).ToString("s").Replace(":","-")
(Get-Date -format g)
@arbickerstaff
arbickerstaff / InputPrompt.ps1
Created April 18, 2016 08:25
Prompt for input to then be used within script
# Prompt for entry
$UserNameEntry = Read-Host -Prompt 'Enter Username'
@arbickerstaff
arbickerstaff / Out-Excel.ps1
Created April 18, 2016 08:01
Creates a function to call in script sending output to Excel a bit like Out-GridView.
function Out-Excel {
param($Path = "$env:temp$(Get-Date -Format yyyyMMddHHmmss).csv")
$input | Export-CSV -Path $Path -UseCulture -Encoding UTF8 -NoTypeInformation
Invoke-Item -Path $Path
}
@arbickerstaff
arbickerstaff / EnableMailbox.ps1
Created January 12, 2016 11:50
Active Directory + Exchange 2007 -
Import-Module ActiveDirectory
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
$list = Import-Csv "C:\Users.csv"
foreach ($entry in $list) {
Enable-Mailbox -Identity ("User\" + $entry.samAccountName) -Database "Enter db here"
}
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
@arbickerstaff
arbickerstaff / Remove_From_Group.ps1
Last active October 4, 2021 18:13
Active Directory -
Import-Module ActiveDirectory
$users = Import-CSV ".\users.csv"
foreach ($user in $users) {
Remove-ADGroupMember -Identity $user.GroupName -Member $user.SamAccountName
}