Skip to content

Instantly share code, notes, and snippets.

View EmmanuelTsouris's full-sized avatar

Emmanuel Tsouris EmmanuelTsouris

View GitHub Profile
@EmmanuelTsouris
EmmanuelTsouris / gist:3ebc8ec3da71f06d948ed3ce5c81195d
Created December 20, 2023 18:57
Some useful PowerShell snippets to prep an EC2 Instance
# turn off ie security
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
# priority to programs, not background
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\PriorityControl" -Name "Win32PrioritySeparation" -Value 38
@EmmanuelTsouris
EmmanuelTsouris / gist:34a14d10631cdc68aa0b60c27191ca2e
Created July 19, 2021 23:58
PowerShell for Windows Updates
#Scan for available updates
function Get-AvailableUpdates {
  [CmdletBinding()]
  param()
  $ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession 
  $result = $ci | Invoke-CimMethod -MethodName ScanForUpdates -Arguments @{SearchCriteria="IsInstalled=0";OnlineScan=$true}
  $result.Updates
}
param (
$ScriptPath
)
# Formats the Script to you can paste it into a RunCommand or Automation Document
# Example:
# .\AdditionalExamples\Format-PSForDocument.ps1 -ScriptPath .\AdditionalExamples\Install-SSMS.ps1
# Grab the script and remove blank lines and comments
$powershell = (Get-Content $ScriptPath | Where-Object {$_ -notlike '#*' -and $_ -notlike [string]::Empty})
@EmmanuelTsouris
EmmanuelTsouris / Install-Chrome.ps1
Last active May 1, 2019 15:56
Install Chrome using PowerShell One Liner
$path = $env:TEMP; $arg="/silent /install"; $exe = "chrome_installer.exe"; $url="https://dl.google.com/chrome/install/latest/$exe"; Invoke-WebRequest $url -OutFile $path$exe; Start-Process -FilePath $path$exe -Args $arg -Verb RunAs -Wait; Remove-Item $path$exe
@EmmanuelTsouris
EmmanuelTsouris / Install-IIS.ps1
Created January 31, 2018 17:08
Two simple lines of PowerShell that install IIS and .Net
# Instal IIS
Install-WindowsFeature -name Web-Server -IncludeManagementTools
# Install .Net
Install-WindowsFeature Net-Framework-Core
@EmmanuelTsouris
EmmanuelTsouris / write-metricgputemp.ps1
Last active September 16, 2017 15:27
PowerShell to log NVIDIA GPU Temperature from a Amazon EC2 G3 Instance to CloudWatch Metric
Import-Module AWSPowerShell
Function Get-MetaData {
<#
.DESCRIPTION
Gets metadata from the local instance using the path extention provided
.PARAMETER metaDataUrlPathExtention
The URL suffix of the metadata that you want to gathered
.EXAMPLE
[string]$instanceId = $(Get-MetaDataObject -metaDataUrlPathExtention "instance-id")
@EmmanuelTsouris
EmmanuelTsouris / Install-VSCode.ps1
Last active May 18, 2024 17:25
Download and Silently Install Visual Studio Code (VSCode)
<#
.SYNOPSIS
This script installs Visual Studio Code Silently.
.DESCRIPTION
The script downloads the latest VSCode installer and performs a silent installation.
.NOTES
Run this script on a Windows Server instance.
#>
@EmmanuelTsouris
EmmanuelTsouris / OperatingSystemSKU.ps1
Created November 28, 2016 18:09
Windows Server SKU
$(Get-CimInstance -ClassName Win32_OperatingSystem).OperatingSystemSKU
#region Nano server check
Switch -Exact ($(Get-CimInstance -ClassName Win32_OperatingSystem).OperatingSystemSKU) {
143 {
Write-Verbose -Message 'Script Running on Windows Server Datacenter Edition (Nano Server installation)'
break;
}
144 {
Write-Verbose -Message 'Windows Server Standard Edition (Nano Server installation)'
@EmmanuelTsouris
EmmanuelTsouris / MSFT_WUOperationsSession.ps1
Last active January 11, 2018 19:04
Windows Server 2016 and Nano Server CimMethods for Windows Updates using MSFT_WUOperationsSession
Write-Host "Installed Updates"
$ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession
$result = $ci | Invoke-CimMethod -MethodName ScanForUpdates -Arguments @{SearchCriteria="IsInstalled=1";OnlineScan=$true}
$result.Updates
Write-Host "Missing Updates"
$ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession 
# PowerShell to grab a list of the Windows 2016 with Containers AMI
Get-EC2Image -Filter @{Name='name';Value='Windows_Server-2016*'},@{Name='name';Value="*Containers*"}