mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-16 17:51:28 +01:00
Add remind-me.ps1
This commit is contained in:
parent
67a273f06e
commit
5a044708c5
@ -1,5 +1,4 @@
|
|||||||
#requires -version 4
|
<#
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
← enter overview of script here
|
← enter overview of script here
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
@ -17,6 +16,8 @@
|
|||||||
← enter URL here
|
← enter URL here
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 4
|
||||||
|
|
||||||
param() # ← enter script parameters here
|
param() # ← enter script parameters here
|
||||||
|
|
||||||
# ← enter functions here
|
# ← enter functions here
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
new-script.ps1 [<filename>]
|
new-script.ps1 [<filename>]
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Creates a new PowerShell script
|
Creates a new PowerShell script file (by using template file ../Data/template.ps1).
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./new-script myscript.ps1
|
PS> ./new-script myscript.ps1
|
||||||
|
✔️ created new PowerShell script: myscript.ps1
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz · License: CC0
|
Author: Markus Fleschutz · License: CC0
|
||||||
.LINK
|
.LINK
|
||||||
@ -16,9 +17,9 @@ param([string]$filename = "")
|
|||||||
try {
|
try {
|
||||||
if ($filename -eq "" ) { $shortcut = read-host "Enter the new filename" }
|
if ($filename -eq "" ) { $shortcut = read-host "Enter the new filename" }
|
||||||
|
|
||||||
copy-item "$PSScriptRoot/../data/template.ps1" "$filename"
|
copy-item "$PSScriptRoot/../Data/template.ps1" "$filename"
|
||||||
|
|
||||||
"✔️ created new PowerShell script $filename"
|
"✔️ created new PowerShell script: $filename"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
31
Scripts/remind-me.ps1
Executable file
31
Scripts/remind-me.ps1
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
remind-me.ps1
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a scheduled task that will display a message.
|
||||||
|
.EXAMPLE
|
||||||
|
PS> ./remind-me "Dentist" "1/1/2016 12:00 PM"
|
||||||
|
✔ OK
|
||||||
|
.NOTES
|
||||||
|
Author: Markus Fleschutz · License: CC0
|
||||||
|
.LINK
|
||||||
|
https://github.com/fleschutz/PowerShell
|
||||||
|
#>
|
||||||
|
|
||||||
|
#requires -version 4
|
||||||
|
|
||||||
|
param([string]$Message = "", [datetime]$Time)
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($Message -eq "") { $Message = read-host "Enter message to display" }
|
||||||
|
|
||||||
|
$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"
|
||||||
|
"✔️ OK"
|
||||||
|
exit 0
|
||||||
|
} catch {
|
||||||
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user