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
$Active_OU = "OU=Systems,DC=fabrikam,DC=com" | |
$Stale_OU = "OU=DisabledOU,DC=fabrikam,DC=com" | |
$Log_Path = "$PSScriptRoot" | |
$ErrorActionPreference = 'Stop' | |
$Lookback = '30' | |
try { | |
# Check if OUs Exist | |
Get-ADOrganizationalUnit -Identity $Active_OU |Out-Null | |
Get-ADOrganizationalUnit -Identity $Stale_OU |Out-null |
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
$Emails = @( | |
"test@contoso.com" | |
"Otherguy@fabrikam.com" | |
) | |
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn | |
$Results = foreach ($Email in $Emails){ | |
$LLT = (Get-MailboxStatistics -Identity $Email).LastLogonTime | |
$ADLLT = (Get-ADUser -Filter {UserPrincipalName -eq $Email} -ErrorAction SilentlyContinue -Properties *) |
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 = [System.Version](Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{066E438B-355E-4A79-B1C2-2D1C71CF000C}" -ErrorAction SilentlyContinue).displayVersion | |
If ($null -ne $Version){ | |
$ProgramVersion_target = [System.Version]'8.0.0.65' | |
if($Version -ge $ProgramVersion_target){ | |
Write-Host "Found it!" | |
} | |
} |
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
$ProductName = "XM Fax CE 23.1" | |
$UninstallStrings = @("HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall") |` | |
foreach-object{Get-ChildItem -Path $_ |` | |
Get-ItemProperty |` | |
Select-Object DisplayName,UninstallString | |
}|` | |
Sort-Object |` | |
Where-Object {($_.DisplayName) -and ($_.DisplayName -match $ProductName)} |` | |
Sort-Object Displayname |` | |
Select-Object -ExpandProperty UninstallString |
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
$ScheduledTaskName = "Scriptname" | |
$Time = "00:00" | |
$Argument = ("-executionpolicy bypass -file 'C:\Scripts\Somescript.ps1'") | |
$TaskParams = @{ | |
Action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "$Argument" | |
Trigger = New-ScheduledTaskTrigger -Daily -At $Time | |
Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -RunOnlyIfNetworkAvailable | |
Principal = New-ScheduledTaskPrincipal -UserId SYSTEM -LogonType ServiceAccount -RunLevel Highest | |
Description = "Run $($ScheduledTaskName) at $Time daily" |
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
$Full_OU_Path = "" # Example: Full OU path. Right click in ADUC and go to object! "contoso.com/Systems/Windows10" | |
$NewGroup = "" # Example: Group name, displayname should work, but SAM would probably be preferrable. "New York Office" | |
Write-Output "Getting OU Path from Canonical name" | |
$OU_Path = (Get-ADOrganizationalUnit -Filter * -Properties CanonicalName,Name,DistinguishedName | Where-Object -FilterScript {$_.CanonicalName -like "*$Full_OU_Path"} | Select-Object -ExpandProperty DistinguishedName) | |
Write-Output "Found $OU_Path" | |
Write-Output "Getting Users from $NewGroup" | |
$Users = Get-ADUser -Filter * -SearchBase $OU_Path | |
Write-Output ("Found "+($users.count)+" Users") |
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
$AppId = "" | |
$Client_Secret = "" | |
$TokenURL = "" # Example: https://www.example.com/oauth2/token | |
$Hostname = "" # Example: https://www.example.com/ | |
$RequestBasePath = "" # Example: api/config/v1 | |
$APIPath = "" # Example: /users | |
$Body = @{ | |
client_id = $AppId | |
client_secret = $Client_Secret |
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
$LocalImgFolder = "Path\To\jessewolcott.github.io\assets\img" | |
$Years = (Get-Childitem -Path $LocalImgFolder).Fullname | |
$EmptyFolders = foreach ($Year in $Years){ | |
Remove-Item -Path ((Get-ChildItem -Path $Year -Recurse | Where-Object {($_.PSIsContainer -eq $True) -and ($_.GetFiles().Count -eq 0)}).FullName) | |
} |
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
$LocalImgFolder = "Path\To\jessewolcott.github.io\assets\img" | |
$Years = (Get-Childitem -Path $LocalImgFolder).Fullname | |
$ThumbNails = foreach ($Year in $Years){ | |
(Get-ChildItem -Path $Year -Recurse -Filter "*-*x*").FullName | |
} | |
foreach ($Thumbnail in $Thumbnails){ Remove-Item -Path $Thumbnail} |