Skip to content

Instantly share code, notes, and snippets.

View PrateekKumarSingh's full-sized avatar

Prateek Singh PrateekKumarSingh

View GitHub Profile
if($Size -ge 1GB){ $SizeWithUnit = "{0:N2} GB" -f ($Size/1gb) }elseif($Size -ge 1Mb){ $SizeWithUnit = "{0:N2} MB" -f ($Size/1mb) }else{$SizeWithUnit = "{0:N2} KB" -f ($Size/1kb)}
aaron-bond.better-comments
adelphes.google-search-ext
ahmadawais.shades-of-purple
atomiks.moonlight
beastdestroyer.firefox-quantum-themes
chunsen.bracket-select
CoenraadS.bracket-pair-colorizer
daylerees.rainglow
donjayamanne.githistory
DougFinke.vscode-PSStackoverflow
$data = irm https://raw.githubusercontent.com/PowerShellAsia/PSConfAsia2019/master/data.json -Verbose
@('',1,2).foreach({$data."Tracks$_".Sessions.speaker.name.trim()}) | ?{![string]::IsNullOrWhiteSpace($_)} | select -Unique
https://github.com/powershell/powershell/issues
https://docs.microsoft.com/en-us/powershell/scripting/whats-new/known-issues-ps6?view=powershell-6
https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-core-62?view=powershell-6
https://devblogs.microsoft.com/powershell/the-next-release-of-powershell-powershell-7/
# https://stackoverflow.com/questions/42145440/powershell-capture-mouse-click-event-inside-a-powershell-console
Add-Type -ReferencedAssemblies System.Drawing @"
using System;
using System.Drawing;
using System.Runtime.InteropServices;
public class Window
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
html {
head{
title "woop title"
link "css/normalize.css" "stylesheet"
}
body{
h1 "This is h1 Title in header"
div {
p {
"This is simply a paragraph in a div."
Function Get-Vars{
Write-Host "-------------------------------------------------------------------"
Write-Host "-------------------------------------------------------------------"
switch($host.Name){
'Visual Studio Code Host' {
$psEditor.GetEditorContext().CurrentFile.tokens.where({$_.kind -eq 'variable'}) | Select @{n='Name';e={$_.extent}},@{n='value';e={iex $($_.extent)}} -Unique
}
'Windows PowerShell ISE Host' {
$abstractSyntaxTree = [System.Management.Automation.Language.Parser]::ParseInput($psISE.CurrentFile.Editor.Text, [ref]$null, [ref]$null)
$AbstractSyntaxTree.FindAll({$args[0] -is [System.Management.Automation.Language.VariableExpressionAst ]}, $true) | Select @{n='Name';e={$_.extent}},@{n='value';e={iex $($_.extent)}} -Unique | ft -AutoSize
function DownloadFTPFile ($Source, $Target, $UserName, $Password) {
$ftprequest = [System.Net.FtpWebRequest]::create($Source)
$ftprequest.Credentials = New-Object System.Net.NetworkCredential($username, $password)
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
$ftprequest.UseBinary = $true
$ftprequest.KeepAlive = $false
# send the ftp request to the server
$ftpresponse = $ftprequest.GetResponse()
$Path = $env:TEMP
$Installer = "chrome_installer.exe"
Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer
Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait
Remove-Item $Path\$Installer
$ChromeVersion = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*chrome*"}).Version

Prateek Singh is an Infrastructure developer and technical writer who specializes in PowerShell scripting and automation. Off-work he is a PowerShell blogger and open-source community contributor and his blog was recognized among the "Top 50 PowerShell blogs in the world" in the year 2017 and 2018. He has also written numerous articles on websites such as 4SysOps.com and blog.IPSwitch.com.

He has also the author of a 'PowerShell to Python book', and has contributed a chapter to 'The PowerShell Conference' book as a co-author, who also runs a YouTube Channel dedicated to PowerShell, Cloud, and Automation.