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
$obj = [pscustomobject]@{ | |
PStypename = "myObject" | |
Name = "Jeff" | |
Computername = "Server1" | |
Date = (Get-Date) | |
} | |
$obj | Get-Member |
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
$obj = [pscustomobject]@{ | |
Name = "Jeff" | |
Computername = "Server1" | |
Date = (Get-Date) | |
} | |
$obj.psobject.typenames.insert(0, "myObject") |
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 Get-CustomDate | |
{ | |
param( | |
[Parameter(Mandatory = $true)] | |
[string]$DateString, | |
[string]$DateFormat = 'ddd MMM d HH:mm:ss yyyy', | |
[cultureinfo]$Culture = $(Get-UICulture) | |
) |
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
<# | |
.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. |
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
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters\ /v AllowEncryptionOracle /t REG_DWORD /d 2 |
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
# defining a lambda function | |
mul = lambda arg1, arg2: arg1*arg2 | |
# calling a lambda function | |
mul(2,4) | |
mul(3,5) |
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
[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) |
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
$mul = {param($num1,$num2) $num1*$num2} | |
# calling the anonymous function with named parameters | |
& $mul -num1 2 -num2 4 |
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
# defining a anonymous function | |
$mul = $args[0]*$args[1]} | |
# calling a anonymous function | |
& $mul 2 4 | |
& $mul 3 5 |
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
# 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 |