By assigning the enum type [ServerTypes] to your result variable, all translating is performed automatically, and cryptic code numbers now show as friendly text. 通过将枚举类型 [ServerTypes] 绑定到您的结果变量,所有转换都会自动进行,而且现在幻数可以转换为友好的文本。
switch($event.SourceEventArgs.Reason) { 'SessionLock' { $synthesizer.Speak("Bye bye $env:username!") } 'SessionUnlock' { $synthesizer.Speak("Nice to see you again $env:username!") } } } }
$ExecutionContext.InvokeCommand.CommandNotFoundAction = { # second argument is the command that was missing: $p = $args[1] # do not try and find it elsewhere $p.StopSearch = $true
$command = $p.CommandName
# output audio message (make sure your audio is turned up) $sapi = New-Object-ComObject Sapi.SpVoice $sapi.Speak("Command $command not found.") }
CommandType Name Version Source ---------------------------- FunctionDebug-FileShare2.0.0.0Storage FunctionGet-FileShare2.0.0.0Storage FunctionNew-FileShare2.0.0.0Storage FunctionRemove-FileShare2.0.0.0Storage FunctionSet-FileShare2.0.0.0Storage