Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of scheduled tasks triggered by HyperV events to execute functions #11

Open
taliesins opened this issue Nov 2, 2021 · 0 comments

Comments

@taliesins
Copy link

taliesins commented Nov 2, 2021

Its possible to create a scheduled task that gets triggered on hyperv events. This is probably the smoothest way to hook in and run powershell snippets when required. see: https://superuser.com/questions/262799/how-to-launch-a-command-on-network-connection-disconnection

When network card is attached to switch:

Scheduled Task Trigger:

Log: System
Source: Hyper-V-VmSwitch
Event Id: 232

Payload:

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Microsoft-Windows-Hyper-V-VmSwitch" Guid="{67dc0d66-3695-47c0-9642-33f76f7bd7ad}" /> 
  <EventID>232</EventID> 
  <Version>0</Version> 
  <Level>4</Level> 
  <Task>0</Task> 
  <Opcode>0</Opcode> 
  <Keywords>0x8000000000000080</Keywords> 
  <TimeCreated SystemTime="2021-11-01T23:48:01.6238111Z" /> 
  <EventRecordID>25479</EventRecordID> 
  <Correlation /> 
  <Execution ProcessID="8196" ThreadID="316" /> 
  <Channel>System</Channel> 
  <Computer>tali</Computer> 
  <Security UserID="S-1-5-83-1" /> 
  </System>
- <EventData>
  <Data Name="NicNameLen">74</Data> 
  <Data Name="NicName">6859057B-7070-4426-8777-0C55181D8D90--FC785225-9131-5661-AC0C-3A157C61AE15</Data> 
  <Data Name="NicFNameLen">0</Data> 
  <Data Name="NicFName" /> 
  <Data Name="PortNameLen">36</Data> 
  <Data Name="PortName">C2CE06CC-0A77-4A84-B77A-BECD5B97AB9F</Data> 
  <Data Name="PortFNameLen">36</Data> 
  <Data Name="PortFName">00D5F962-EA19-482C-8D33-902351A56571</Data> 
  <Data Name="SwitchNameLen">36</Data> 
  <Data Name="SwitchName">B6591560-4373-4889-962B-27A4F2442DE5</Data> 
  <Data Name="SwitchFNameLen">3</Data> 
  <Data Name="SwitchFName">WSL</Data> 
  </EventData>
  </Event>
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

No branches or pull requests

1 participant