Skip to content

Instantly share code, notes, and snippets.

View PrateekKumarSingh's full-sized avatar

Prateek Singh PrateekKumarSingh

View GitHub Profile
$obj = [pscustomobject]@{
PStypename = "myObject" 
Name = "Jeff"
Computername = "Server1"
Date = (Get-Date)
}
$obj | Get-Member
$obj = [pscustomobject]@{
Name = "Jeff"
Computername = "Server1"
Date = (Get-Date)
}
$obj.psobject.typenames.insert(0, "myObject")
function Get-CustomDate
{
param(
[Parameter(Mandatory = $true)]
[string]$DateString,
[string]$DateFormat = 'ddd MMM d HH:mm:ss yyyy',
[cultureinfo]$Culture = $(Get-UICulture)
)
<#
.SYNOPSIS
Retries a powershell command n-times.
.DESCRIPTION
The cmdlet is capable of retrying a PowerShell command passed as a [ScriptBlock] according to the user defined number of retries and timeout (In Seconds)
.PARAMETER TimeoutInSecs
Timeout in secods for each retry.
@PrateekKumarSingh
PrateekKumarSingh / CREDSSP.txt
Created January 16, 2019 11:08
CredSSP Issue, Local registry edit
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters\ /v AllowEncryptionOracle /t REG_DWORD /d 2
# defining a lambda function
mul = lambda arg1, arg2: arg1*arg2
# calling a lambda function
mul(2,4)
mul(3,5)
[ScriptBlock].FullName # full name of the class
# creating the script block then invokig it
[ScriptBlock]::create('$args[0]*2').invoke(2)
[ScriptBlock]::create('$args[0]*2').invoke(5)
$mul = {param($num1,$num2) $num1*$num2}
# calling the anonymous function with named parameters
& $mul -num1 2 -num2 4
# defining a anonymous function
$mul = $args[0]*$args[1]}
# calling a anonymous function
& $mul 2 4
& $mul 3 5
# Install-Module Graphical, Coin -Force
Import-Module Graphical, Coin
$Date = Get-Date
# capture price history
$LTC = Get-CoinPriceHistory -FromSymbol LTC -ToSymbol USD -DataInterval Day -Since $Date.AddDays(-30*3) -Until $Date | % close
$ETH = Get-CoinPriceHistory -FromSymbol ETH -ToSymbol USD -DataInterval Day -Since $Date.AddDays(-30*3) -Until $Date | % close
$BTC = Get-CoinPriceHistory -FromSymbol BTC -ToSymbol USD -DataInterval Day -Since $Date.AddDays(-30*3) -Until $Date | % close
$ZEC = Get-CoinPriceHistory -FromSymbol ZEC -ToSymbol USD -DataInterval Day -Since $Date.AddDays(-30*3) -Until $Date | % close