├── GAT ├── Functions │ ├── fuck.ps1 │ ├── Test-Administrator.ps1 │ ├── sudo.ps1 │ ├── Disable-WindowsTelemetry.ps1 │ ├── Enable-RDP.ps1 │ ├── Get-WeatherReport.ps1 │ ├── Expand-ShortURL.ps1 │ ├── Get-EmlFileInfo.ps1 │ ├── Save-Screenshot.ps1 │ ├── Get-ProfileBanner.ps1 │ ├── Remove-AppxBloat.ps1 │ ├── Disable-Unused2016Services.ps1 │ └── Set-WindowsKey.ps1 ├── GAT.psm1 └── GAT.psd1 ├── README.md └── LICENSE /GAT/Functions/fuck.ps1: -------------------------------------------------------------------------------- 1 | Function fuck { 2 | $cmd = (Get-History ((Get-History).Count))[0].CommandLine 3 | Write-Output "Running $cmd in $PWD" 4 | sudo powershell -NoExit -Command "pushd $PWD; $cmd" 5 | } 6 | -------------------------------------------------------------------------------- /GAT/Functions/Test-Administrator.ps1: -------------------------------------------------------------------------------- 1 | Function Test-Administrator { 2 | $AdminUserTest = [Security.Principal.WindowsIdentity]::GetCurrent(); 3 | (New-Object Security.Principal.WindowsPrincipal $AdminUserTest).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) 4 | } 5 | -------------------------------------------------------------------------------- /GAT/GAT.psm1: -------------------------------------------------------------------------------- 1 | # Set PSScriptRoot 2 | If (!($PSScriptRoot)) { 3 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 4 | } 5 | 6 | # Dot source the modules functions 7 | $GATFunctions = Get-ChildItem -Path "$PSScriptRoot\Functions\*.ps1" 8 | $GATFunctions | ForEach-Object {. $_.FullName} 9 | Export-ModuleMember -Function $GATFunctions.BaseName 10 | -------------------------------------------------------------------------------- /GAT/Functions/sudo.ps1: -------------------------------------------------------------------------------- 1 | Function sudo { 2 | If ($args[0] -eq '!!') { 3 | fuck 4 | } Else { 5 | $file, [string]$arguments = $args 6 | $psi = New-Object System.Diagnostics.ProcessStartInfo $file 7 | $psi.Arguments = $arguments 8 | $psi.Verb = "runas" 9 | $psi.WorkingDirectory = Get-Location 10 | [System.Diagnostics.Process]::Start($psi) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /GAT/Functions/Disable-WindowsTelemetry.ps1: -------------------------------------------------------------------------------- 1 | Function Disable-WindowsTelemetry { 2 | # Disable CEIP Tasks 3 | Get-ScheduledTask -TaskPath '\Microsoft\Windows\Customer Experience Improvement Program\' | Disable-ScheduledTask 4 | # Only send security related telemetry [Enterprise] or basic [All other editions] 5 | New-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\DataCollection' -Name AllowTelemetry -Value 0 -Force 6 | } 7 | -------------------------------------------------------------------------------- /GAT/Functions/Enable-RDP.ps1: -------------------------------------------------------------------------------- 1 | Function Enable-RDP { 2 | # Allow Remote Desktop in Firewall 3 | Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Enabled True 4 | # Enable Remote Desktop in Registry 5 | New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name UserAuthentication -Value 0 -Force 6 | New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0 -Force 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GAT 2 | Gavin's Admin Toolkit 3 | 4 | Functions: 5 | 6 | - `Disable-WindowsTelemetry` - Sets telemetry to only send security or basic information. 7 | - `Enable-RDP` - Enables remote desktop and adds firewall exceptions. 8 | - `fuck` - Runs the previous command in an elevated PowerShell console. 9 | - `Get-ProfileBanner` - Displays a banner with system information about the host. 10 | - `Remove-AppxBloat` - Removes all AppX packages not in the pre-defined RequiredPackages variable. 11 | - `Set-WindowsKey` - Sets the Windows Product Key. 12 | - `sudo` - Runs an application with elevated privileges. 13 | - `Test-Administrator` - Tests to see if the PowerShell console is running with elevated permissions. 14 | -------------------------------------------------------------------------------- /GAT/Functions/Get-WeatherReport.ps1: -------------------------------------------------------------------------------- 1 | Function Get-WeatherReport { 2 | [Cmdletbinding()] 3 | Param( 4 | [Parameter(HelpMessage = 'Enter name of the City to get weather report')] 5 | [string]$City # Not Required 6 | ) 7 | 8 | Begin { 9 | If ($psISE) { 10 | Write-Warning -Message 'This function does not display correctly in Windows PowerShell ISE, please use the console or VSCode' 11 | } 12 | } 13 | 14 | Process { 15 | ForEach ($Item in $City) { 16 | Try { 17 | $Response = Invoke-RestMethod "wttr.in/$City" -UserAgent curl 18 | $Weather = $Response -split "`n" 19 | If ($Weather) { 20 | $Weather[0..6] 21 | } 22 | } Catch { 23 | $_.Exception.Message 24 | } 25 | } 26 | } 27 | 28 | End {} 29 | } 30 | -------------------------------------------------------------------------------- /GAT/Functions/Expand-ShortURL.ps1: -------------------------------------------------------------------------------- 1 | Function Expand-ShortURL { 2 | Param( 3 | [Parameter(Mandatory = $True,HelpMessage = 'Short URL to be expanded',ValueFromPipeline = $True)] 4 | [ValidateNotNullOrEmpty()] 5 | [string[]] $URL 6 | ) 7 | 8 | Begin {} 9 | 10 | Process { 11 | ForEach ($Item in $URL) { 12 | Try { 13 | $Request = Invoke-WebRequest -Uri $Item -MaximumRedirection 0 -ErrorAction Ignore 14 | If ($Request.StatusCode -ge 300 -and $Request.StatusCode -lt 400) { 15 | $LongURL = $Request.Headers.Location 16 | } 17 | 18 | [PSCustomObject]@{ 19 | ShortURL = $Item 20 | LongURL = $LongURL 21 | } 22 | } Catch { 23 | $_.Exception.Message 24 | } 25 | } 26 | } 27 | 28 | End {} 29 | } 30 | -------------------------------------------------------------------------------- /GAT/Functions/Get-EmlFileInfo.ps1: -------------------------------------------------------------------------------- 1 | Function Get-EmlFileInfo { 2 | Param ( 3 | [Parameter(Mandatory=$True,HelpMessage = 'Mandatory. Path to the eml file.')] 4 | [ValidateScript({ 5 | If (-Not ($_ | Test-Path) ) { 6 | Throw 'File does not exist' 7 | } 8 | 9 | If (-Not ($_ | Test-Path -PathType Leaf) ) { 10 | Throw 'Must be a file. Folder paths are not allowed.' 11 | } 12 | 13 | If ($_ -notmatch '(\.eml)') { 14 | Throw 'The file specified must be of type eml' 15 | } 16 | 17 | Return $True 18 | })] 19 | [System.IO.FileInfo]$EmlFileName 20 | ) 21 | 22 | Begin {} 23 | 24 | Process { 25 | $AdoDbStream = New-Object -ComObject ADODB.Stream 26 | $AdoDbStream.Open() 27 | $AdoDbStream.LoadFromFile($EmlFileName) 28 | $CdoMessage = New-Object -ComObject CDO.Message 29 | $CdoMessage.DataSource.OpenObject($AdoDbStream,'_Stream') 30 | 31 | Return $CdoMessage 32 | } 33 | 34 | End {} 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Gavin Eke 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /GAT/Functions/Save-Screenshot.ps1: -------------------------------------------------------------------------------- 1 | Function Save-Screenshot { 2 | [Cmdletbinding()] 3 | Param( 4 | # Specify the directory to create the files in. 5 | # The files names are a combination of the display name and a timestamp 6 | [ValidateScript({Test-Path -Path "$_" -PathType 'Container'})] 7 | [Alias("Path")] 8 | [string]$Directory = ".", 9 | 10 | #The lower the number specified, the higher the compression and therefore the lower the quality of the image. Zero would give you the lowest quality image and 100 the highest. 11 | [ValidateRange(0,100)] 12 | [int]$Quality = 100, 13 | 14 | # By default, only the PRIMARY display is captured 15 | [Switch]$AllScreens 16 | ) 17 | 18 | Begin { 19 | Set-StrictMode -Version 2 20 | Add-Type -AssemblyName System.Windows.Forms 21 | } 22 | 23 | Process { 24 | If ($AllScreens) { 25 | $Capture = [System.Windows.Forms.Screen]::AllScreens 26 | } Else { 27 | $Capture = [System.Windows.Forms.Screen]::PrimaryScreen 28 | } 29 | 30 | ForEach ($Item in $Capture) { 31 | $FileName = '{0}-{1}.jpg' -f (Join-Path (Resolve-Path $Directory) ($Item.DeviceName -split "\\")[3]), (Get-Date).ToString('yyyyMMdd_HHmmss') 32 | $Bitmap = New-Object System.Drawing.Bitmap($Item.Bounds.Width, $Item.Bounds.Height) 33 | $Image = [System.Drawing.Graphics]::FromImage($Bitmap) 34 | $Image.CopyFromScreen($Item.Bounds.Location, (New-Object System.Drawing.Point(0,0)), $Item.Bounds.Size) 35 | $Image.Dispose() 36 | $EncoderParam = [System.Drawing.Imaging.Encoder]::Quality 37 | $EncoderParamSet = New-Object System.Drawing.Imaging.EncoderParameters(1) 38 | $EncoderParamSet.Param[0] = New-Object System.Drawing.Imaging.EncoderParameter($EncoderParam, $Quality) 39 | $JPGCodec = [System.Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | Where-Object {$_.MimeType -eq 'image/jpeg'} 40 | $Bitmap.Save($FileName, $JPGCodec, $EncoderParamSet) 41 | $FileSize = [INT]((Get-Childitem $FileName).Length / 1KB) 42 | Write-Verbose -Message "Display [$($Item.DeviceName)] ScreenCapture saved to File [$FileName] Size [$FileSize] KB" 43 | } 44 | } 45 | 46 | End {} 47 | } 48 | -------------------------------------------------------------------------------- /GAT/Functions/Get-ProfileBanner.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | 4 | Displays system information to a host. 5 | 6 | .DESCRIPTION 7 | 8 | The Get-Get-ProfileBanner cmdlet is a system information tool written in PowerShell. 9 | 10 | .EXAMPLE 11 | 12 | PS C:\> Get-Get-ProfileBanner 13 | #> 14 | Function Get-ProfileBanner { 15 | $ComputerInfo = Get-ComputerInfo 16 | 17 | Write-Host -Object ('##########################') -ForegroundColor Cyan 18 | Write-Host -Object ('#ppppp \ppppppppppppppp#') -NoNewline -ForegroundColor Cyan 19 | Write-Host -Object (" $(Get-Date)") -ForegroundColor Green 20 | Write-Host -Object ('#ooooo. oooooooooooooo#') -ForegroundColor Cyan 21 | Write-Host -Object ('#wwwwwww- wwwwwwwwwwwww#') -NoNewline -ForegroundColor Cyan 22 | Write-Host -Object (' User: ') -NoNewline 23 | Write-Host -Object ("$($env:USERNAME)") -ForegroundColor Yellow 24 | Write-Host -Object ('#eeeeeeee\ .eeeeeeeeeee#') -NoNewline -ForegroundColor Cyan 25 | Write-Host -Object (' Hostname: ') -NoNewline 26 | Write-Host -Object ("$($env:COMPUTERNAME)") -ForegroundColor Yellow 27 | Write-Host -Object ('#rrrrrrrrr. ;rrrrrrrrr#') -NoNewline -ForegroundColor Cyan 28 | Write-Host -Object (' Logon Domain: ') -NoNewline 29 | Write-Host -Object ("$($env:USERDOMAIN)") -ForegroundColor Yellow 30 | Write-Host -Object ('#sssssssssss sssssssss#') -NoNewline -ForegroundColor Cyan 31 | Write-Host -Object (' Boot Time: ') -NoNewline 32 | Write-Host -Object ("$($ComputerInfo.OsLastBootUpTime)") -ForegroundColor Yellow 33 | Write-Host -Object ('#hhhhhhhhh/ /hhhhhhhhh#') -NoNewline -ForegroundColor Cyan 34 | Write-Host -Object (' OS: ') -NoNewline 35 | Write-Host -Object ("$($ComputerInfo.WindowsProductName)") -ForegroundColor Yellow 36 | Write-Host -Object ('#eeeeeee; eeeeeeeeeeee#') -NoNewline -ForegroundColor Cyan 37 | Write-Host -Object (' TimeZone: ') -NoNewline 38 | Write-Host -Object ("$($ComputerInfo.TimeZone)") -ForegroundColor Yellow 39 | Write-Host -Object ('#lllll. ;lllllllllllll#') -NoNewline -ForegroundColor Cyan 40 | Write-Host -Object (' Shell: ') -NoNewline 41 | Write-Host -Object ("Powershell $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)") -ForegroundColor Yellow 42 | Write-Host -Object ('#lllll .lll lllll#') -NoNewline -ForegroundColor Cyan 43 | Write-Host -Object (' Memory: ') -NoNewline 44 | Write-Host -Object ("$([math]::round($ComputerInfo.OsFreePhysicalMemory / 1MB, 2))GB/$($ComputerInfo.CsPhyicallyInstalledMemory / 1MB)GB") -ForegroundColor Yellow 45 | Write-Host -Object ('##########################') -ForegroundColor Cyan 46 | Write-Host -Object ('') 47 | } 48 | -------------------------------------------------------------------------------- /GAT/Functions/Remove-AppxBloat.ps1: -------------------------------------------------------------------------------- 1 | Function Remove-AppxBloat { 2 | [CmdletBinding()] 3 | Param( 4 | [ValidateSet('Whitelist','Blacklist')] 5 | [string]$Method = 'Whitelist' 6 | ) 7 | If ($Method -eq 'Whitelist') { 8 | [regex]$Whitelist = "1527c705-839a-4832-9118-54d4Bd6a0c89|c5e2524a-ea46-4f67-841f-6a9465d9d515|F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE|CheckPoint.VPN|CortanaListenUIApp|DesktopLearning|DesktopView|E2A4F912-2574-4A75-9BB0-0D023378592B|EnvironmentsApp|f5.vpn.client|FileManager|HoloCamera|HoloItemPlayerApp|HoloShell|InputApp|JuniperNetworks.JunosPulseVpn|Microsoft.AAD.BrokerPlugin|Microsoft.AccountsControl|Microsoft.Advertising.Xaml|Microsoft.Appconnector|Microsoft.BioEnrollment|Microsoft.CredDialogHost|Microsoft.DesktopAppInstaller|Microsoft.ECApp|Microsoft.HEVCVideoExtension|Microsoft.LockApp|Microsoft.Media.PlayReadyClient|Microsoft.Messaging|Microsoft.MicrosoftEdge|Microsoft.MicrosoftStickyNotes|Microsoft.MoCamera|Microsoft.MSPaint|Microsoft.NET.Native.Framework|Microsoft.NET.Native.Runtime|Microsoft.OneConnect|Microsoft.PPIProjection|Microsoft.Services.Store.Engagement|Microsoft.Services.Store.Engagement|Microsoft.StorePurchaseApp|Microsoft.VCLibs|Microsoft.Wallet|Microsoft.Windows.Apprep.ChxApp|Microsoft.Windows.AssignedAccessLockApp|Microsoft.Windows.CloudExperienceHost|Microsoft.Windows.ContentDeliveryManager|Microsoft.Windows.Cortana|Microsoft.Windows.HolographicFirstRun|Microsoft.Windows.ModalSharePickerHost|Microsoft.Windows.OOBENetworkCaptivePortal|Microsoft.Windows.OOBENetworkConnectionFlow|Microsoft.Windows.ParentalControls|Microsoft.Windows.PeopleExperienceHost|Microsoft.Windows.Photos|Microsoft.Windows.PinningConfirmationDialog|Microsoft.Windows.SecondaryTileExperience|Microsoft.Windows.SecureAssessmentBrowser|Microsoft.Windows.ShellExperienceHost|Microsoft.WindowsAlarms|Microsoft.WindowsCalculator|Microsoft.WindowsCamera|Microsoft.WindowsMaps|Microsoft.Windows.SecHealthUI|Microsoft.WindowsSoundRecorder|Microsoft.Windows.WindowPicker|Microsoft.WindowsStore|Microsoft.WinJS|Microsoft.XboxGameCallableUI|Microsoft.XboxGameOverlay|Microsoft.XboxIdentityProvider|Microsoft.XboxSpeechToTextOverlay|SonicWALL.MobileConnect|Windows.ContactSupport|windows.devicesflow|windows.immersivecontrolpanel|Windows.MiracastView|Windows.PrintDialog|Windows.PurchaseDialog|winstore" 9 | Write-Verbose 'Starting to remove provisioned packages' 10 | Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $Whitelist} | Remove-AppxProvisionedPackage -Online | Out-Null 11 | Write-Verbose 'Starting to remove packages from all users' 12 | Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $Whitelist} | Remove-AppxPackage | Out-Null 13 | Write-Output 'Successfully completed removal of all AppX Packages not specified in the whitelist' 14 | } Else { 15 | [regex]$Blacklist = "9E2F88E3.Twitter|A278AB0D.MarchofEmpires|ClearChannelRadioDigital.iHeartRadio|Facebook.Facebook|Flipboard.Flipboard|king.com.CandyCrushSaga|king.com.CandyCrushSodaSaga|Microsoft.3DBuilder|Microsoft.BingFinance|Microsoft.BingFoodAndDrink|Microsoft.BingHealthAndFitness|Microsoft.BingNews|Microsoft.BingSports|Microsoft.BingTranslator|Microsoft.BingTravel|Microsoft.BingWeather|Microsoft.CommsPhone|Microsoft.FreshPaint|Microsoft.GetHelp|Microsoft.Getstarted|Microsoft.Microsoft3DViewer|Microsoft.MicrosoftJackpot|Microsoft.MicrosoftJigsaw|Microsoft.MicrosoftOfficeHub|Microsoft.MicrosoftSolitaireCollection|Microsoft.MicrosoftSudoku|Microsoft.MinecraftUWP|Microsoft.MovieMoments|Microsoft.Office.OneNote|Microsoft.Office.Sway|Microsoft.People|Microsoft.Print3D|Microsoft.SkypeApp|Microsoft.SkypeWiFi|Microsoft.Studios.Wordament|Microsoft.Taptiles|microsoft.windowscommunicationsapps|Microsoft.WindowsFeedback|Microsoft.WindowsFeedbackHub|Microsoft.WindowsPhone|Microsoft.Xbox.TCUI|Microsoft.XboxApp|Microsoft.ZuneMusic|Microsoft.ZuneVideo|MicrosoftMahjong|ShazamEntertainmentLtd.Shazam|TheNewYorkTimes.NYTCrossword" 16 | Write-Verbose 'Starting to remove provisioned packages' 17 | Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -Match $Blacklist} | Remove-AppxProvisionedPackage -Online | Out-Null 18 | Write-Verbose 'Starting to remove packages from all users' 19 | Get-AppxPackage -AllUsers | Where-Object {$_.Name -Match $Blacklist} | Remove-AppxPackage | Out-Null 20 | Write-Output 'Successfully completed removal of all AppX Packages specified in the blacklist' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /GAT/Functions/Disable-Unused2016Services.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | 4 | Disables services not required in Windows Server 2016. 5 | 6 | .DESCRIPTION 7 | 8 | Disables services not required to increase security of the system. 9 | 10 | .PARAMETER ComputerName 11 | Specifies a remote computer. Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qualified domain name of a remote computer. 12 | 13 | .PARAMETER XboxOnly 14 | Specifies the to only disable the Xbox services. 15 | 16 | .INPUTS 17 | 18 | You can pipe objects to ComputerName by the property name. 19 | 20 | .OUTPUTS 21 | 22 | None. This command does not generate any output. 23 | 24 | .EXAMPLE 25 | 26 | PS C:\> Disable-Unused2016Services 27 | 28 | This command with no parameters will disable all services that are not required in Windows Server 2016. 29 | 30 | .EXAMPLE 31 | 32 | PS C:\> Disable-Unused2016Services SVR01,SVR02,SVR03 -XboxOnly 33 | 34 | This command with will remotely disable the 2 Xbox services on the computers named SVR01, SVR02 and SVR03. 35 | 36 | .EXAMPLE 37 | 38 | PS C:\> Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"} | Select-Object -ExpandProperty Name | Disable-Unused2016Services 39 | 40 | Remotely disables unused services of computers piped in from AD. 41 | 42 | .LINK 43 | 44 | https://gist.github.com/GavinEke/abfc2a547aea74b9d74a2c0c598f3fd7 45 | #> 46 | Function Disable-Unused2016Services { 47 | [CmdletBinding()] 48 | Param( 49 | [Parameter(ValueFromPipelineByPropertyName=$True)] 50 | [Alias('__SERVER','CN')] 51 | [string[]]$ComputerName, 52 | 53 | [switch]$XboxOnly 54 | ) 55 | 56 | Begin { 57 | $fullservices = @( 58 | 'AxInstSV', 59 | 'bthserv', 60 | 'CDPUserSvc', 61 | 'PimIndexMaintenanceSvc', 62 | 'dmwappushservice', 63 | 'MapsBroker', 64 | 'lfsvc', 65 | 'SharedAccess', 66 | 'lltdsvc', 67 | 'wlidsvc', 68 | 'NgcSvc', 69 | 'NgcCtnrSvc', 70 | 'NcbService', 71 | 'PhoneSvc', 72 | 'PcaSvc', 73 | 'QWAVE', 74 | 'RmSvc', 75 | 'SensorDataService', 76 | 'SensrSvc', 77 | 'SensorService', 78 | 'ShellHWDetection', 79 | 'ScDeviceEnum', 80 | 'SSDPSRV', 81 | 'WiaRpc', 82 | 'OneSyncSvc', 83 | 'TabletInputService', 84 | 'upnphost', 85 | 'UserDataSvc', 86 | 'UnistoreSvc', 87 | 'WalletService', 88 | 'Audiosrv', 89 | 'AudioEndpointBuilder', 90 | 'FrameServer', 91 | 'stisvc', 92 | 'wisvc', 93 | 'icssvc', 94 | 'WpnService', 95 | 'WpnUserService', 96 | 'XblAuthManager', 97 | 'XblGameSave' 98 | ) 99 | $xboxservices = @( 100 | 'XblAuthManager', 101 | 'XblGameSave' 102 | ) 103 | 104 | If ($XboxOnly) { 105 | Write-Verbose -Message 'Selecting only xbox services' 106 | $services = $xboxservices 107 | } Else { 108 | Write-Verbose -Message 'Selecting all services not required' 109 | $services = $fullservices 110 | } 111 | } 112 | 113 | Process { 114 | If ($PSBoundParameters.ContainsKey('ComputerName')) { 115 | ForEach ($service in $services) { 116 | Write-Verbose -Message "Disabling $service on $ComputerName" 117 | Set-Service -ComputerName $ComputerName -Name $service -StartupType Disabled -ErrorAction SilentlyContinue 118 | } 119 | Write-Verbose -Message "Disabling Xbox tasks on $ComputerName" 120 | [void]$(Invoke-Command -ComputerName $ComputerName -ScriptBlock {Get-ScheduledTask -TaskPath '\Microsoft\XblGameSave\' | Disable-ScheduledTask}) 121 | } Else { 122 | ForEach ($service in $services) { 123 | Write-Verbose -Message "Disabling $service on localhost" 124 | Set-Service -Name $service -StartupType Disabled 125 | } 126 | Write-Verbose -Message 'Disabling Xbox tasks on localhost' 127 | [void]$(Get-ScheduledTask -TaskPath '\Microsoft\XblGameSave\' | Disable-ScheduledTask) 128 | } 129 | } 130 | 131 | End {} 132 | } 133 | -------------------------------------------------------------------------------- /GAT/GAT.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | 3 | # Script module or binary module file associated with this manifest. 4 | RootModule = 'GAT.psm1' 5 | 6 | # Version number of this module. 7 | ModuleVersion = '1.3.1' 8 | 9 | # Supported PSEditions 10 | # CompatiblePSEditions = @() 11 | 12 | # ID used to uniquely identify this module 13 | GUID = 'e2f534d1-c140-4440-840d-65566f2289b5' 14 | 15 | # Author of this module 16 | Author = 'Gavin Eke' 17 | 18 | # Company or vendor of this module 19 | # CompanyName = 'Unknown' 20 | 21 | # Copyright statement for this module 22 | Copyright = '(c) 2017 Gavin Eke. All rights reserved.' 23 | 24 | # Description of the functionality provided by this module 25 | Description = "Gavin's Admin Toolkit (GAT) is a collection of functions for managing Windows 8.1+/Windows Server 2012 R2+" 26 | 27 | # Minimum version of the Windows PowerShell engine required by this module 28 | PowerShellVersion = '5.1' 29 | 30 | # Name of the Windows PowerShell host required by this module 31 | # PowerShellHostName = '' 32 | 33 | # Minimum version of the Windows PowerShell host required by this module 34 | # PowerShellHostVersion = '' 35 | 36 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 37 | # DotNetFrameworkVersion = '' 38 | 39 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 40 | # CLRVersion = '' 41 | 42 | # Processor architecture (None, X86, Amd64) required by this module 43 | # ProcessorArchitecture = '' 44 | 45 | # Modules that must be imported into the global environment prior to importing this module 46 | # RequiredModules = @() 47 | 48 | # Assemblies that must be loaded prior to importing this module 49 | # RequiredAssemblies = @() 50 | 51 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 52 | # ScriptsToProcess = @() 53 | 54 | # Type files (.ps1xml) to be loaded when importing this module 55 | # TypesToProcess = @() 56 | 57 | # Format files (.ps1xml) to be loaded when importing this module 58 | # FormatsToProcess = @() 59 | 60 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 61 | # NestedModules = @() 62 | 63 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 64 | FunctionsToExport = @('Disable-Unused2016Services','Disable-WindowsTelemetry','Enable-RDP','Expand-ShortURL','fuck','Get-EmlFileInfo','Get-ProfileBanner','Get-WeatherReport','Remove-AppxBloat','Save-Screenshot','Set-WindowsKey','sudo','Test-Administrator') 65 | 66 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 67 | CmdletsToExport = @() 68 | 69 | # Variables to export from this module 70 | VariablesToExport = '*' 71 | 72 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 73 | AliasesToExport = @() 74 | 75 | # DSC resources to export from this module 76 | # DscResourcesToExport = @() 77 | 78 | # List of all modules packaged with this module 79 | # ModuleList = @() 80 | 81 | # List of all files packaged with this module 82 | # FileList = @() 83 | 84 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 85 | PrivateData = @{ 86 | 87 | PSData = @{ 88 | 89 | # Tags applied to this module. These help with module discovery in online galleries. 90 | Tags = @('GavinEke','GAT','Gavin','Admin','Tookit') 91 | 92 | # A URL to the license for this module. 93 | # LicenseUri = '' 94 | 95 | # A URL to the main website for this project. 96 | ProjectUri = 'https://github.com/GavinEke/GAT' 97 | 98 | # A URL to an icon representing this module. 99 | # IconUri = '' 100 | 101 | # ReleaseNotes of this module 102 | ReleaseNotes = ' 103 | * New Function - Get-EmlFileInfo 104 | * Minor performance improvements 105 | ' 106 | 107 | } # End of PSData hashtable 108 | 109 | } # End of PrivateData hashtable 110 | 111 | # HelpInfo URI of this module 112 | # HelpInfoURI = '' 113 | 114 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 115 | # DefaultCommandPrefix = '' 116 | 117 | } 118 | -------------------------------------------------------------------------------- /GAT/Functions/Set-WindowsKey.ps1: -------------------------------------------------------------------------------- 1 | Function Set-WindowsKey { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory=$True,ParameterSetName='Key')] 5 | [ValidateLength(29,29)] 6 | [String]$Key, 7 | 8 | [Parameter(Mandatory=$True,ParameterSetName='KMS')] 9 | [Switch]$KMS, 10 | 11 | [Parameter(Mandatory=$True,ParameterSetName='OEM')] 12 | [Switch]$OEM, 13 | 14 | [Parameter(ValueFromPipelineByPropertyName=$True)] 15 | [Alias('__SERVER','CN')] 16 | [String]$ComputerName 17 | ) 18 | 19 | Begin {} 20 | 21 | Process { 22 | $SLSParams = @{ 23 | Class = 'SoftwareLicensingService' 24 | } 25 | If ($PSBoundParameters.ContainsKey('ComputerName')) { 26 | $SLSParams.Add('ComputerName', $ComputerName) 27 | } 28 | $SoftwareLicensingService = Get-CimInstance @SLSParams 29 | 30 | If ($KMS) { 31 | $W32OSParams = @{ 32 | Class = 'Win32_OperatingSystem' 33 | } 34 | If ($PSBoundParameters.ContainsKey('ComputerName')) { 35 | $W32OSParams.Add('ComputerName', $ComputerName) 36 | } 37 | $OSversion = Get-CimInstance @W32OSParams | Select-Object -ExpandProperty Caption 38 | 39 | Switch ($OSversion) { 40 | 'Windows Server 2016 Datacenter' {$Key = 'CB7KF-BWN84-R7R2Y-793K2-8XDDG'; break} 41 | 'Windows Server 2016 Standard' {$Key = 'WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY'; break} 42 | 'Windows Server 2016 Essentials' {$Key = 'JCKRF-N37P4-C2D82-9YXRT-4M63B'; break} 43 | 'Windows 10 Professional' {$Key = 'W269N-WFGWX-YVC9B-4J6C9-T83GX'; break} 44 | 'Windows 10 Professional N' {$Key = 'MH37W-N47XK-V7XM9-C7227-GCQG9'; break} 45 | 'Windows 10 Enterprise' {$Key = 'NPPR9-FWDCX-D2C8J-H872K-2YT43'; break} 46 | 'Windows 10 Enterprise N' {$Key = 'DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4'; break} 47 | 'Windows 10 Education' {$Key = 'NW6C2-QMPVW-D7KKK-3GKT6-VCFB2'; break} 48 | 'Windows 10 Education N' {$Key = '2WH4N-8QGBV-H22JP-CT43Q-MDWWJ'; break} 49 | 'Windows 10 Enterprise 2015 LTSB' {$Key = 'WNMTR-4C88C-JK8YV-HQ7T2-76DF9'; break} 50 | 'Windows 10 Enterprise 2015 LTSB N' {$Key = '2F77B-TNFGY-69QQF-B8YKP-D69TJ'; break} 51 | 'Windows 10 Enterprise 2016 LTSB' {$Key = 'DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ'; break} 52 | 'Windows 10 Enterprise 2016 LTSB N' {$Key = 'QFFDN-GRT3P-VKWWX-X7T3R-8B639'; break} 53 | 'Windows 8.1 Professional' {$Key = 'GCRJD-8NW9H-F2CDX-CCM8D-9D6T9'; break} 54 | 'Windows 8.1 Professional N' {$Key = 'HMCNV-VVBFX-7HMBH-CTY9B-B4FXY'; break} 55 | 'Windows 8.1 Enterprise' {$Key = 'MHF9N-XY6XB-WVXMC-BTDCT-MKKG7'; break} 56 | 'Windows 8.1 Enterprise N' {$Key = 'TT4HM-HN7YT-62K67-RGRQJ-JFFXW'; break} 57 | 'Windows Server 2012 R2 Server Standard' {$Key = 'D2N9P-3P6X9-2R39C-7RTCD-MDVJX'; break} 58 | 'Windows Server 2012 R2 Datacenter' {$Key = 'W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9'; break} 59 | 'Windows Server 2012 R2 Essentials' {$Key = 'KNC87-3J2TX-XB4WP-VCPJV-M4FWM'; break} 60 | 'Windows 8 Professional' {$Key = 'NG4HW-VH26C-733KW-K6F98-J8CK4'; break} 61 | 'Windows 8 Professional N' {$Key = 'XCVCF-2NXM9-723PB-MHCB7-2RYQQ'; break} 62 | 'Windows 8 Enterprise' {$Key = '32JNW-9KQ84-P47T8-D8GGY-CWCK7'; break} 63 | 'Windows 8 Enterprise N' {$Key = 'JMNMF-RHW7P-DMY6X-RF3DR-X2BQT'; break} 64 | 'Windows Server 2012' {$Key = 'BN3D2-R7TKB-3YPBD-8DRP2-27GG4'; break} 65 | 'Windows Server 2012 N' {$Key = '8N2M2-HWPGY-7PGT9-HGDD8-GVGGY'; break} 66 | 'Windows Server 2012 Single Language' {$Key = '2WN2H-YGCQR-KFX6K-CD6TF-84YXQ'; break} 67 | 'Windows Server 2012 Country Specific' {$Key = '4K36P-JN4VD-GDC6V-KDT89-DYFKP'; break} 68 | 'Windows Server 2012 Server Standard' {$Key = 'XC9B7-NBPP2-83J2H-RHMBY-92BT4'; break} 69 | 'Windows Server 2012 MultiPoint Standard' {$Key = 'HM7DN-YVMH3-46JC3-XYTG7-CYQJJ'; break} 70 | 'Windows Server 2012 MultiPoint Premium' {$Key = 'XNH6W-2V9GX-RGJ4K-Y8X6F-QGJ2G'; break} 71 | 'Windows Server 2012 Datacenter' {$Key = '48HP8-DN98B-MYWDG-T2DCC-8W83P'; break} 72 | 'Windows 7 Professional' {$Key = 'FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4'; break} 73 | 'Windows 7 Professional N' {$Key = 'MRPKT-YTG23-K7D7T-X2JMM-QY7MG'; break} 74 | 'Windows 7 Professional E' {$Key = 'W82YF-2Q76Y-63HXB-FGJG9-GF7QX'; break} 75 | 'Windows 7 Enterprise' {$Key = '33PXH-7Y6KF-2VJC9-XBBR8-HVTHH'; break} 76 | 'Windows 7 Enterprise N' {$Key = 'YDRBP-3D83W-TY26F-D46B2-XCKRJ'; break} 77 | 'Windows 7 Enterprise E' {$Key = 'C29WB-22CC8-VJ326-GHFJW-H9DH4'; break} 78 | 'Windows Server 2008 R2 Web' {$Key = '6TPJF-RBVHG-WBW2R-86QPH-6RTM4'; break} 79 | 'Windows Server 2008 R2 HPC edition' {$Key = 'TT8MH-CG224-D3D7Q-498W2-9QCTX'; break} 80 | 'Windows Server 2008 R2 Standard' {$Key = 'YC6KT-GKW9T-YTKYR-T4X34-R7VHC'; break} 81 | 'Windows Server 2008 R2 Enterprise' {$Key = '489J6-VHDMP-X63PK-3K798-CPX3Y'; break} 82 | 'Windows Server 2008 R2 Datacenter' {$Key = '74YFP-3QFB3-KQT8W-PMXWJ-7M648'; break} 83 | 'Windows Server 2008 R2 for Itanium-based Systems' {$Key = 'GT63C-RJFQ3-4GMB6-BRFB9-CB83V'; break} 84 | 'Windows Vista Business' {$Key = 'YFKBB-PQJJV-G996G-VWGXY-2V3X8'; break} 85 | 'Windows Vista Business N' {$Key = 'HMBQG-8H2RH-C77VX-27R82-VMQBT'; break} 86 | 'Windows Vista Enterprise' {$Key = 'VKK3X-68KWM-X2YGT-QR4M6-4BWMV'; break} 87 | 'Windows Vista Enterprise N' {$Key = 'VTC42-BM838-43QHV-84HX6-XJXKV'; break} 88 | 'Windows Web Server 2008' {$Key = 'WYR28-R7TFJ-3X2YQ-YCY4H-M249D'; break} 89 | 'Windows Server 2008 Standard' {$Key = 'TM24T-X9RMF-VWXK6-X8JC9-BFGM2'; break} 90 | 'Windows Server 2008 Standard without Hyper-V' {$Key = 'W7VD6-7JFBR-RX26B-YKQ3Y-6FFFJ'; break} 91 | 'Windows Server 2008 Enterprise' {$Key = 'YQGMW-MPWTJ-34KDK-48M3W-X4Q6V'; break} 92 | 'Windows Server 2008 Enterprise without Hyper-V' {$Key = '39BXF-X8Q23-P2WWT-38T2F-G3FPG'; break} 93 | 'Windows Server 2008 HPC' {$Key = 'RCTX3-KWVHP-BR6TB-RB6DM-6X7HP'; break} 94 | 'Windows Server 2008 Datacenter' {$Key = '7M67G-PC374-GR742-YH8V4-TCBY3'; break} 95 | 'Windows Server 2008 Datacenter without Hyper-V' {$Key = '22XQ2-VRXRG-P8D42-K34TD-G3QQC'; break} 96 | 'Windows Server 2008 for Itanium-Based Systems' {$Key = '4DWFP-JF3DJ-B7DTH-78FJB-PDRHK'; break} 97 | } 98 | 99 | } ElseIf ($PSCmdlet.ParameterSetName -eq "OEM") { 100 | $Key = $SoftwareLicensingService | Select-Object -ExpandProperty OA3xOriginalProductKey 101 | } 102 | 103 | $IPKParams = @{ 104 | MethodName = 'InstallProductKey' 105 | Arguments = @{ ProductKey = $Key } 106 | } 107 | If ($PSBoundParameters.ContainsKey('ComputerName')) { 108 | $IPKParams.Add('ComputerName', $ComputerName) 109 | } 110 | $SoftwareLicensingService | Invoke-CimMethod @IPKParams 111 | 112 | 113 | $RLSParams = @{ 114 | MethodName = 'RefreshLicenseStatus' 115 | } 116 | If ($PSBoundParameters.ContainsKey('ComputerName')) { 117 | $RLSParams.Add('ComputerName', $ComputerName) 118 | } 119 | $SoftwareLicensingService | Invoke-CimMethod @RLSParams 120 | } 121 | 122 | End {} 123 | } 124 | --------------------------------------------------------------------------------