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
| 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" } |
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
| 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 |
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
| { | |
| "globals" : | |
| { | |
| "alwaysShowTabs" : true, | |
| "defaultProfile" : "{574e775e-4f2a-5b96-ac1e-a2962a402336}", | |
| "initialCols" : 120, | |
| "initialRows" : 30, | |
| "keybindings" : | |
| [ | |
| { |
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
| <# | |
| 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 |
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
| ### 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 |
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
| #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 |
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
| # 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 |
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
| 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, |
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
| # 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 |
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
| $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 | |
| #> |