めちゃくちゃ気持ち悪いんですけど。
function WriteEventEntry(
[System.String] $strMessage
, [System.Diagnostics.EventLogEntryType] $logType = 'Error')
{
Set-Variable -Name 'strSource' -Value 'Test' -Option 'Constant';
Set-Variable -Name 'strLogName' -Value 'Application' -Option 'Constant';
$eventlog = New-Object `
-TypeName 'System.Diagnostics.EventLog' `
-ArgumentList $strLogName;
$eventlog.Source = $strSource;
$eventlog.WriteEntry($strMessage, $logType);
}
こんな関数書いたんですが、なんで下記のようによびださなければならないの?
WriteEventEntry 'Message' 'Information'
こうゆう呼び出しできるようにしてほしいんですけど
WriteEventEntry 'Message' [System.Diagnostics.EventLogEntryType]::Information
なんで、文字列で指定するの?