Monday, September 28, 2015

Maximus is coming . . .

This has been an ongoing project\side project for myself over the last month or two. It's more or less a PowerShell Module loaded with functions to allow you to do great things at great speeds. In all I think it contains about 30 functions, I'm sure this will continue to fluctuate.... which leads me to why I'm actually writing this, I hope to possible\hopefully treat this page as the HelpURI for Maximus.

but anyhow..... here is one, one I just wrote today actually. This is what I would call an oldie but a goodie.

Function Invoke-Speech {
<#
.SYNOPSIS  
   This functions allows you to make a computer speak.
 
.DESCRIPTION
   This function allows you to make Windows talk with the voice of either Microsoft David or Microsoft Zira.

.EXAMPLE
   PS C:\> Invoke-Speech -Gender Female -Message "You Sir, look like you are ready for a coffee break."

.NOTES  
    
    Version             : 5.0+ Verified
    
    Author/Copyright    : © Matthew Kerfoot - All Rights Reserved
    
    Email/Blog/Twitter  : mkkerfoot@gmail.com  www.TheOvernightAdmin.com  @mkkerfoot
    
    Disclaimer          : THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK
                          OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
                          While these scripts are tested and working in my environment, it is recommended 
                          that you test these scripts in a test environment before using in your production environment
                          Matthew Kerfoot further disclaims all implied warranties including, without limitation, any 
                          implied warranties of merchantability or of fitness for a particular purpose. The entire risk 
                          arising out of the use or performance of this script and documentation remains with you. 
                          In no event shall Matthew Kerfoot, its authors, or anyone else involved in the creation, production, 
                          or delivery of this script/tool be liable for any damages whatsoever (including, without limitation, 
                          damages for loss of business profits, business comerruption, loss of business information, or other 
                          pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, 
                          even if Matthew Kerfoot has been advised of the possibility of such damages

    Assumptions         : ExecutionPolicy of AllSigned (recommended), RemoteSigned or Unrestricted (not recommended)
#>
[CmdletBinding(SupportsShouldProcess)]
                Param(
                        [Parameter(Mandatory=$True, ValueFromPipelineByPropertyName=$true, HelpMessage = "David or Zira?", Position=0)]
                        $Gender,
                        [Parameter(Mandatory=$True, ValueFromPipelineByPropertyName=$true, HelpMessage = "What would you like to say?", Position=1)]
                        $Message
                     )
$Voice = New-Object -ComObject sapi.spvoice
Switch($Gender)
    {
        Male    { $Voice.Voice = $Voice.GetVoices().Item("0") ; $Voice.Speak($Message) }
        Female  { $Voice.Voice = $Voice.GetVoices().Item("1") ; $Voice.Speak($Message) }
        Default { $Voice.Speak($Message) } <# Microsofts default is Male. #>
    }
}
Invoke-Speech -Gender Female -Message "You Sir, look like you are ready for a coffee break."

Sunday, August 2, 2015

How to enable Windows 10 dark theme

Well Windows 10 was released to the general public last week on 7/29/2015. Since then I found out about a cool tweak you can make with just a slight adjustment, This will likely be added to the PC Setting context menu in the future as a toggle button but for now you still have to manually add it by creating a single registry key. Wait really that's it, Yes it is!

I threw in a quick little revert back function called Set-LightTheme just in case you don't like the dark theme(I think you are weird).



Please download functions from the Microsoft Script Repository!








Click here to download the script from the Microsoft Script Repository!









Wednesday, February 18, 2015

Enable AD Recycing Bin and prevent accidental deletion for all objects

We've all have heard about the new recycling bin feature that was introduced with Server 2008 R2, sadly the recycling bin is not enabled by default... I do not know why this is but I feel it is a huge mistake on Microsoft's part...

So I wrote a little function that will enable the recycling bin. But that's not it, it will also set all OUs, computer accounts and user accounts to be protected from accidental deletion. A log file is saved in C:\windows\temp as well.

Preventive maintenance can be the most important maintenance.

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
Function Set-ADSafeMode {
<#
 .CREATED BY:
     Matthew A. Kerfoot
 .CREATED ON:
     2/18/2015
 .Synopsis
    Enables the AD recycling Bin and prevents all OUs\computer\users accounts from accidental deletion.
 .DESCRIPTION
    Checks the AD recycling bin to see if it is enabled, if not it will enable it. Then it checks all OUs `
    in the domain to see if they are being prevented from accidental deletion, if not it will check the `
    check box that prevents them from accidental deletion. This is also done for all user and computer accounts on your domain.
 .FUNCTIONALITY
    PowerShell v2 (must be ran from a DC(the activedirectory module is required))
 #>
[CmdletBinding(SupportsShouldProcess=$True)]
param(
        [Parameter(Mandatory=$false,ValueFromPipeline=$true)]
        [string]$VerbosePreference = "SilentlyContinue",
        [Parameter(Mandatory=$false,ValueFromPipeline=$true)]
        [string]$ErrorActionPreference = "SilentlyContinue",
        [Parameter(Mandatory=$false,ValueFromPipeline=$true)]
        [string[]]$LogDate = (get-date -format "MM-d-yy-HH")
    )

Function global:Write-Verbose { [string] $Message }

Import-Module activedirectory

$VerbosePreference = "Continue"

Start-Transcript -Path "C:\Windows\temp\$LogDate.log"

#More or less turns on and\or enables logging to begin.
Write-Verbose

$Bin = Get-ADOptionalFeature -Filter 'name -like "Recycle Bin Feature"' -Properties IsDisableable | `
       Select @{ Name = "NeedsToBeEnabled" ; Expression = { ( $_.IsDisableable ) } }

   If ($Bin.NeedsToBeEnabled -eq $False)
       {
         Write-Host "The Active Directory Recycling Bin has already been enabled!" -ForegroundColor "Green"
       }
   Else
       {
         Write-Host "The Active Directory Recycling Bin NEEDS TO BE ENABLED!" -ForegroundColor "Red"

         Enable-ADOptionalFeature 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target $env:USERDOMAIN -WhatIf

         Write-Host "The Active Directory Recycling has now been enabled!!" -ForegroundColor "Red"
       }

            #Sets all OU to be protewcted against accidental deletion
            Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | `
            Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true -Verbose -WhatIf

        #Sets all user and Computer accounts to be protected from accidental deletion
        Get-ADObject -filter * -Properties ProtectedFromAccidentalDeletion | Where-Object {$_.ObjectClass -eq "user" -or $_.ObjectClass -eq "Computer"} | Set-ADObject -ProtectedFromAccidentalDeletion $true -WhatIf

    Write-Host "Script Completed Successfully!" -ForegroundColor "Green" | Tee-Object "C:\Windows\temp\$LogDate.log" -Verbose

#Ends the logfile
Stop-Transcript

 } Set-ADSafeMode

If you prevent fires you don't have to put out fires...