Skip to content

Fix for calling async functions#1

Open
rot169 wants to merge 2 commits into
securesean:masterfrom
rot169:master
Open

Fix for calling async functions#1
rot169 wants to merge 2 commits into
securesean:masterfrom
rot169:master

Conversation

@rot169

@rot169 rot169 commented Mar 21, 2021

Copy link
Copy Markdown

Whilst the original code runs fine within the PowerShell ISE, when run ouside the ISE async jobs were failing due to the 'alertHandler' functions "not recognized as the name of a cmdlet, function, script file, or operable program" - possibly as they were defined outside the code snippet being passed to Register-WmiEvent (??). Running inside the ISE masks this issue as it performs additional function caching. This change converts the functions to variables, resolving the issue.

rot169 added 2 commits March 21, 2021 10:03
Async jobs were failing due to the 'alertHandler' functions "not recognized as the name of a cmdlet, function, script file, or operable program" - possibly as they were defined outside the code snippet being passed to Register-WmiEvent (??). This change converts the functions to variables, resolving the issue.
Chuck the output of Register-WmiEvent into a throw-away variable to avoid it being printed to screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant