This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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))" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-EventLog -LogName Application | Where-Object { $_.EventID -eq 1001 } | ForEach-Object { | |
Write-Host "Event 1001 detected: $($_.Message)" | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-EventLog -LogName System -EntryType Error -After (Get-Date).AddHours(-1) | ForEach-Object { | |
Write-Host "Error Event Found: $($_.Message)" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Counter '\Memory\Available MBytes' -Continuous | ForEach-Object {Write-Host "Available Memory: $($_.CounterSamples[0].CookedValue) MB"; Start-Sleep -Seconds 10} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Counter '\Processor(_Total)\% Processor Time' -Continuous | ForEach-Object {Write-Host "CPU Usage: $($_.CounterSamples[0].CookedValue)%"; Start-Sleep -Seconds 5} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
azurerm = { | |
source = "hashicorp/azurerm" | |
version = "= 2.99" | |
} | |
} | |
} | |
provider "azurerm" { |
NewerOlder