Skip to content

Instantly share code, notes, and snippets.

View Windos's full-sized avatar

Josh King Windos

View GitHub Profile
@Windos
Windos / PS-ScheduledJob-FullExePath.ps1
Created June 19, 2018 23:47
Changing PowerShell.exe to full path for Windows PowerShell scheduled jobs
$Option = New-ScheduledJobOption -RunElevated -RequireNetwork
Register-ScheduledJob -ScriptBlock {Add-Content -Path C:\temp\joblog.txt -Value (Get-Date)} -Name 'Test Job' -ScheduledJobOption $Option -RunNow
$CurrentAction = (Get-ScheduledTask -TaskName 'Test Job').actions
$Params = @{
Id = $CurrentAction.Id
Argument = $CurrentAction.Arguments
Execute = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
}
@Windos
Windos / TonerLevels.ps1
Created April 28, 2018 23:12
Toast with multiple progress bars, showing toner levels
# Unfortunatly, it's not currently possible to give New-BurntToastNotification multiple progressbars... so diving into all of these other functions are needed.
# I'll fix this in the next version of BurntToast.
$Text1 = New-BTText -Content 'Printer01 Toner Levels'
$BlackProgressBar = New-BTProgressBar -Status 'Black' -Value 0.3
$YellowProgressBar = New-BTProgressBar -Status 'Yellow' -Value 0.9
$MagentaProgressBar = New-BTProgressBar -Status 'Magenta' -Value 0.75
$CyanProgressBar = New-BTProgressBar -Status 'Cyan' -Value 0.1
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="__GUID1__" Version="1.0.0.0" Language="1033" Name="__NAME__" Manufacturer="__MANUFACTURER__">
<Package InstallerVersion="300" Compressed="yes"/>
<Media Id="1" Cabinet="__NAME__.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="__NAME__"/>
</Directory>
@Windos
Windos / PasswordReminder.ps1
Created January 25, 2018 10:16
Pester people with toasts when their password is close to expiring
$JobBlock = {
$ExpiryTime = Get-ADUser $env:USERNAME -Properties 'msDS-UserPasswordExpiryTimeComputed'
$Expiry = [datetime]::FromFileTime($ExpiryTime.'msDS-UserPasswordExpiryTimeComputed')
$TimeToGo = New-TimeSpan -Start (Get-Date) -End $Expiry
if ($TimeToGo -le 3) {
if ($TimeToGo.Days -gt 0) {
$Count = $TimeToGo.Days
$Unit = 'Days'
#Requires -Modules PoshRSJob, PoshPctBar, ActiveDirectory
function New-StorageReport {
<#
.SYNOPSIS
Creates a new Server Storage Report.
.DESCRIPTION
The New-StorageReport function creates a new Storage Report of local disks on all servers in a specific Organizational Unit in Active Directory.
.INPUTS
None.
.OUTPUTS
#Requires -Version 3.0
#Requires -Modules MSOnline, SkypeOnlineConnector, Microsoft.Online.SharePoint.PowerShell
<#
Required downloads
Microsoft Azure Active Directory Module for Windows PowerShell
32-bit: http://aka.ms/fohrds
64-bit: http://aka.ms/siqtee
Skype for Business Online Connector: http://aka.ms/x3kyib
$path = 'HKCU:\Software\Microsoft\Internet Explorer\Main\'
#First page
$name = 'start page'
$value = 'https://www.google.com/?gws_rd=ssl'
Set-Itemproperty -Path $path -Name $name -Value $value
#Additional pages
$name = 'Secondary Start Pages'
$value = @('https://secondpage.com/', 'https://thirdpage.co.nz')
@Windos
Windos / PuTTY-Theme-Grabber.ps1
Last active November 1, 2016 01:16
Lunch hours effort in downloading then converting PuTTY themes into a standard JSON format
$ThemeLists = 'http://putty.org.ru/themes/index.html', 'http://putty.org.ru/themes/page2.html', 'http://putty.org.ru/themes/page3.html', 'http://putty.org.ru/themes/page4.html', 'http://putty.org.ru/themes/page5.html'
foreach ($Uri in $ThemeLists)
{
$Content = Invoke-WebRequest -Uri $Uri
$List = $Content.ParsedHtml.getElementsByTagName('ol')
$Links = $List[0] | foreach {$_.getElementsByTagName('a') | where {$_.textContent -ne $null} }
foreach ($Link in $Links)
{
@Windos
Windos / Windos-ScriptingGames-2016-05.ps1
Created April 27, 2016 08:44
May 2016 Scripting Games Submission, Windos
$Group = Read-Host -Prompt 'Specify problem group'
Get-AdGroupMember -Identity $Group -Recursive |
Where-Object -FilterScript {$_.objectClass -eq 'user'} |
Get-AdUser -Properties 'EmailAddress', 'Department' |
Select-Object 'Name', 'EmailAddress', 'Department'
<#
Assumptions:
* Execution policy configured so this can run
* Person running this has proper access to Active Directory
@Windos
Windos / randomSelection.ps1
Created April 5, 2016 23:51
Random selection of Objects (Dumb and Smart)
# Dumb
$Count = ($ADComputer | Measure-Object).Count
$Random = Get-Random -Minimum 0 -Maximum $Count
$CandidateComputer = $ADComputer[$Random]
# Smart
$CandidateComputer = Get-Random -InputObject $ADComputer