# Http Server
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")
This file contains 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
See youtube below for easy install instruction (just copy and paste oneliner in Powershell) and demo tour of Text-to-speech with Cortana: | |
https://www.youtube.com/watch?v=u3rIyxtpEFY |
This file contains 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
# installation | |
Install-Module PSCognitiveService -Force -Scope CurrentUser -Verbose | |
Import-Module PSCognitiveService -Force -Verbose | |
# create AzureRM Cognitive Service subscription | |
New-CognitiveServiceAccount -AccountType Face -ResourceGroupName RG1 -Location southeastasia -SKUName F0 -Verbose | Out-Null | |
New-CognitiveServiceAccount -AccountType ComputerVision -ResourceGroupName RG1 -Location southeastasia -SKUName F0 -Verbose | Out-Null | |
# create AzureRM Cognitive Service subscription when you're unsure of resource groups, price tier and location | |
New-CognitiveServiceAccount -AccountType Bing.Search.v7 -Verbose |
This file contains 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 Debug-Error { | |
[OutputType([void])] | |
[CmdletBinding()] | |
param | |
() | |
$action = { | |
if ($_ -and ($stacktrace -notmatch '^\s*at System\.Management\.Automation\.ExceptionHandlingOps\.CheckActionPreference') -and ($stacktrace -notmatch '^\s*at System\.Management\.Automation\.MshCommandRuntime\.ThrowTerminatingError\(ErrorRecord errorRecord\)\s*$')) { | |
break | |
} |
This file contains 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
# encoding the URL | |
[System.Web.HTTPUtility]::UrlEncode("https://RidiCurious.com") | |
# decoding the URL | |
[System.Web.HTTPUtility]::UrlDecode("https%3a%2f%2fRidiCurious.com") |
This file contains 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
$data = Invoke-WebRequest https://www.sqlshack.com/top-50-powershell-bloggers-of-2018/ | |
$data.Links.Where({ $_.href -like "*http*" -and | |
$_.href -notlike "*twitter*" -and | |
$_.href -notlike "*sql*" -and | |
$_.href -notlike "*creativecomm*" -and | |
$_.href -notlike "*microsoft*" | |
}) | Select-Object href -Unique -ExpandProperty href |
This file contains 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
# define a set | |
$x = [System.Collections.Generic.HashSet[string]]::new() | |
'python'.ToCharArray().foreach({[void]$x.add($_)}) | |
$y = [System.Collections.Generic.HashSet[string]]::new() | |
'powershell'.ToCharArray().foreach({[void$y.add($_)}) | |
$x.ExceptWith($y) # All the elements in x but not in y | |
# union | |
$x.UnionWith($y) # Unique elements in x or y or both |
This file contains 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
# Create an Internet Explorer object | |
$ie = New-Object -ComObject 'internetExplorer.Application' | |
$ie.Visible= $true # Make it visible | |
# Open all websites | |
$ie.Navigate("www.linkedin.com") | |
# Navigate2() function to open in new tab in the same IE window | |
$ie.Navigate2("www.facebook.com",0x1000) |
This file contains 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 to enable telnet-ing from [Local/Remote] Source location, which requires credentials for remote source machine | |
# This Function is a wrapper around Function PSTelnet to add remote source telnet-ing feature | |
Function Test-Port | |
{ | |
[cmdletbinding()] | |
Param | |
( | |
[Parameter(Position=0)] $Source = $(Hostname), | |
[Parameter(Mandatory=$true,Position=1)] $Destination, |
This file contains 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
Test-Port -Source '127.0.0.1' -Destination '10.196.11.206','10.196.11.206','10.196.11.206','123.234.234.3' ` | |
-Port 3389,20, 21 -Verbose | ft -AutoSize | |
#-Iterate | Export-Csv portstatus.csv -NoTypeInformation | |
#Test-PortConnectivity '127.0.0.1' 'dc1' 57766 -Protocol UDP -Iterate | |
#Test-PortConnectivity 'localhost' 'dc2' 51753 -Protocol UDP | |
#Test-PortConnectivity -Source $EUCAS -Destination $EUMBX -Port 135 -Iterate | |
#Test-PortConnectivity -Source 'localhost' -Destination '127.0.0.1' -Port 135 -Iterate -protocol TCP | |
Function Test-Port |
OlderNewer