Skip to content

Instantly share code, notes, and snippets.

@jhamilton09
jhamilton09 / ADPwdExpired.ps1
Created June 17, 2016 16:21
Query Active Directory for number of users with expired or expiring (in next 30 days) passwords
<#
Name of the script: ADPwdExpired.ps1
Author of the script: Jason Hamilton, www.404TechSupport.com
Version of the script: 0.1
Description: Query Active Directory for number of users with expired or expiring (in next 30 days) passwords
Version of PowerShell required: 3.0
If Elevated permissions required: No, but read access to AD is required.
If specific modules are required: No.
Ideas for future improvement:
Known errors:
@jhamilton09
jhamilton09 / sophospolicyupdate.ps1
Created June 13, 2016 21:19
Update Sophos policies at startup
<#
Name of the script: SophosPolicyUpdate
Author of the script: Jason Hamilton
Version of the script: 0.1
Where you got the idea: Needed to force VDI clients to check for new policy information from Sophos
Version of PowerShell required: 3.0
If Elevated permissions required: Yes, assigned as Startup script, so runs as SYSTEM
If specific modules are required: No
Comments about new types of constructions: N/A
Comments about specific cmdlets: N/A
@jhamilton09
jhamilton09 / scrapeweb.ps1
Created June 6, 2016 02:48
Scrape the web with PowerShell example
$site = Invoke-WebRequest -Uri https://www.404techsupport.com/
#$site.Links | Out-GridView
$title = $site.AllElements | WHERE Class -eq "entry-title" | Select-Object -First 1
$date = $site.AllElements | WHERE Class -eq "entry-time" | Select-Object -First 1
Clear-Host
Write-Host "Latest article from 404TechSupport.com:"
$title.innerText
$date.datetime
@jhamilton09
jhamilton09 / UninstallQuickTime.ps1
Created April 19, 2016 15:15
PowerShell script to uninstall QuickTime for Windows
<#
Name of the script: UninstallQuickTime.ps1
Author of the script: Jason Hamilton
Author contact information: https://www.404techsupport.com/
Version of the script: 0.1
Where you got the idea: QuickTime deprecated by Apple
Version of PowerShell required: 3.0
If Elevated permissions required: Yes
If specific modules are required: No
Comments about new types of constructions:
@jhamilton09
jhamilton09 / RemoveProfiles.ps1
Created February 17, 2016 20:48
PowerShell script to remove profiles at shutdown/restart
$profiles = $null
$profiles = Get-WMIObject -class Win32_UserProfile | Where {((!$_.Special) -and ($_.LocalPath -ne "C:\Users\Administrator") -and ($_.LocalPath -ne "C:\Users\UpdatusUser"))}
if ($profiles -ne $null) {
$profiles | Remove-WmiObject
}
Exit
@jhamilton09
jhamilton09 / PowerShellBuildingBlocks.ps1
Last active February 7, 2016 23:14
PowerShell Basics examples
#PowerShell Building Blocks
#Single-line comments begin with a pound sign.
<# Multi-line comments can span between angle brackets and pound signs.
Just like this.
The syntax highlighter in PowerShell ISE colors comments green so they're easy to see. #>
#Output
#Output to the monitor
# Get AD computers where attribute is not null
$PCs = Get-ADComputer -Filter {ms-Mcs-AdmPwd -like "*"} -Properties Name, ms-Mcs-AdmPwd, ms-Mcs-AdmPwdExpirationTime | sort Name | ft Name, ms-Mcs-AdmPwd, ms-Mcs-AdmPwdExpirationTime
$PCs
Write-Host $PCs.count "Computers with LAPS enabled"