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
# web search a keyword to get snippets | |
$Snippets = Search-Web "Jeffery Snover" | | |
ForEach-Object {$_.webpages.value.snippet} | |
# extract keywords from snippets | |
$Words = $snippets.ForEach({ | |
Get-KeyPhrase -Text $_ -ErrorAction SilentlyContinue | |
}).documents.keyphrases.split(' ') |
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
# add subscription keys & location from azure | |
# to $profile as $env variables | |
# and load them in them in current session | |
$null = New-LocalConfiguration -FromAzure -AddKeysToProfile -Verbose |
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
# installation | |
Install-Module PSCognitiveService -Verbose -Force -Confirm:$false -Scope CurrentUser | |
# import module | |
Import-Module PSCognitiveService | |
# create cognitive service accounts in azure | |
$Params1 = @{ | |
AccountType = 'Bing.Search.v7' | |
ResourceGroupName = 'demo-resource-group' |
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
Import-Module Graphical | |
# inputs | |
$WarningPreference = 'SilentlyContinue' | |
$TimeGrain = [timespan]::FromMinutes(1) | |
$MetricName = 'Percentage CPU' | |
$ResourceName = 'MyVM' | |
$Start = [datetime]::Now.AddMinutes(-90) | |
$End = [datetime]::Now.AddMinutes(-45) |
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
# plot the graph | |
Show-Graph -Datapoints $Datpoints -GraphTitle $MetricName -YAxisStep 5 | |
Show-Graph -Datapoints $Datpoints -GraphTitle $MetricName -YAxisStep 5 -Type Line | |
Show-Graph -Datapoints $Datpoints -GraphTitle $MetricName -YAxisStep 5 -Type Scatter |
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
# capture resource metrics | |
$ResourceID = (Get-AzResource -ResourceName $ResourceName).ResourceId | |
$Splat = @{ | |
ResourceId = $ResourceID | |
MetricName = $MetricName | |
TimeGrain = $TimeGrain | |
StartTime = $Start | |
EndTime = $End | |
} |
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
# inputs | |
$WarningPreference = 'SilentlyContinue' | |
$TimeGrain = [timespan]::FromMinutes(1) | |
$MetricName = 'Percentage CPU' | |
$ResourceName = 'MyVM' | |
$Start = [datetime]::Now.AddMinutes(-90) | |
$End = [datetime]::Now.AddMinutes(-45) |
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
Application Performance Monitoring | |
1. response times, user satisfaction | |
2. delays is requests, most used | |
3. Windows Performance counters | |
4. capacity | |
4. logs | |
5. Alert | |
6. Action and remediation | |
7. dependencies |
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 9 - From String using `-Match` operator | |
$Hashtable = @{} | |
@" | |
name=prateek | |
age=29 | |
skills=powershell | |
"@ -split [System.Environment]::NewLine | ForEach-Object { | |
if ($_ -match '^(.*)=(.*)'){ | |
$Hashtable[$matches[1]] = $matches[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
# Method 8 - String to Hashtable using `ConvertFrom-StringData` cmdlet | |
@" | |
name=prateek | |
age=29 | |
skills=powershell | |
"@ | ConvertFrom-StringData |