Skip to content

Instantly share code, notes, and snippets.

Avatar

9to5IT 9to5IT

View GitHub Profile
@9to5IT
9to5IT / Logging_Functions.ps1
Last active Dec 1, 2020
PowerShell: Logging Functions
View Logging_Functions.ps1
Function Log-Start{
<#
.SYNOPSIS
Creates log file
.DESCRIPTION
Creates log file with path and name that is passed. Checks if log file exists, and if it does deletes it and creates a new one.
Once created, writes initial logging data
.PARAMETER LogPath
@9to5IT
9to5IT / Script_Template.ps1
Last active Dec 1, 2020
PowerShell: Script Template
View Script_Template.ps1
#requires -version 2
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
@9to5IT
9to5IT / Get-ADUserInfo.ps1
Last active Nov 21, 2020
PowerShell: Get Active Directory User Information
View Get-ADUserInfo.ps1
Import-Module ActiveDirectory
$aResults = @()
$List = Get-Content ".\List.txt"
ForEach($Item in $List){
$Item = $Item.Trim()
$User = Get-ADUser -Filter{displayName -like $Item -and SamAccountName -notlike "admin-*" -and Enabled -eq $True} -Properties SamAccountName, GivenName, Surname, telephoneNumber, mail
$hItemDetails = New-Object -TypeName psobject -Property @{
@9to5IT
9to5IT / Send-Email.ps1
Last active Nov 21, 2020
PowerShell: Send Email
View Send-Email.ps1
Function Send-Email{
<#
.SYNOPSIS
Used to send data as an email to a list of addresses
.DESCRIPTION
This function is used to send an email to a list of addresses. The body can be provided in HTML or plain-text
.PARAMETER EmailFrom
Mandatory. The email addresses of who you want to send the email from. Example: "admin@9to5IT.com"
@9to5IT
9to5IT / iframe-example.html
Last active Nov 21, 2020
HTML: Disabling mouse scrolling in iFrame (Example: Disable zooming for Google Maps iframe)
View iframe-example.html
<iframe style="pointer-events:none;" src=""></iframe>
EXAMPLE Google Maps iFrame:
-----------------------------
<iframe style="pointer-events:none; border:0;" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3540.087495492481!2d153.02746689999998!3d-27.466535299999965!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6b915a1d2f662eb3%3A0x4f3c5ce2c1aafa48!2sAdelaide+St%2C+Brisbane+QLD+4000!5e0!3m2!1sen!2sau!4v1412077371383" width="600" height="300" frameborder="0"></iframe>
@9to5IT
9to5IT / Find-RegistryValues.ps1
Created Jun 23, 2016
PowerShell: Enumerate & Search Registry Key values with PowerShell
View Find-RegistryValues.ps1
$RegKey = (Get-ItemProperty 'HKCU:\Volatile Environment')
$RegKey.PSObject.Properties | ForEach-Object {
If($_.Name -like '*View*'){
Write-Host $_.Name ' = ' $_.Value
}
}
@9to5IT
9to5IT / Manage-ADOUs.ps1
Created Jul 4, 2016
PowerShell: Cleanup empty AD OUs
View Manage-ADOUs.ps1
Import-Module ActiveDirectory
#-------------------------------
# FIND EMPTY OUs
#-------------------------------
# Get empty AD Organizational Units
$OUs = Get-ADOrganizationalUnit -Filter * | ForEach-Object { If ( !( Get-ADObject -Filter * -SearchBase $_ -SearchScope OneLevel) ) { $_ } } | Select-Object Name, DistinguishedName
#-------------------------------
@9to5IT
9to5IT / PS_Script_Template_V2_NoLogs.ps1
Last active Nov 6, 2020
PowerShell: Script Template Version 2 (without logging)
View PS_Script_Template_V2_NoLogs.ps1
#requires -version 4
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
@9to5IT
9to5IT / Manage-ADComputers.ps1
Created Jul 4, 2016
PowerShell: Cleanup inactive AD computer objects
View Manage-ADComputers.ps1
Import-Module ActiveDirectory
# Set the number of days since last logon
$DaysInactive = 90
$InactiveDate = (Get-Date).Adddays(-($DaysInactive))
#-------------------------------
# FIND INACTIVE COMPUTERS
#-------------------------------
# Below are three options to find inactive computers. Select the one that is most appropriate for your requirements:
@9to5IT
9to5IT / Manage-ADUsers.ps1
Created Jul 4, 2016
PowerShell: Cleanup Inactive AD User Accounts
View Manage-ADUsers.ps1
Import-Module ActiveDirectory
# Set the number of days since last logon
$DaysInactive = 90
$InactiveDate = (Get-Date).Adddays(-($DaysInactive))
#-------------------------------
# FIND INACTIVE USERS
#-------------------------------
# Below are four options to find inactive users. Select the one that is most appropriate for your requirements:
You can’t perform that action at this time.