Skip to content

Instantly share code, notes, and snippets.

View rossarioking's full-sized avatar

Rossario King rossarioking

  • Dublin
View GitHub Profile
@rossarioking
rossarioking / Powershell Script to Check for Specific Application Install.ps1
Created September 23, 2023 14:18
Powershell Script to Check for Specific Application Install
$applicationDisplayName = "Your Application Name" # Replace with the name of the application you want to check
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedApps = Get-ItemProperty -Path $regPath | Where-Object { $_.DisplayName -eq $applicationDisplayName }
if ($installedApps) {
Write-Host "$applicationDisplayName is installed."
}
else {
Write-Host "$applicationDisplayName is not installed."
@rossarioking
rossarioking / Monitor CPU of Remote Host.ps1
Created September 23, 2023 14:13
Powershell Script to Monitor CPU of Remote Host
$computerName = "RemoteComputerName" # Replace with the name or IP address of the remote computer
$counterPath = "\\$computerName\Processor(_Total)\% Processor Time"
# Continuous monitoring loop
while ($true) {
$cpuUsage = (Get-Counter -Counter $counterPath).CounterSamples.CookedValue
Write-Host "CPU Usage on $computerName: $($cpuUsage)%" -ForegroundColor Green
Start-Sleep -Seconds 5 # Adjust the sleep interval as needed
}
@rossarioking
rossarioking / Monitoring Website Availability with Powershell.ps1
Created September 23, 2023 14:05
Monitoring Website Availability with Powershell
$websites = "https://example.com", "https://google.com"
$websites | ForEach-Object {
$url = $_
$response = Invoke-WebRequest -Uri $url
if ($response.StatusCode -eq 200) {
Write-Host "$url is online (Status Code: $($response.StatusCode))"
}
else {
Write-Host "$url is down (Status Code: $($response.StatusCode))"
}
@rossarioking
rossarioking / Monitoring Event Log for Specific Events.ps1
Created September 23, 2023 14:04
Monitoring Event Log for Specific Events With Powershell
Get-EventLog -LogName Application | Where-Object { $_.EventID -eq 1001 } | ForEach-Object {
Write-Host "Event 1001 detected: $($_.Message)"
}
@rossarioking
rossarioking / Monitoring Event Logs with Powershell.ps1
Created September 23, 2023 14:00
Monitoring Event Logs with Powershell
Get-EventLog -LogName System -EntryType Error -After (Get-Date).AddHours(-1) | ForEach-Object {
Write-Host "Error Event Found: $($_.Message)"
}
@rossarioking
rossarioking / Monitoring Disk Space with Powershell.ps1
Created September 23, 2023 13:58
Monitoring Disk Space with Powershell
Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } | ForEach-Object {
$disk = $_
$freeSpace = [math]::Round($disk.FreeSpace / 1GB, 2)
$totalSpace = [math]::Round($disk.Size / 1GB, 2)
Write-Host "$($disk.DeviceID) - Free Space: ${freeSpace}GB / Total Space: ${totalSpace}GB"
}
@rossarioking
rossarioking / Monitoring Memory Usage with Powershell.ps1
Created September 23, 2023 13:57
Monitoring Memory Usage with Powershell
Get-Counter '\Memory\Available MBytes' -Continuous | ForEach-Object {Write-Host "Available Memory: $($_.CounterSamples[0].CookedValue) MB"; Start-Sleep -Seconds 10}
@rossarioking
rossarioking / Monitoring CPU Usage with Powershell.ps1
Last active September 23, 2023 14:07
Monitoring CPU Usage with Powershell
Get-Counter '\Processor(_Total)\% Processor Time' -Continuous | ForEach-Object {Write-Host "CPU Usage: $($_.CounterSamples[0].CookedValue)%"; Start-Sleep -Seconds 5}
@rossarioking
rossarioking / Azure_Resize VMs in the Availability Set.txt
Created August 30, 2023 20:26
Azure_Resize VMs in the Availability Set
$vm = Get-AzVM -ResourceGroupName <RESOURCE_GROUP_NAME> -VMName labVM0
$vm.HardwareProfile.VmSize = "Standard_B1s"
Update-AzVM -VM $vm -ResourceGroupName <RESOURCE_GROUP_NAME>
\\\To view results of the change, enter Get-AzVM. We should see VMSize for labVM0 changed to Standard_B1s.
@rossarioking
rossarioking / Terraform_WebApp_Lab.tf
Created July 27, 2023 13:34
Deploy a Web Application with Terraform
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "= 2.99"
}
}
}
provider "azurerm" {