Functions/Functions.ps1
function Install-Chocolatey { <# .DESCRIPTION Installs Chocolatey .EXAMPLE Install-Chocolatey #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute( ` "PSAvoidUsingInvokeExpression", ` "", ` Justification = "Using Chocolatey-provided call")] param() try { choco -v | Out-Null Write-Host 'Chocolatey already installed.' -ForegroundColor Green return } catch { $downloadUrl = 'https://chocolatey.org/install.ps1' Write-Output 'Installing Chocolatey...' Set-ExecutionPolicy Bypass -Scope Process -Force; ` Invoke-Expression ` ((New-Object System.Net.WebClient).DownloadString($downloadUrl)) } } function Install-ChocoPackages { <# .SYNOPSIS -Taylor Lee Modified 06052019 .DESCRIPTION Install one or Multiple Choclatey Packages .EXAMPLE Install a single application Install-ChocoPackages -install firefox .EXAMPLE Install Multiple Applications. Install-ChocoPackages -install firefox, chrome, nmap #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)]$Install ) #Start Transcipt $username = $env:UserName Start-Transcript "c:\users\$username\desktop\Choco Install.txt" -append #Install Choco Packages Write-Host 'Installing Software with Chocolatey...' -ForegroundColor Green choco install -y -r $Install #Stop Transcript Stop-Transcript } function Get-ChocoOutdated { <# .SYNOPSIS -Taylor Lee Modified 06052019 .DESCRIPTION Gets outdated choco packages .EXAMPLE Get-ChocoOutdated #> choco outdated } function Show-ChocoInstalls { <# .SYNOPSIS -Taylor Lee Modified 05262019 .DESCRIPTION Show Installed Chocolatey packages .EXAMPLE Show-ChocoInstalls #> [CmdletBinding()] param ( ) choco list --local-only } function Invoke-ChocoUpgrade { <# .SYNOPSIS -Taylor Lee Modified 06062019 .DESCRIPTION Upgrade choco packages .EXAMPLE Invoke-ChocoUpgrade #> [CmdletBinding()] param ( ) choco upgrade all } function Remove-Shortcuts { <# .SYNOPSIS -Taylor Lee Modified 05262019 .DESCRIPTION Removes desktop shortcuts .EXAMPLE Remove-Shortcuts #> [CmdletBinding()] param ( ) Write-Host 'Deleting desktop icons...' -ForegroundColor Green Remove-Item C:\Users\*\Desktop\*.lnk -Force } function Remove-Tiles { <# .SYNOPSIS -Taylor Lee Modified 05262019 .DESCRIPTION Removes all start menu tiles .EXAMPLE Remove-Tiles #> [CmdletBinding()] param ( ) (New-Object -Com Shell.Application). NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}'). Items() | ForEach-Object { $_.Verbs() } | Where-Object { $_.Name -match 'Un.*pin from Start' } | ForEach-Object { $_.DoIt() } } function Remove-StoreApps { <# .SYNOPSIS -Taylor Lee Modified 05262019 .DESCRIPTION Removes sponsered Windows store apps and some microsoft apps -Microsot Apps Removes "Microsoft.BingNews" "Microsoft.BingWeather" "Microsoft.MicrosoftSolitaireCollection" "Microsoft.Office.OneNote" "Microsoft.Office.Sway" "Microsoft.RemoteDesktop" "Microsoft.WindowsCamera" "*Skype*" .EXAMPLE Remove-StoreApps #> [CmdletBinding()] Param ( ) $CrapApps = @( #Unnecessary Windows 10 AppX Apps "Microsoft.BingNews" "Microsoft.BingWeather" "Microsoft.MicrosoftSolitaireCollection" "Microsoft.Office.OneNote" "Microsoft.Office.Sway" "Microsoft.RemoteDesktop" "Microsoft.WindowsCamera" "*Skype*" #Sponsored Windows 10 AppX Apps "*EclipseManager*" "*ActiproSoftwareLLC*" "*AdobeSystemsIncorporated.AdobePhotoshopExpress*" "*Duolingo-LearnLanguagesforFree*" "*PandoraMediaInc*" "*CandyCrush*" "*Wunderlist*" "*Flipboard*" "*Twitter*" "*Facebook*" "*Spotify*" "*Minecraft*" "*Royal Revolt*" ) foreach ($Crap in $CrapApps) { Get-AppxPackage -Name $Crap | Remove-AppxPackage -ErrorAction SilentlyContinue Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Debloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue Write-Output "Removing $Crap if exists." } Write-Host "Adding Registry key to prevent bloatware apps from returning" -ForegroundColor Green $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" If (!(Test-Path $registryPath)) { New-Item $registryPath } Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1 If (!(Test-Path $registryOEM)) { New-Item $registryOEM } Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0 Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0 Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0 Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0 Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0 Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0 } function Disable-Standby { <# .SYNOPSIS -Taylor Lee Modified 06192019 .DESCRIPTION Disables standby, sleep, and hibernate .EXAMPLE Disable-Standby #> [CmdletBinding()] param ( ) Write-Host "disabling standby" -ForegroundColor Green powercfg.exe -change -standby-timeout-ac 0 powercfg.exe -change -standby-timeout-dc 0 powercfg.exe -change -hibernate-timeout-ac 0 powercfg.exe -change -hibernate-timeout-dc 0 powercfg.exe -change -monitor-timeout-ac 0 powercfg.exe -change -monitor-timeout-dc 0 powercfg.exe -change -disk-timeout-ac 0 powercfg.exe -change -disk-timeout-dc 0 powercfg -h off Remove-Item c:\hiberfile.sys -Force -ErrorAction SilentlyContinue } Function Disable-UAC { <# .Synopsis -Taylor Lee Modified 05172019 .Description This Function disable UAC and removes the Consent Prompt Behaviour. #> [CmdletBinding()] param ( ) reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /f /v "ConsentPromptBehaviorAdmin" /t reg_dword /d 0 reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /f /v "EnableLUA" /t reg_dword /d 0 } Function Disable-UACPrompt { <# .Synopsis -Taylor Lee Modified 05172019 .Description This Function disables UAC Consent Prompting for local Administrators. #> [CmdletBinding()] param ( ) reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /f /v "ConsentPromptBehaviorAdmin" /t reg_dword /d 0 } Function Enable-UAC { <# .Synopsis -Taylor Lee Modified 05172019 .Description This Function enables UAC and sets the Consent Prompt Behaviour. #> [CmdletBinding()] param ( ) reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /f /v "ConsentPromptBehaviorAdmin" /t reg_dword /d 2 reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /f /v "EnableLUA" /t reg_dword /d 1 } Function Disable-ShakeToMinimize { <# .Synopsis -Taylor Lee Modified 05172019 .Description This Function disables the annoying shake to minimize Windows feature #> [CmdletBinding()] param ( ) reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /f /v "DisallowShaking" /t reg_dword /d 1 } function Disable-Firewall { <# .SYNOPSIS -Taylor Lee Modified 05262019 .DESCRIPTION Disables the local firewall .EXAMPLE Disable-Firewall #> [CmdletBinding()] param ( ) Write-Host "Disabling Firewall" -ForegroundColor Green Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled False } function Enable-Firewall { <# .SYNOPSIS -Taylor Lee Modified 05262019 .DESCRIPTION Disables the local firewall .EXAMPLE Disable-Firewall #> [CmdletBinding()] param ( ) Write-Host "Enabling Firewall" -ForegroundColor Green Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled True } function Join-Domain { <# .SYNOPSIS -Taylor Lee Modified 05262019 .DESCRIPTION Joins pc to a domain .EXAMPLE Join-Domain -domain company.com #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)]$domain ) Add-Computer -DomainName $domain -Credential $credentials } |