Skip to content

Instantly share code, notes, and snippets.

View kvprasoon's full-sized avatar
🙏
>_

PRASOON KARUNAN V kvprasoon

🙏
>_
View GitHub Profile
@kvprasoon
kvprasoon / kvp_braincandy_20190831.ps1
Last active August 31, 2019 18:26
kvp_braincandy_20190831.ps1
# https://twitter.com/dfinke/status/1167559940598370304
$a='';1..9|%{"{0,9} x 8 + $_ = $(8*($a+=$_)+$_)"-f$a}
# if executing only once in a scope
1..9|%{"{0,9} x 8 + $_ = $(8*($a+="$_")+$_)"-f$a}
@kvprasoon
kvprasoon / Pester.Remark.json
Last active July 17, 2023 19:26
Json config for Pester with remark
{
"service": {
"suggestion": {
"startmode": "Open PowerShell as administrator and run 'Set-Service -Name {0} -StartType {1}'",
"status": "Make the service '{0}' in {1} state."
},
"expectedconfiguration": [
{
"name": "BITS",
"status": "running",
@kvprasoon
kvprasoon / Pester.Remark.tests.ps1
Last active July 17, 2023 19:26
Pester with remark
param(
[Parameter(Mandatory = $True)]
[string]$ConfigPath
)
$Config = Get-Content -Path $ConfigPath | ConvertFrom-Json
Describe "Describing validation tests post deployment" {
Context "Post deployment validation tests for services" {
BeforeAll {
@kvprasoon
kvprasoon / Show-Tree.ps1
Last active March 15, 2019 19:28
Cross platform Show-Tree.ps1
<#PSScriptInfo
.VERSION 1.0.0
.GUID 3b5ee706-249d-4108-8126-c8692d603ebc
.AUTHOR Jeffrey Snover
.COMPANYNAME Microsoft Corporation
@kvprasoon
kvprasoon / ScreenShot.ps1
Created March 20, 2018 19:11
Script to save a Screenshot
Param(
[String]$OutFilePath
)
Add-type -AssemblyName System.Drawing
$VirtualScreen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Bmp = New-Object System.Drawing.Bitmap $VirtualScreen.Width, $VirtualScreen.Height
$Graphic = [System.Drawing.Graphics]::FromImage($bmp)
$Graphic.CopyFromScreen($VirtualScreen.Left, $VirtualScreen.Top, 0, 0, $Bmp.Size)
$Bmp.Save($OutFilePath)
@kvprasoon
kvprasoon / Build-ParamLog.ps1
Last active February 27, 2018 18:50
Script to create expressions to print parameter values in a PowerShell script
<#
.SYNOPSIS
This script will help to create expressions for logging the input values of a PowerShell script.
.DESCRIPTION
This script will help to create expressions for logging the input values of a PowerShell script.
.EXAMPLE
PS C:\> .\Build-ParamLog.ps1 -Script C:\Test.PS1 -Prefix Log
Above execution will create expressions with prefix Log, see below.
@kvprasoon
kvprasoon / ScriptingGamesJan2016.ps1
Last active January 11, 2016 04:37
ScriptingGamesJan2016
Function Get-Uptime{
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline = $true)]
[String[]]$ComputerName = $env:COMPUTERNAME
)
Begin
{
$Output=@()
@kvprasoon
kvprasoon / ScriptingGamesOct2015.ps1
Last active January 2, 2016 08:28
Get-RSSFeed.ps1
<#
.Synopsis
Shows you the RSS Feeds for given URI.
.DESCRIPTION
This cmdlet Shows you RSS Feeds for a given URI.Results for this cmdlet includes Title,Link and a Short Description for specified Link.
.EXAMPLE
PS C:\WINDOWS\system32> Get-RSSFeed -Uri http://blogs.msdn.com/powershell -OutFilePath C:\Users\PR615733\Documents\RssFeedExample1.csv -OpenAfterExecution -Verbose
Title Link
----- ----
@kvprasoon
kvprasoon / ScriptingGamesSep2015.ps1
Created September 7, 2015 17:41
ScriptingGamesSep
$Cred=Get-Credential;import-csv C:\powershell.org\Input.csv|select -ExpandProperty machinename |foreach{new-object psobject -Property @{'MACHIUNENAME'=$_;'OS VERSION'=$(Get-WmiObject -Class win32_operatingsystem -ComputerName $_ -Credential $cred|select -ExpandProperty caption)}}|Export-Csv C:\powershell.org\Output.csv -NoTypeInformation
@kvprasoon
kvprasoon / ScriptingGamesAug2015.ps1
Last active August 30, 2015 04:36
A oneliner Which uses JSON
#Invoke-WebRequest -Uri www.telize.com/geoip|select -ExpandProperty content|ConvertFrom-Json|select longitude,latitude,country_code,timezone
function Get-GeoInformation
{
[CmdletBinding()]
[Alias('ggeo')]
param(
[Parameter(ValueFromPipeLine=$true)]
[ValidateNotNull()]