Change windows theme based on season

A couple of Sundays ago I was laying in the couch with a small hangover and my kids were watching cartoons I got an idea that I would like to have my theme and desktop wallpaper change with the weather season. Since I am Swedish I wanted the wallpapers to be from my home country. I found out that Microsoft had season themes with desktop pictures from Sweden on their homepage, so I could easily use Bits to download the themes. I made 5 variables with the days of each weather season stored in them and then used a switch to install the correct theme based on season. It worked like a charm and I scheduled a task on my main computer on each login so it will change theme as when season change. I also sync themes on my other computers that use Windows 8.1 and 10 so i get the correct season theme on all my computers.

$Ssu_theme = "SwedishSummer.themepack"
$Ssp_theme = "SwedishSpring.themepack"
$Win_theme = "SwedishWinter.themepack"
$Aut_theme = "SwedishAutumn.themepack"

$Ssu = "http://download.microsoft.com/download/A/7/4/A7448DBD-5723-44C1-BBB1-51FB285DEB0E/" + $Ssu_theme
$Ssp = "http://download.microsoft.com/download/A/7/4/A7448DBD-5723-44C1-BBB1-51FB285DEB0E/" + $Ssp_theme
$Win = "http://download.microsoft.com/download/A/7/4/A7448DBD-5723-44C1-BBB1-51FB285DEB0E/" + $Win_theme
$Aut = "http://download.microsoft.com/download/A/7/4/A7448DBD-5723-44C1-BBB1-51FB285DEB0E/" + $Aut_theme


$reg_path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\themes"
$reg = Get-ItemProperty -Path $reg_path

$Ssu_theme_reg = "Swedish S\Swedish S.theme"
$Ssp_theme_reg = "Swedish S (2)\Swedish S.theme"
$win_theme_reg = "Swedish W\Swedish W.theme"
$Aut_theme_reg = "Swedish A\Swedish A.theme"



$summer = 152..243
$spring = 60..151
$winter1 = 335..365
$winter2 = 1..59
$winter = $winter1 + $winter2
$Autum = 244..334

$date = get-date

switch ($date.DayOfYear)
{
    {$_ -in $summer} 
    {
    if ($reg.CurrentTheme -notlike "*$Ssu_theme_reg*")
{ if (Test-Path c:\temp\$Ssu_theme)
  {   & c:\temp\$Ssu_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')

      
  }
  else
  {Start-BitsTransfer $Ssu -Destination c:\temp\$Ssu_theme
  & c:\temp\$Ssu_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')
}
  }
    }
    {$_ -in $spring} {
    if ($reg.CurrentTheme -notlike "*$Ssp_theme_reg*")
{ if (Test-Path c:\temp\$Ssp_theme)
  {   & c:\temp\$Ssp_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')

      
  }
  else
  {Start-BitsTransfer $Ssp -Destination c:\temp\$Ssp_theme
  & c:\temp\$Ssp_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')
}
  }
    }
    {$_ -in $winter} {
        if ($reg.CurrentTheme -notlike "*$win_theme_reg*")
{ if (Test-Path c:\temp\$win_theme)
  {   & c:\temp\$win_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')

      
  }
  else
  {Start-BitsTransfer $win -Destination c:\temp\$win_theme
  & c:\temp\$win_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')
}
  }
    }
    {$_ -in $Autum} {
    if ($reg.CurrentTheme -notlike "*$aut_theme_reg*")
{ if (Test-Path c:\temp\$aut_theme)
  {   & c:\temp\$aut_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')

      
  }
  else
  {Start-BitsTransfer $aut -Destination c:\temp\$aut_theme
  & c:\temp\$aut_theme
  Start-Sleep -Seconds 2
$shell = New-Object -ComObject WScript.Shell; $shell.AppActivate('Personalization'); $shell.SendKeys('%{F4}')
}
  }}
  }

Collect users with a certain attribute and clear the attribute.

Last week a college working with identity management needed a script to clear a dummy AD-attribute. All users that don´t have a telephone number needed a dummy phone number because of an external calendar system. This script collects all users with the telephoneNumber attribute 99999 in an variable and then exports the users in the variable with all their attributes before it clears the telephoneNumber attribute. We use it as an scheduled task.

Import-Module Activedirectory
# get date and time tog get the backup unique.
$date = get-date -Format yyyymmddHHmm
# Samla in användare som har 99999 som telefonnummer
# Collect users that hav 99999 as telephonenumber attribute.
$users = Get-ADUser -filter 'telephoneNumber -like "99999"' -Properties *

# Check if backup-file exists, if it exists stop the script and alert the usr, if it not exists export all users that is about to get the attribute changed.
if (Test-Path c:\temp\backup_$date.txt)
{Write-Host  "vänta en minut backupfilen finns redan" -BackgroundColor Yellow -ForegroundColor Red
    
}

else
{
Write-Host "exporterar användare" -BackgroundColor Black -ForegroundColor White
$users | Export-Csv c:\temp\backup_$date.txt -Encoding UTF8 -NoTypeInformation

foreach ($user in $users)
{
Write-Host "Clearing attribute on $user"
  Set-ADUser -Identity $user -Clear telephoneNumber
}
}