Scripts for the Desktop
Scripts for the Desktop 관련
close-calculator.ps1
This PowerShell script closes the calculator application gracefully.
PS> ./close-calculator.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-calculator.ps1
<#
.SYNOPSIS
Closes the calculator application
.DESCRIPTION
This PowerShell script closes the calculator application gracefully.
.EXAMPLE
PS> ./close-calculator
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
Stop-Process -name "CalculatorApp"
exit 0 # success
close-cortana.ps1
This PowerShell script closes Microsoft's Cortana application gracefully.
PS> ./close-cortana.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-cortana.ps1
<#
.SYNOPSIS
Closes Microsoft's Cortana application
.DESCRIPTION
This PowerShell script closes Microsoft's Cortana application gracefully.
.EXAMPLE
PS> ./close-cortana
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Cortana" "Cortana" "Cortana"
exit 0 # success
close-chrome.ps1
This PowerShell script closes the Google Chrome Web browser gracefully.
PS> ./close-chrome.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-chrome
<#
.SYNOPSIS
Closes the Chrome browser
.DESCRIPTION
This PowerShell script closes the Google Chrome Web browser gracefully.
.EXAMPLE
PS> ./close-chrome
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Google Chrome" "chrome" "chrome"
exit 0 # success
close-program.ps1
This PowerShell script closes a program's processes gracefully.
PS> ./close-program.ps1 [[-FullProgramName] <String>] [[-ProgramName] <String>] [[-ProgramAliasName] <String>] [<CommonParameters>]
-FullProgramName <String>
Specifies the full program name
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ProgramName <String>
Specifies the program name
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ProgramAliasName <String>
Specifies the program alias name
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-program.ps1 "Google Chrome" "chrome.exe"
#
<#
.SYNOPSIS
Closes a program's processes
.DESCRIPTION
This PowerShell script closes a program's processes gracefully.
.PARAMETER FullProgramName
Specifies the full program name
.PARAMETER ProgramName
Specifies the program name
.PARAMETER ProgramAliasName
Specifies the program alias name
.EXAMPLE
PS> ./close-program "Google Chrome" "chrome.exe"
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$FullProgramName = "", [string]$ProgramName = "", [string]$ProgramAliasName = "")
try {
if ($ProgramName -eq "") {
get-process | where-object {$_.mainWindowTitle} | format-table Id, Name, mainWindowtitle -AutoSize
$ProgramName = read-host "Enter program name"
}
if ($FullProgramName -eq "") {
$FullProgramName = $ProgramName
}
$Processes = get-process -name $ProgramName -errorAction 'silentlycontinue'
if ($Processes.Count -ne 0) {
foreach ($Process in $Processes) {
$Process.CloseMainWindow() | Out-Null
}
Start-Sleep -milliseconds 100
stop-process -name $ProgramName -force -errorAction 'silentlycontinue'
} else {
$Processes = get-process -name $ProgramAliasName -errorAction 'silentlycontinue'
if ($Processes.Count -eq 0) {
throw "$FullProgramName isn't running"
}
foreach ($Process in $Processes) {
$_.CloseMainWindow() | Out-Null
}
Start-Sleep -milliseconds 100
stop-process -name $ProgramName -force -errorAction 'silentlycontinue'
}
if ($($Processes.Count) -eq 1) {
"✔️ $FullProgramName closed, 1 process stopped"
} else {
"✔️ $FullProgramName closed, $($Processes.Count) processes stopped"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
close-edge.ps1
This PowerShell script closes the Microsoft Edge Web browser gracefully.
PS> ./close-edge.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-edge.ps1
#
<#
.SYNOPSIS
Closes the Edge browser
.DESCRIPTION
This PowerShell script closes the Microsoft Edge Web browser gracefully.
.EXAMPLE
PS> ./close-edge
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
TaskKill /im msedge.exe /f /t
if ($lastExitCode -ne "0") {
& "$PSScriptRoot/speak-english.ps1" "Sorry, Microsoft Edge isn't running."
exit 1
}
exit 0 # success
close-file-explorer.ps1
This PowerShell script closes the Microsoft File Explorer application gracefully.
PS> ./close-file-explorer.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-file-explorer.ps1
#
<#
.SYNOPSIS
Closes the File Explorer
.DESCRIPTION
This PowerShell script closes the Microsoft File Explorer application gracefully.
.EXAMPLE
PS> ./close-file-explorer
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
(New-Object -ComObject Shell.Application).Windows() | %{$_.quit()}
exit 0 # success
close-firefox.ps1
This PowerShell script closes the Mozilla Firefox Web browser gracefully.
PS> ./close-firefox.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-firefox.ps1
#
<#
.SYNOPSIS
Closes the Firefox browser
.DESCRIPTION
This PowerShell script closes the Mozilla Firefox Web browser gracefully.
.EXAMPLE
PS> ./close-firefox
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Mozilla Firefox" "firefox" "firefox"
exit 0 # success
close-microsoft-store.ps1
This PowerShell script closes the Microsoft Store application gracefully.
PS> ./close-microsoft-store.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-microsoft-store.ps1
#
<#
.SYNOPSIS
Closes the Microsoft Store app
.DESCRIPTION
This PowerShell script closes the Microsoft Store application gracefully.
.EXAMPLE
PS> ./close-microsoft-store.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
TaskKill /im WinStore.App.exe /f /t
if ($lastExitCode -ne "0") {
& "$PSScriptRoot/speak-english.ps1" "Sorry, Microsoft Store isn't running."
exit 1
}
exit 0 # success
close-netflix.ps1
This PowerShell script closes the Netflix application gracefully.
PS> ./close-netflix.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-netflix.ps1
#
<#
.SYNOPSIS
Closes the Netflix app
.DESCRIPTION
This PowerShell script closes the Netflix application gracefully.
.EXAMPLE
PS> ./close-netflix.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Netflix" "ApplicationFrameHost" "RuntimeBroker"
exit 0 # success
❌close-onedrive.ps1
This script closes Microsoft's OneDrive folder gracefully.
close-onedrive.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-onedrive
#
close-serenade.ps1
This PowerShell script closes the Serenade.ai application gracefully.
PS> ./close-serenade.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-serenade.ps1
#
<#
.SYNOPSIS
Closes the Serenade.ai application
.DESCRIPTION
This PowerShell script closes the Serenade.ai application gracefully.
.EXAMPLE
PS> ./close-serenade.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Serenade.ai" "serenade" ""
exit 0 # success
close-snipping-tool.ps1
This PowerShell script closes the Snipping Tool application gracefully.
PS> ./close-snipping-tool.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-snipping-tool.ps1
#
<#
.SYNOPSIS
Closes the Snipping Tool
.DESCRIPTION
This PowerShell script closes the Snipping Tool application gracefully.
.EXAMPLE
PS> ./close-snipping-tool.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Snipping Tool" "SnippingTool.exe" ""
exit 0 # success
close-spotify.ps1
This PowerShell script closes the Spotify application gracefully.
PS> ./close-spotify.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-spotify.ps1
#
<#
.SYNOPSIS
Closes Spotify
.DESCRIPTION
This PowerShell script closes the Spotify application gracefully.
.EXAMPLE
PS> ./close-spotify.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Spotify" "spotify" ""
exit 0 # success
❌close-system-settings.ps1
This script closes the System Settings window gracefully.
close-system-settings.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-system-settings
#
close-task-manager.ps1
This PowerShell script closes the Task Manager application gracefully.
PS> ./close-task-manager.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-task-manager.ps1
#
<#
.SYNOPSIS
Closes the Task Manager
.DESCRIPTION
This PowerShell script closes the Task Manager application gracefully.
.EXAMPLE
PS> ./close-task-manager.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
tskill taskmgr
exit 0 # success
close-thunderbird.ps1
This PowerShell script closes the Mozilla Thunderbird email application gracefully.
PS> ./close-thunderbird.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-thunderbird.ps1
#
<#
.SYNOPSIS
Closes the Thunderbird app
.DESCRIPTION
This PowerShell script closes the Mozilla Thunderbird email application gracefully.
.EXAMPLE
PS> ./close-thunderbird.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
TaskKill /im thunderbird.exe
if ($lastExitCode -ne "0") {
& "$PSScriptRoot/speak-english.ps1" "Sorry, Mozilla Thunderbird isn't running."
exit 1
}
exit 0 # success
close-vlc.ps1
This PowerShell script closes the VLC media player application gracefully.
PS> ./close-vlc.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-vlc.ps1
#
<#
.SYNOPSIS
Closes the VLC media player application
.DESCRIPTION
This PowerShell script closes the VLC media player application gracefully.
.EXAMPLE
PS> ./close-vlc.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "VLC media player" "vlc" "vlc"
exit 0 # success
close-windows-terminal.ps1
This PowerShell script closes the Windows Terminal application gracefully.
PS> ./close-windows-terminal.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./close-windows-terminal.ps1
#
<#
.SYNOPSIS
Closes the Windows Terminal app
.DESCRIPTION
This PowerShell script closes the Windows Terminal application gracefully.
.EXAMPLE
PS> ./close-windows-terminal.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/close-program.ps1" "Windows Terminal" "WindowsTerminal" "WindowsTerminal"
exit 0 # success
enable-god-mode.ps1
This PowerShell script enables the god mode in Windows. It adds a new icon to the desktop.
PS> ./enable-god-mode.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./enable-god-mode.ps1
✔ God mode enabled, please click the new desktop icon
#
<#
.SYNOPSIS
Enables the god mode
.DESCRIPTION
This PowerShell script enables the god mode in Windows. It adds a new icon to the desktop.
.EXAMPLE
PS> ./enable-god-mode.ps1
✔ God mode enabled, please click the new desktop icon
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$GodModeSplat = @{
Path = "$HOME\Desktop"
Name = "GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}"
ItemType = 'Directory'
}
$null = New-Item @GodModeSplat
"✔️ God mode enabled, please click the new desktop icon"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
list-clipboard.ps1
This PowerShell script lists the contents of the clipboard.
PS> ./list-clipboard.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./list-clipboard.ps1
# 📋 test
#
<#
.SYNOPSIS
Lists the contents of the clipboard
.DESCRIPTION
This PowerShell script lists the contents of the clipboard.
.EXAMPLE
PS> ./list-clipboard.ps1
📋 test
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
"📋 $(get-clipboard)"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
new-email.ps1
This PowerShell script opens the default email client to write a new email.
PS> ./new-email.ps1 [[-EmailAddress] <String>] [<CommonParameters>]
-EmailAddress <String>
Specifies the email address fill in
Required? false
Position? 1
Default value markus@fleschutz.de
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./new-email.ps1
#
<#
.SYNOPSIS
Opens the default email client to write a new email
.DESCRIPTION
This PowerShell script opens the default email client to write a new email.
.PARAMETER EmailAddress
Specifies the email address fill in
.EXAMPLE
PS> ./new-email.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$EmailAddress = "markus@fleschutz.de")
try {
$URL="mailto:$EmailAddress"
Start-Process $URL
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
❌open-amazon-website.ps1
This script launches the Web browser with the Amazon website.
PS> open-amazon-website.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-amazon-website
#
open-default-browser.ps1
This PowerShell script launches the default Web browser, optional with a given URL.
PS> ./open-default-browser.ps1 [[-URL] <String>] [<CommonParameters>]
-URL <String>
Specifies the URL
Required? false
Position? 1
Default value http://www.fleschutz.de
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-default-browser
#
<#
.SYNOPSIS
Opens the default browser
.DESCRIPTION
This PowerShell script launches the default Web browser, optional with a given URL.
.PARAMETER URL
Specifies the URL
.EXAMPLE
PS> ./open-default-browser
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$URL = "http://www.fleschutz.de")
try {
Start-Process $URL
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-calculator.ps1
This PowerShell script launches the calculator application.
PS> ./open-calculator.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-calculator
#
<#
.SYNOPSIS
Launches the calculator application
.DESCRIPTION
This PowerShell script launches the calculator application.
.EXAMPLE
PS> ./open-calculator
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
Start-Process ms-calculator:
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-c-drive.ps1
This PowerShell script launches the File Explorer with the C:
drive folder.
PS> ./open-c-drive.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-c-drive
#
<#
.SYNOPSIS
Opens the C: drive folder
.DESCRIPTION
This PowerShell script launches the File Explorer with the C: drive folder.
.EXAMPLE
PS> ./open-c-drive
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-file-explorer.ps1" "C:"
exit 0 # success
open-downloads-folders.ps1
This PowerShell script launches the File Explorer showing the user's downloads folder.
PS> ./open-downloads-folder.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-downloads-folder
<#
.SYNOPSIS
Opens the user's downloads folder
.DESCRIPTION
This PowerShell script launches the File Explorer showing the user's downloads folder.
.EXAMPLE
PS> ./open-downloads-folder
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
$Path = Resolve-Path "$HOME/Downloads"
} else {
$Path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path
}
if (-not(Test-Path "$Path" -pathType container)) {
throw "Downloads folder at 📂$Path doesn't exist (yet)"
}
& "$PSScriptRoot/open-file-explorer.ps1" $Path
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-dropbox-folder.ps1
This PowerShell script launches the File Explorer with the user's Dropbox folder.
PS> ./open-dropbox-folder.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
@tba Example
PS> ./open-dropbox-folder
#
<#
.SYNOPSIS
Opens the Dropbox folder
.DESCRIPTION
This PowerShell script launches the File Explorer with the user's Dropbox folder.
.EXAMPLE
PS> ./open-dropbox-folder
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$TargetDirs = resolve-path "$HOME/Dropbox*"
foreach($TargetDir in $TargetDirs) {
& "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir"
exit 0 # success
}
throw "No Dropbox folder at 📂$HOME/Dropbox"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-edge.ps1
This PowerShell script launches the Microsoft Edge Web browser.
PS> ./open-edge.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-edge
#
<#
.SYNOPSIS
Launches the Edge browser
.DESCRIPTION
This PowerShell script launches the Microsoft Edge Web browser.
.EXAMPLE
PS> ./open-edge
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
Start-Process microsoft-edge://
exit 0 # success
open-email-client.ps1
This PowerShell script launches the default email client.
PS> ./open-email-client.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-email-client
#
<#
.SYNOPSIS
Starts the default email client
.DESCRIPTION
This PowerShell script launches the default email client.
.EXAMPLE
PS> ./open-email-client
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
start-process "mailto:markus@fleschutz.de"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
❌open-facebook-website.ps1
This script launches the Web browser with the Facebook website.
open-facebook-website.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-facebook-website
#
open-file-explorer.ps1
This PowerShell script launches the File Explorer.
PS> ./open-file-explorer.ps1 [[-Path] <String>] [<CommonParameters>]
-Path <String>
Specifies the path to the folder to display
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-file-explorer
#
<#
.SYNOPSIS
Launches the File Explorer
.DESCRIPTION
This PowerShell script launches the File Explorer.
.EXAMPLE
PS> ./open-file-explorer
.PARAMETER Path
Specifies the path to the folder to display
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$Path = "")
try {
if ("$Path" -ne "") {
start-process explorer.exe "$Path"
} else {
start-process explorer.exe
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-firefox.ps1
This PowerShell script launches the Mozilla Firefox Web browser.
PS> ./open-firefox.ps1 [[-URL] <String>] [<CommonParameters>]
-URL <String>
Specifies an URL
Required? false
Position? 1
Default value http://www.fleschutz.de
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-firefox
#
<#
.SYNOPSIS
Launches the Firefox browser
.DESCRIPTION
This PowerShell script launches the Mozilla Firefox Web browser.
.EXAMPLE
PS> ./open-firefox
.PARAMETER URL
Specifies an URL
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$URL = "http://www.fleschutz.de")
try {
$App = Get-AppxPackage -Name Mozilla.FireFox
if ($App.Status -eq "Ok") {
# starting Firefox UWP app:
explorer.exe shell:appsFolder\$($App.PackageFamilyName)!FIREFOX
} else {
# starting Firefox program:
start-process firefox.exe "$URL"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
❌open-fritz-box.ps1
This script launches the Web browser with FRITZ!Box's Web interface.
/home/markus/Repos/PowerShell/Scripts/open-fritz-box.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-fritz-box
#
❌open-github.ps1
This script launches the Web browser with the GitHub website.
/home/markus/Repos/PowerShell/Scripts/open-github.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-github
#
open-google-contacts.ps1
This PowerShell script launches the Web browser with the Google Contacts website.
PS> ./open-google-contacts.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-contacts
#
<#
.SYNOPSIS
Opens Google Contacts
.DESCRIPTION
This PowerShell script launches the Web browser with the Google Contacts website.
.EXAMPLE
PS> ./open-google-contacts
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://contacts.google.com"
exit 0 # success
open-google-earth.ps1
This PowerShell script launches the Web browser with the Google Earth website.
PS> ./open-google-earth.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-earth
#
<#
.SYNOPSIS
Opens Google Earth
.DESCRIPTION
This PowerShell script launches the Web browser with the Google Earth website.
.EXAMPLE
PS> ./open-google-earth
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://earth.google.com/web/"
exit 0 # success
open-google-mail.ps1
This PowerShell script launches the Web browser with the Google Mail website.
PS> ./open-google-mail.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-mail
#
<#
.SYNOPSIS
Opens Google Mail
.DESCRIPTION
This PowerShell script launches the Web browser with the Google Mail website.
.EXAMPLE
PS> ./open-google-mail
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://mail.google.com"
exit 0 # success
open-google-maps.ps1
This PowerShell script launches the Web browser with the Google Maps website.
PS> ./open-google-maps.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-maps
#
<#
.SYNOPSIS
Opens Google Maps
.DESCRIPTION
This PowerShell script launches the Web browser with the Google Maps website.
.EXAMPLE
PS> ./open-google-maps
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://www.google.com/maps"
exit 0 # success
open-google-news.ps1
This PowerShell script launches the Web browser with the Google News website.
PS> ./open-google-news.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-news
#
<#
.SYNOPSIS
Opens Google News
.DESCRIPTION
This PowerShell script launches the Web browser with the Google News website.
.EXAMPLE
PS> ./open-google-news
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://news.google.com"
exit 0 # success
open-google-play.ps1
This PowerShell script launches the Web browser with the Google Play website.
PS> ./open-google-play.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-play
<#
.SYNOPSIS
Opens Google Play
.DESCRIPTION
This PowerShell script launches the Web browser with the Google Play website.
.EXAMPLE
PS> ./open-google-play
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://play.google.com/store"
exit 0 # success
open-google-search.ps1
This PowerShell script launches the Web browser with the Google Search website.
PS> ./open-google-search.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-search
#
<#
.SYNOPSIS
Opens Google Search
.DESCRIPTION
This PowerShell script launches the Web browser with the Google Search website.
.EXAMPLE
PS> ./open-google-search
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://google.com"
exit 0 # success
open-google-translate.ps1
This PowerShell script launches the Web browser with the Google Translate website.
PS> ./open-google-translate.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-google-translate
#
<#
.SYNOPSIS
Opens Google Translate
.DESCRIPTION
This PowerShell script launches the Web browser with the Google Translate website.
.EXAMPLE
PS> ./open-google-translate
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://translate.google.com"
exit 0 # success
open-home-folder.ps1
This script launches the File Explorer with the user's home folder.
PS> ./open-home-folder.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-home-folder
#
<#
.SYNOPSIS
Opens the home folder
.DESCRIPTION
This script launches the File Explorer with the user's home folder.
.EXAMPLE
PS> ./open-home-folder
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$TargetDir = resolve-path "$HOME"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Home folder at 📂$TargetDir doesn't exist (yet)"
}
& "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-music-folder.ps1
This script launches the File Explorer with the user's music folder.
PS> ./open-music-folder.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-music-folder
#
<#
.SYNOPSIS
Opens the music folder
.DESCRIPTION
This script launches the File Explorer with the user's music folder.
.EXAMPLE
PS> ./open-music-folder
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$TargetDir = resolve-path "$HOME/Music"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Music folder at 📂$TargetDir doesn't exist (yet)"
}
& "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-netflix.ps1
This script launches the Netflix application.
PS> ./open-netflix.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-netflix
#
<#
.SYNOPSIS
Launches the Netflix app
.DESCRIPTION
This script launches the Netflix application.
.EXAMPLE
PS> ./open-netflix
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
Start-Process netflix:
exit 0 # success
open-microsoft-store.ps1
This script launches the Microsoft Store application.
PS> ./open-microsoft-store.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-microsoft-store
#
<#
.SYNOPSIS
Starts the Microsoft Store app
.DESCRIPTION
This script launches the Microsoft Store application.
.EXAMPLE
PS> ./open-microsoft-store
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
Start-Process ms-windows-store:
exit 0 # success
❌open-notepad.ps1
This script launches the Notepad application.
PS>./open-notepad.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-notepad
#
❌open-onedrive-folder.ps1
This script launches Microsoft OneDrive with the user's OneDrive folder.
PS> ./open-onedrive-folder.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-onedrive
#
open-pictures-folder.ps1
This script launches the File Explorer with the user's pictures folder.
PS> ./open-pictures-folder.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-pictures-folder
#
<#
.SYNOPSIS
Opens the user's pictures folder
.DESCRIPTION
This script launches the File Explorer with the user's pictures folder.
.EXAMPLE
PS> ./open-pictures-folder
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$TargetDir = resolve-path "$HOME/Pictures"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Pictures folder at 📂$TargetDir doesn't exist (yet)"
}
& "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
❌open-recycle-bin.ps1
This script launches the File Explorer with the user's recycle bin folder.
PS> ./open-recycle-bin.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-recycle-bin
#
open-repos-folder.ps1
This script launches the File Explorer with the user's Git repositories folder.
PS> ./open-repos-folder.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-repos-folder
#
<#
.SYNOPSIS
Opens the Git repositories folder
.DESCRIPTION
This script launches the File Explorer with the user's Git repositories folder.
.EXAMPLE
PS> ./open-repos-folder
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$TargetDir = Resolve-Path "$HOME/Repos"
if (-not(Test-Path "$TargetDir" -pathType container)) {
throw "Repos folder at 📂$TargetDir doesn't exist (yet)"
}
& "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-snipping-tool.ps1
This script launches the Snipping Tool application.
PS> ./open-snipping-tool.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-snipping-tool
#
<#
.SYNOPSIS
Starts the Snipping Tool
.DESCRIPTION
This script launches the Snipping Tool application.
.EXAMPLE
PS> ./open-snipping-tool
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
Start-Process SnippingTool.exe
exit 0 # success
open-speed-test.ps1
This script launches the Web browser with Cloudflare's speed test website.
PS> ./open-speed-test.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-speed-test
#
<#
.SYNOPSIS
Opens Cloudflare's Speed Test
.DESCRIPTION
This script launches the Web browser with Cloudflare's speed test website.
.EXAMPLE
PS> ./open-speed-test
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
& "$PSScriptRoot/open-default-browser.ps1" "https://speed.cloudflare.com"
exit 0 # success
open-spotify.ps1
This script launches the Spotify application.
PS> ./open-spotify.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-spotify
#
<#
.SYNOPSIS
Launches the Spotify app
.DESCRIPTION
This script launches the Spotify application.
.EXAMPLE
PS> ./open-spotify
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
Start-Process spotify:
exit 0 # success
❌ open-system-settings.ps1
This script launches the Windows system settings application.
PS> open-system-settings.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-system-settings
#
open-task-manager.ps1
This script launches the Windows Task Manager application.
PS> ./open-task-manager.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-task-manager
#
<#
.SYNOPSIS
Starts the Task Manager
.DESCRIPTION
This script launches the Windows Task Manager application.
.EXAMPLE
PS> ./open-task-manager
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
Start-Process taskmgr.exe
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
open-videos-folder.ps1
This script launches the Windows Terminal application.
PS> ./open-windows-terminal.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-windows-terminal
#
<#
.SYNOPSIS
Launches the Windows Terminal app
.DESCRIPTION
This script launches the Windows Terminal application.
.EXAMPLE
PS> ./open-windows-terminal
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
Start-Process wt.exe
exit 0 # success
❌open-windows-terminal.ps1
open-wikipedia-website.ps1 - Opens the Wikipedia website
This script launches the Web browser with the Wikipedia website.
PS> ./open-wikipedia-website.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-wikipedia-website.ps1
#
❌open-wikipedia-website.ps1
This script launches the Web browser with the YouTube website.
PS> ./open-youtube-website.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./open-youtube-website
❌open-youtube-website.ps1
@tab Script Content
:::
remind-me.ps1
powershellcomponent VPCard { "title": "remind-me.ps1", "desc": "Creates a scheduled task that will display a popup message.", "link": "https://github.com/fleschutz/PowerShell/blob/master/remind-me.md", "logo": "https://avatars.githubusercontent.com/u/16557787?v=4", "background": "rgba(10, 10, 10, 0.2)" }
This PowerShell script creates a scheduled task that will display a popup message.
::: tabs
@tab:active Parameters
```powershell
PS> ./remind-me.ps1 [[-Message] <String>] [[-Time] <DateTime>] [<CommonParameters>]
-Message <String>
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Time <DateTime>
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
@tab Example
PS> ./remind-me "Dentist" "4/10/2021 12:00 PM"
# TaskPath TaskName State
# -------- -------- -----
# \ Reminder_451733811 Ready
@tab Script Content
<#
.SYNOPSIS
Creates a scheduled task that will display a popup message
.DESCRIPTION
This PowerShell script creates a scheduled task that will display a popup message.
.EXAMPLE
PS> ./remind-me "Dentist" "4/10/2021 12:00 PM"
TaskPath TaskName State
-------- -------- -----
\ Reminder_451733811 Ready
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
#requires -version 4
param([string]$Message = "", [datetime]$Time)
try {
if ($Message -eq "") { $Message = read-host "Enter reminder message" }
$Task = New-ScheduledTaskAction -Execute msg -Argument "* $Message"
$Trigger = New-ScheduledTaskTrigger -Once -At $Time
$Random = (Get-Random)
Register-ScheduledTask -Action $Task -Trigger $Trigger -TaskName "Reminder_$Random" -Description "Reminder"
exit 0
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
:::
save-screenshot.ps1
This PowerShell script takes a single screenshot and saves it into a target folder (default is the user's screenshots folder).
PS> ./save-screenshot.ps1 [[-TargetFolder] <String>] [<CommonParameters>]
-TargetFolder <String>
Specifies the target folder (the user's screenshots folder by default)
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./save-screenshot
# ✔️ screenshot saved to C:\Users\Markus\Pictures\Screenshots\2021-10-10T14-33-22.png
#
<#
.SYNOPSIS
Saves a single screenshot
.DESCRIPTION
This PowerShell script takes a single screenshot and saves it into a target folder (default is the user's screenshots folder).
.PARAMETER TargetFolder
Specifies the target folder (the user's screenshots folder by default)
.EXAMPLE
PS> ./save-screenshot
✔️ screenshot saved to C:\Users\Markus\Pictures\Screenshots\2021-10-10T14-33-22.png
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$TargetFolder = "")
function GetScreenshotsFolder {
if ($IsLinux) {
$Path = "$HOME/Pictures"
if (-not(Test-Path "$Path" -pathType container)) { throw "Pictures folder at $Path doesn't exist (yet)"}
if (Test-Path "$Path/Screenshots" -pathType container) { $Path = "$Path/Screenshots" }
} else {
$Path = [Environment]::GetFolderPath('MyPictures')
if (-not(Test-Path "$Path" -pathType container)) { throw "Pictures folder at $Path doesn't exist (yet)" }
if (Test-Path "$Path\Screenshots" -pathType container) { $Path = "$Path\Screenshots" }
}
return $Path
}
function TakeScreenshot { param([string]$FilePath)
Add-Type -Assembly System.Windows.Forms
$ScreenBounds = [Windows.Forms.SystemInformation]::VirtualScreen
$ScreenshotObject = New-Object Drawing.Bitmap $ScreenBounds.Width, $ScreenBounds.Height
$DrawingGraphics = [Drawing.Graphics]::FromImage($ScreenshotObject)
$DrawingGraphics.CopyFromScreen( $ScreenBounds.Location, [Drawing.Point]::Empty, $ScreenBounds.Size)
$DrawingGraphics.Dispose()
$ScreenshotObject.Save($FilePath)
$ScreenshotObject.Dispose()
}
try {
if ("$TargetFolder" -eq "") { $TargetFolder = GetScreenshotsFolder }
$Time = (Get-Date)
$Filename = "$($Time.Year)-$($Time.Month)-$($Time.Day)T$($Time.Hour)-$($Time.Minute)-$($Time.Second).png"
$FilePath = (Join-Path $TargetFolder $Filename)
TakeScreenshot $FilePath
"✔️ screenshot saved to $FilePath"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
set-wallpaper.ps1
This PowerShell script sets the given image file as desktop wallpaper (.JPG or .PNG supported)
PS> ./set-wallpaper.ps1 [[-ImageFile] <String>] [[-Style] <String>] [<CommonParameters>]
-ImageFile <String>
Specifies the path to the image file
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Style <String>
Specifies either Fill, Fit, Stretch, Tile, Center, or Span (default)
Required? false
Position? 2
Default value Span
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
PS> ./set-wallpaper C:\ocean.jpg
#
<#
.SYNOPSIS
Sets the given image file as desktop wallpaper
.DESCRIPTION
This PowerShell script sets the given image file as desktop wallpaper (.JPG or .PNG supported)
.PARAMETER ImageFile
Specifies the path to the image file
.PARAMETER Style
Specifies either Fill, Fit, Stretch, Tile, Center, or Span (default)
.EXAMPLE
PS> ./set-wallpaper C:\ocean.jpg
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$ImageFile = "", [string]$Style = "Span")
function SetWallPaper {
param([string]$Image, [ValidateSet('Fill', 'Fit', 'Stretch', 'Tile', 'Center', 'Span')][string]$Style)
$WallpaperStyle = switch($Style) {
"Fill" {"10"}
"Fit" {"6"}
"Stretch" {"2"}
"Tile" {"0"}
"Center" {"0"}
"Span" {"22"}
}
if ($Style -eq "Tile") {
New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WallpaperStyle -PropertyType String -Value $WallpaperStyle -Force
New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name TileWallpaper -PropertyType String -Value 1 -Force
} else {
New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WallpaperStyle -PropertyType String -Value $WallpaperStyle -Force
New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name TileWallpaper -PropertyType String -Value 0 -Force
}
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Params
{
[DllImport("User32.dll",CharSet=CharSet.Unicode)]
public static extern int SystemParametersInfo (Int32 uAction,
Int32 uParam,
String lpvParam,
Int32 fuWinIni);
}
"@
$SPI_SETDESKWALLPAPER = 0x0014
$UpdateIniFile = 0x01
$SendChangeEvent = 0x02
$fWinIni = $UpdateIniFile -bor $SendChangeEvent
$ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni)
}
try {
if ($ImageFile -eq "" ) { $ImageFile = read-host "Enter path to image file" }
SetWallPaper -Image $ImageFile -Style $Style
"✔️ Done."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}