Skip to content

Instantly share code, notes, and snippets.

View kpatnayakuni's full-sized avatar
🏠
Working from home

Kiran Patnayakuni kpatnayakuni

🏠
Working from home
View GitHub Profile
PS C:\Users\kiran> Try { Test-Connection "localhost" -Count 1 } Catch { Write-Host "Connection Error" } Finally { Write-Host "`nTest Complete" }
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
Workstation localhost 127.0.0.1 ::1 32 0
Test Complete
PS C:\Users\kiran> Try { Test-Connection "localhost1" -Count 1 } Catch { Write-Host "Connection Error" } Finally { Write-Host "`nTest Complete" }
Write-Host ""
Write-Host " _ _ _ _____ ______ __ _" -ForegroundColor Yellow
Write-Host "| | / / | | | _ | | __ | | \ | |" -ForegroundColor Yellow
Write-Host "| |_/ / | | | |_| | | |__| | | |\ \ | |" -ForegroundColor Yellow
Write-Host "| _ / | | | __| | __ | | | \ \ | |" -ForegroundColor Yellow
Write-Host "| | \ \ | | | |\ \ | | | | | | \ \| |" -ForegroundColor Yellow
Write-Host "|_| \_\ |_| |_| \_\ |_| |_| |_| \ __|" -ForegroundColor Yellow
Write-Host ""
Write-Host " *" -ForegroundColor Red
Write-Host " /.\" -ForegroundColor Red -NoNewline; Write-Host " Author: " -ForegroundColor Green -NoNewline; Write-Host "Kiran Patnayakuni" -ForegroundColor Magenta
@kpatnayakuni
kpatnayakuni / profiles.json
Last active March 17, 2026 20:42
Windows Terminal Profiles
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
<#
This script returns the current date time from http://worldclockapi.com/ using REST API service.
You can find the latest uri from the site above.
Eastern Standard Time http://worldclockapi.com/api/json/est/now
Coordinated Universal Time http://worldclockapi.com/api/json/utc/now
@kpatnayakuni
kpatnayakuni / Demo-Archive.ps1
Created January 31, 2019 09:27
Zip & Unzip files
### Examples are from Microsoft Docs
## Zip the files
# Example 1: Create an archive file
Compress-Archive -LiteralPath C:\Reference\Draftdoc.docx, C:\Reference\Images\diagram2.vsd -CompressionLevel Optimal -DestinationPath C:\Archives\Draft.Zip
# Example 2: Create an archive with wildcard characters
Compress-Archive -Path C:\Reference\* -CompressionLevel Fastest -DestinationPath C:\Archives\Draft
# Example 3: Update an existing archive file
#requires -Module Az
## Ensure logged into your Azure account
if([string]::IsNullOrEmpty($(Get-AzContext)))
{ Add-AzAccount }
## Define the required variables
$SubscriptionId = '<SubscriptionId>' # This is your subscription id (ex: 'f34d6539-c45b-4a93-91d9-0b4e6ffb6030')
$ResourceGroupName = 'static-websites-rg' # Resource Group
$Location = 'southindia' # Location
# Enter your ps script name including path
# And launch application to the script file at the end of the code
# Start-Process -FilePath <yourapplication.exe>
$ScriptFile = 'yourpsfileincludingpath.ps1'
$ShortcutFile = "$Home\Desktop\" + (Get-ChildItem -Path $ScriptFile).BaseName + '.lnk'
$PowerShellPath = "$env:SystemRoot\system32\WindowsPowerShell\v1.0\powershell.exe"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $PowerShellPath
Function Create-NewItem
{
[CmdLetBinding(SupportsShouldProcess)]
param
(
[parameter(mandatory=$true,parametersetname="Path")]
[parameter(mandatory=$false,parametersetname="Name")]
[string]$Path,
[parameter(mandatory=$true,parametersetname="Name")]
[string] $Name,
# Copy a file using named paramaters
Copy-Item -Path $env:windir\Temp\CSV1.csv -Destination $env:TEMP\CSV1.csv -Force
# With array
$paramarray = @("$env:windir\Temp\CSV1.csv", "$env:TEMP\CSV1.csv")
Copy-Item @paramarray -Force
$CSV1 = Import-Csv ".\CSV1.csv"
<#
Code UUID Asset
---- ---- -----
DL1721 MNY07789-D112-E34C-B41D-4ACFB442B60P 23160
HP1023 ABC07789-D112-E34C-B41D-4ACFB442B65D 23145
HP2190 XYZ07789-D112-E34C-B41D-4ACFB442B65E 23146
#>