Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ExecutionContext.InvokeCommand.CommandNotFoundAction = {
- param (
- [string]
- $CommandName,
- [System.Management.Automation.CommandLookupEventArgs]
- $Lookup
- )
- if ($CommandName -match '^(\d+)[WD](\d+)$')
- {
- $Lookup.StopSearch = $true
- $Lookup.Command = (Get-Command Invoke-DiceRoll)
- $Lookup.CommandScriptBlock = [scriptblock]::Create("Invoke-DiceRoll -Count $($matches[1]) -Size $($matches[2])")
- }
- }
- function Invoke-DiceRoll
- {
- [CmdletBinding()]
- param (
- [int]
- $Count = 1,
- [int]
- $Size = 20
- )
- $results = foreach ($number in (1 .. $Count))
- {
- 1..$Size | Get-Random
- }
- ($results | Measure-Object -Sum).Sum
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement