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 Coin -Force | |
$Date = Get-Date | |
# define parameters for splatting | |
$param = @{ | |
FromSymbol ='BTC' | |
ToSymbol ='USD' | |
DataInterval ='Day' | |
Since = $Date.AddDays(-7) |
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 the modules from PowerShell Gallery | |
Install-Module Graphical, Coin -Force | |
$Date = Get-Date | |
# define parameters for splatting | |
$param = @{ | |
FromSymbol ='BTC' | |
ToSymbol ='USD' | |
DataInterval ='Day' |
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
# 1. Enable Windows Feature: | |
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | |
# alternatively: Appwiz.cpl > Turn Windows Feature On/Off > Windows Subsystem for Linux | |
# 2. Restart your machine when prompted | |
Restart-Computer | |
# 3. Go to MicroSoft store and find a Suitable Linux Distribution. Install It. | |
# 4. Once the Installation is complete, Launch the WSL (Windows Subsystem for Linux) |
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
$password = ConvertTo-SecureString 'Password@123' -AsPlainText -Force | |
New-Object System.Management.Automation.PSCredential ('Administrator', $password) | |
# Alternatively create credentials using the type accelerator | |
[PSCredential]::new('Adminstrator', $password) |
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
# method 1 - Enviroment Variables | |
$env:PROCESSOR_ARCHITECTURE | |
[Environment]::Is64BitOperatingSystem | |
# method 2 - WMI and CIM classes | |
(Get-WmiObject Win32_OperatingSystem).OSArchitecture | |
(Get-CimInStance CIM_OperatingSystem).OSArchitecture | |
(Get-WmiObject Win32_Processor).AddressWidth | |
# method 3 - Native CMD commands |
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
# Using New-Object and hashtables | |
$properties = @{ | |
firstname = 'Prateek' | |
lastname = 'Singh' | |
} | |
$o = New-Object psobject -Property $properties; $o |
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 = New-Object -TypeName psobject | |
$obj | Add-Member -MemberType NoteProperty -Name firstname -Value 'Prateek' | |
$obj | Add-Member -MemberType NoteProperty -Name lastname -Value 'Singh' | |
# add a method to an object | |
$obj | Add-Member -MemberType ScriptMethod -Name "GetName" -Value {$this.firstname +' '+$this.lastname} |
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
Select-Object @{n='firstname';e={'Prateek'}},@{n='lastname';e={'Singh'}} -InputObject '' | |
# alternatively | |
'' | Select-Object @{n='firstname';e={'Prateek'}},@{n='lastname';e={'Singh'}} |
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
[pscustomobject]@{ | |
firstname = 'Prateek' | |
lastname = 'Singh' | |
} |
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
# substring using .substring() method | |
$string = "My name is Prateek Singh`nI`'m from India" | |
$string.Substring(11,7) # output: 'Prateek' | |
$string.Substring(25,14) # output: 'I'm from India' | |
$string.Substring(11,13) # output: 'Prateek Singh' |