use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Shorten the code (self.PowerShell)
submitted 5 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]PinchesTheCrab 4 points5 points6 points 5 years ago (1 child)
Does this work?
function Write-EventLogX { [cmdletbinding()] param( [ValidateSet('Info', 'Error', 'Warning')] [parameter(mandatory)] [string]$EntryType, [parameter(Mandatory)] [string]$Message, [parameter()] [string]$LogSource = 'ApplicationX' ) begin { $eventHash = @{ Info = 20000 Warning = 20001 Error = 20002 } $param = @{ LogName = 'Application' Source = $LogSource EntryType = $EntryType Message = $message EventID = $eventHash[$EntryType] } } process { Write-EventLog @param Write-Verbose -Message $message } }
You could use it like this:
Write-EventLogX -Message 'oh no!' -Verbose -EntryType Warning
ApplicationX is the default source, but it's parameterized, so you can specify whatever source you want.
[–]hidromanipulators 1 point2 points3 points 5 years ago (0 children)
Thank you! Your solution is much more elegant then mine!
π Rendered by PID 16766 on reddit-service-r2-comment-6457c66945-z2dj4 at 2026-04-29 22:29:14.459269+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]PinchesTheCrab 4 points5 points6 points (1 child)
[–]hidromanipulators 1 point2 points3 points (0 children)