mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-16 09:50:02 +01:00
add show-notification-motivation-quote script
This commit is contained in:
parent
67a251c8de
commit
a6ef0c2876
31
README.md
31
README.md
@ -288,27 +288,27 @@ Mega Collection of PowerShell Scripts
|
||||
------------------------------
|
||||
|
||||
| Script | Description |
|
||||
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
||||
|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [add-memo.ps1](scripts/add-memo.ps1) | Adds the given memo text to $HOME/Memos.csv. [Read more...](docs/add-memo.md) |
|
||||
| [check-ipv4-address.ps1](scripts/check-ipv4-address.ps1)| Checks the given IPv4 address for validity. [Read more...](docs/check-ipv4-address.md) |
|
||||
| [check-ipv6-address.ps1](scripts/check-ipv6-address.ps1)| Checks the given IPv6 address for validity. [Read more...](docs/check-ipv6-address.md) |
|
||||
| [check-mac-address.ps1](scripts/check-mac-address.ps1)| Checks the given MAC address for validity. [Read more...](docs/check-mac-address.md) |
|
||||
| [check-subnet-mask.ps1](scripts/check-subnet-mask.ps1)| Checks the given subnet mask for validity. [Read more...](docs/check-subnet-mask.md) |
|
||||
| [check-ipv4-address.ps1](scripts/check-ipv4-address.ps1) | Checks the given IPv4 address for validity. [Read more...](docs/check-ipv4-address.md) |
|
||||
| [check-ipv6-address.ps1](scripts/check-ipv6-address.ps1) | Checks the given IPv6 address for validity. [Read more...](docs/check-ipv6-address.md) |
|
||||
| [check-mac-address.ps1](scripts/check-mac-address.ps1) | Checks the given MAC address for validity. [Read more...](docs/check-mac-address.md) |
|
||||
| [check-subnet-mask.ps1](scripts/check-subnet-mask.ps1) | Checks the given subnet mask for validity. [Read more...](docs/check-subnet-mask.md) |
|
||||
| [check-weather.ps1](scripts/check-weather.ps1) | Checks the current weather for critical values. [Read more...](docs/check-weather.md) |
|
||||
| [display-time.ps1](scripts/display-time.ps1) | Displays the current time for 10 seconds by default. [Read more...](docs/display-time.md) |
|
||||
| [list-anagrams.ps1](scripts/list-anagrams.ps1) | Lists all anagrams of the given word. [Read more...](docs/list-anagrams.md) |
|
||||
| [list-city-weather.ps1](scripts/list-city-weather.ps1)| Lists the current weather of cities worldwide (west to east). [Read more...](docs/list-city-weather.md) |
|
||||
| [list-city-weather.ps1](scripts/list-city-weather.ps1) | Lists the current weather of cities worldwide (west to east). [Read more...](docs/list-city-weather.md) |
|
||||
| [list-countries.ps1](scripts/list-countries.ps1) | Lists details of all countries. [Read more...](docs/list-countries.md) |
|
||||
| [list-credits.ps1](scripts/list-credits.ps1) | Shows the credits. [Read more...](docs/list-credits.md) |
|
||||
| [list-crypto-rates.ps1](scripts/list-crypto-rates.ps1)| Lists the current crypto exchange rates. [Read more...](docs/list-crypto-rates.md) |
|
||||
| [list-environment-variables.ps1](scripts/list-environment-variables.ps1)| Lists all environment variables. [Read more...](docs/list-environment-variables.md)|
|
||||
| [list-crypto-rates.ps1](scripts/list-crypto-rates.ps1) | Lists the current crypto exchange rates. [Read more...](docs/list-crypto-rates.md) |
|
||||
| [list-environment-variables.ps1](scripts/list-environment-variables.ps1) | Lists all environment variables. [Read more...](docs/list-environment-variables.md) |
|
||||
| [list-emojis.ps1](scripts/list-emojis.ps1) | Lists the emojis of Unicode 13.0. [Read more...](docs/list-emojis.md) |
|
||||
| [list-fritzbox-calls.ps1](scripts/list-fritzbox-calls.ps1)| Lists the FRITZ!Box calls. [Read more...](docs/list-fritzbox-calls.md) |
|
||||
| [list-fritzbox-devices.ps1](scripts/list-fritzbox-devices.ps1)| Lists FRITZ!Box's known devices. [Read more...](docs/list-fritzbox-devices.md) |
|
||||
| [list-fritzbox-calls.ps1](scripts/list-fritzbox-calls.ps1) | Lists the FRITZ!Box calls. [Read more...](docs/list-fritzbox-calls.md) |
|
||||
| [list-fritzbox-devices.ps1](scripts/list-fritzbox-devices.ps1) | Lists FRITZ!Box's known devices. [Read more...](docs/list-fritzbox-devices.md) |
|
||||
| [list-earthquakes.ps1](scripts/list-earthquakes.ps1) | Lists earthquakes with magnitude >= 6.0 for the last 30 days. [Read more...](docs/list-earthquakes.md) |
|
||||
| [list-exchange-rates.ps1](scripts/list-exchange-rates.ps1)| Lists the current exchange rates for the given currency. [Read more...](docs/list-exchange-rates.md) |
|
||||
| [list-exchange-rates.ps1](scripts/list-exchange-rates.ps1) | Lists the current exchange rates for the given currency. [Read more...](docs/list-exchange-rates.md) |
|
||||
| [list-memos.ps1](scripts/list-memos.ps1) | Lists the memos at $HOME/Memos.csv. [Read more...](docs/list-memos.md) |
|
||||
| [list-mysql-tables.ps1](scripts/list-mysql-tables.ps1)| Lists the MySQL server tables. [Read more...](docs/list-mysql-tables.md) |
|
||||
| [list-mysql-tables.ps1](scripts/list-mysql-tables.ps1) | Lists the MySQL server tables. [Read more...](docs/list-mysql-tables.md) |
|
||||
| [list-news.ps1](scripts/list-news.ps1) | Lists the latest news. [Read more...](docs/list-news.md) |
|
||||
| [list-os-releases.ps1](scripts/list-os-releases.ps1) | Lists operating system releases and download URL. [Read more...](docs/list-os-releases.md) |
|
||||
| [list-os-updates.ps1](scripts/list-os-updates.ps1) | Lists operating system updates. [Read more...](docs/list-os-updates.md) |
|
||||
@ -328,9 +328,9 @@ Mega Collection of PowerShell Scripts
|
||||
| [send-tcp.ps1](scripts/send-udp.ps1) | Sends a TCP message to the given IP address and port. [Read more...](docs/send-tcp.md) |
|
||||
| [send-udp.ps1](scripts/send-udp.ps1) | Sends a UDP datagram message to the given IP address and port. [Read more...](docs/send-udp.md) |
|
||||
| [set-timer.ps1](scripts/set-timer.ps1) | Sets a timer for a countdown. [Read more...](docs/set-timer.md) |
|
||||
| [simulate-presence.ps1](scripts/simulate-presence.ps1)| Simulates the human presence against burglars. [Read more...](docs/simulate-presence.md) |
|
||||
| [start-calibre-server.ps1](scripts/start-calibre-server.ps1)| Starts a local Calibre server. [Read more...](docs/start-calibre-server.md) |
|
||||
| [start-ipfs-server.ps1](scripts/start-ipfs-server.ps1)| Starts a local IPFS server. [Read more...](docs/start-ipfs-server.md) |
|
||||
| [simulate-presence.ps1](scripts/simulate-presence.ps1) | Simulates the human presence against burglars. [Read more...](docs/simulate-presence.md) |
|
||||
| [start-calibre-server.ps1](scripts/start-calibre-server.ps1) | Starts a local Calibre server. [Read more...](docs/start-calibre-server.md) |
|
||||
| [start-ipfs-server.ps1](scripts/start-ipfs-server.ps1) | Starts a local IPFS server. [Read more...](docs/start-ipfs-server.md) |
|
||||
| [switch-shelly1.ps1](scripts/switch-shelly1.ps1) | Switches a Shelly1 device in the local network. [Read more...](docs/switch-shelly1.md) |
|
||||
| [translate-file.ps1](scripts/translate-file.ps1) | Translates the given text file into other languages. [Read more...](docs/translate-file.md) |
|
||||
| [translate-files.ps1](scripts/translate-files.ps1) | Translates the given text files into any supported language. [Read more...](docs/translate-files.md) |
|
||||
@ -355,6 +355,7 @@ Mega Collection of PowerShell Scripts
|
||||
| [write-typewriter.ps1](scripts/write-typewriter.ps1) | Writes the given text with the typewriter effect. [Read more...](docs/write-typewriter.md) |
|
||||
| [write-uppercase.ps1](scripts/write-uppercase.ps1) | Writes the given text in uppercase letters. [Read more...](docs/write-uppercase.md) |
|
||||
| [write-vertical.ps1](scripts/write-vertical.ps1) | Writes the given text in vertical direction. [Read more...](docs/write-vertical.md) |
|
||||
| [show-notification-motivation-quote.ps1](scripts/show-notification-motivation-quote.ps1) | Show notification with random cat picture and motivation quote. [Read more...](docs/show-notification-motivation-quote.md) |
|
||||
|
||||
📧 Feedback
|
||||
------------
|
||||
|
74
docs/show-notification-motivation-quote.md
Normal file
74
docs/show-notification-motivation-quote.md
Normal file
@ -0,0 +1,74 @@
|
||||
Script: *show-notification-motivation-quote.ps1*
|
||||
========================
|
||||
|
||||
This PowerShell script shows a toast-message notification with random cat picture and random motivation quote.
|
||||
You can change Quote API key using yours.
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./show-notification-motivation-quote.ps1
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: [Gorlov Igor](https://github.com/noBloodOnTheLeaves) | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
#Api key for quotes https://api.api-ninjas.com
|
||||
$headerQuote = @{
|
||||
"X-Api-Key"="FZ/rIx6RAn/W7+3S10zrHQ==gWBfP5fO0xcUiKp3"
|
||||
}
|
||||
#calling api and getting quoute
|
||||
$quote = Invoke-WebRequest -Uri https://api.api-ninjas.com/v1/quotes?category=inspirational -Method GET -Headers $headerQuote
|
||||
#parsing json response
|
||||
$quoteObj = ConvertFrom-Json $([String]::new($quote.Content))
|
||||
|
||||
$headlineText = $quoteObj.author
|
||||
$bodyText = $quoteObj.quote
|
||||
#defualt windows Icon for notification icon
|
||||
$logo = 'C:\Windows\System32\@WindowsHelloFaceToastIcon.png'
|
||||
|
||||
#get random picture of cat
|
||||
$image = Invoke-WebRequest -Uri 'https://api.thecatapi.com/v1/images/search?size=small' -Method Get
|
||||
#parsing json response
|
||||
$jsonObj = ConvertFrom-Json $([String]::new($image.Content))
|
||||
|
||||
$wc = New-Object System.Net.WebClient
|
||||
#put cat picture into your user pictures folder
|
||||
$wc.DownloadFile($jsonObj.url, "C:\Users\" + $Env:Username + "\Pictures\test.jpg")
|
||||
|
||||
|
||||
$xml = @"
|
||||
<toast>
|
||||
<visual>
|
||||
<binding template="ToastGeneric">
|
||||
<text>$($headlineText)</text>
|
||||
<text>$($bodyText)</text>
|
||||
<image placement="appLogoOverride" src="$($logo)"/>
|
||||
<image placement="hero" addImageQuery="true" src="C:\Users\User\Pictures\test.jpg"/>
|
||||
</binding>
|
||||
</visual>
|
||||
<audio silent="true"/>
|
||||
</toast>
|
||||
"@
|
||||
|
||||
#play cat mew with notification
|
||||
$MediaPlayer = [Windows.Media.Playback.MediaPlayer, Windows.Media, ContentType = WindowsRuntime]::New()
|
||||
$MediaPlayer.Source = [Windows.Media.Core.MediaSource]::CreateFromUri('https://v1.cdnpk.net/videvo_files/audio/premium/audio0023/watermarked/AnimalCat 6003_40_1_preview.mp3')
|
||||
$MediaPlayer.Volume = 10.
|
||||
$MediaPlayer.Play()
|
||||
|
||||
#show notification
|
||||
$XmlDocument = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]::New()
|
||||
$XmlDocument.loadXml($xml)
|
||||
$AppId = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
|
||||
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]::CreateToastNotifier($AppId).Show($XmlDocument)
|
||||
```
|
50
scripts/show-notification-motivation-quote.ps1
Normal file
50
scripts/show-notification-motivation-quote.ps1
Normal file
@ -0,0 +1,50 @@
|
||||
#Api key for quotes https://api.api-ninjas.com
|
||||
$headerQuote = @{
|
||||
"X-Api-Key"="FZ/rIx6RAn/W7+3S10zrHQ==gWBfP5fO0xcUiKp3"
|
||||
}
|
||||
#calling api and getting quoute
|
||||
$quote = Invoke-WebRequest -Uri https://api.api-ninjas.com/v1/quotes?category=inspirational -Method GET -Headers $headerQuote
|
||||
#parsing json response
|
||||
$quoteObj = ConvertFrom-Json $([String]::new($quote.Content))
|
||||
|
||||
$headlineText = $quoteObj.author
|
||||
$bodyText = $quoteObj.quote
|
||||
#defualt windows Icon for notification icon
|
||||
$logo = 'C:\Windows\System32\@WindowsHelloFaceToastIcon.png'
|
||||
|
||||
#get random picture of cat
|
||||
$image = Invoke-WebRequest -Uri 'https://api.thecatapi.com/v1/images/search?size=small' -Method Get
|
||||
#parsing json response
|
||||
$jsonObj = ConvertFrom-Json $([String]::new($image.Content))
|
||||
|
||||
$wc = New-Object System.Net.WebClient
|
||||
#put cat picture into your user pictures folder
|
||||
$wc.DownloadFile($jsonObj.url, "C:\Users\" + $Env:Username + "\Pictures\test.jpg")
|
||||
|
||||
|
||||
$xml = @"
|
||||
<toast>
|
||||
<visual>
|
||||
<binding template="ToastGeneric">
|
||||
<text>$($headlineText)</text>
|
||||
<text>$($bodyText)</text>
|
||||
<image placement="appLogoOverride" src="$($logo)"/>
|
||||
<image placement="hero" addImageQuery="true" src="C:\Users\User\Pictures\test.jpg"/>
|
||||
</binding>
|
||||
</visual>
|
||||
<audio silent="true"/>
|
||||
</toast>
|
||||
"@
|
||||
|
||||
#play cat mew with notification
|
||||
$MediaPlayer = [Windows.Media.Playback.MediaPlayer, Windows.Media, ContentType = WindowsRuntime]::New()
|
||||
$MediaPlayer.Source = [Windows.Media.Core.MediaSource]::CreateFromUri('https://v1.cdnpk.net/videvo_files/audio/premium/audio0023/watermarked/AnimalCat 6003_40_1_preview.mp3')
|
||||
$MediaPlayer.Volume = 10.
|
||||
$MediaPlayer.Play()
|
||||
|
||||
#show notification
|
||||
$XmlDocument = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]::New()
|
||||
$XmlDocument.loadXml($xml)
|
||||
$AppId = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
|
||||
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]::CreateToastNotifier($AppId).Show($XmlDocument)
|
||||
|
Loading…
Reference in New Issue
Block a user