diff --git a/help.md b/help.md
new file mode 100644
index 0000000..6aefd12
--- /dev/null
+++ b/help.md
@@ -0,0 +1 @@
+https://learn.microsoft.com/zh-cn/virtualization/hyper-v-on-windows/quick-start/try-hyper-v-powershell
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5050a74..dd58504 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,6 @@
https://git.dr1997.com/hyper-v/hyper-v-java
-
17
UTF-8
@@ -21,15 +20,25 @@
+
+
+
+
+
- com.profesorfalken
- jPowerShell
- 3.1.1
+ com.github.tuupertunut
+ powershell-lib-java
+ 2.0.0
- junit
- junit
- 4.13.2
+ cn.hutool
+ hutool-all
+ 5.8.11
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.9.2
test
diff --git a/src/main/java/cn/x47/service/VmService.java b/src/main/java/cn/x47/service/VmService.java
new file mode 100644
index 0000000..5f6fd0e
--- /dev/null
+++ b/src/main/java/cn/x47/service/VmService.java
@@ -0,0 +1,12 @@
+package cn.x47.service;
+
+
+/**
+ * hyper-v 虚拟操作相关接口
+ */
+public interface VmService {
+
+
+
+
+}
diff --git a/src/main/java/cn/x47/service/impl/VmServiceImpl.java b/src/main/java/cn/x47/service/impl/VmServiceImpl.java
new file mode 100644
index 0000000..d06b94a
--- /dev/null
+++ b/src/main/java/cn/x47/service/impl/VmServiceImpl.java
@@ -0,0 +1,59 @@
+package cn.x47.service.impl;
+
+import cn.hutool.core.util.ReUtil;
+import cn.x47.service.VmService;
+import com.github.tuupertunut.powershelllibjava.PowerShell;
+import com.github.tuupertunut.powershelllibjava.PowerShellExecutionException;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Pattern;
+
+
+public class VmServiceImpl implements VmService {
+
+ public void test() {
+
+
+ try (PowerShell psSession = PowerShell.open()) {
+ String s = psSession.executeCommands("Get-VM");
+
+// String s = psSession.executeCommands("Get-VMSwitch");
+ String[] split = s.split("\\r\\n");
+ List allGroups = ReUtil.getAllGroups(Pattern.compile("(\\S+\\s+)"), split[1], false, true);
+ List integers = allGroups.stream().map(String::length).toList();
+
+
+ List> lists = Arrays.stream(split).skip(3).map(e -> {
+ List a = new ArrayList<>();
+
+ int index = 0;
+ for (int i = 0; i < integers.size(); i++) {
+ if (i == 0) {
+ a.add(e.substring(index, integers.get(i)));
+
+ } else {
+ a.add(e.substring(index, index + integers.get(i)));
+ }
+
+ index += integers.get(i);
+ }
+ return a;
+ }).toList();
+
+
+ lists.forEach(System.out::println);
+
+
+ } catch (IOException |
+ PowerShellExecutionException ex) {
+ ex.printStackTrace();
+ }
+
+
+ }
+
+
+}
diff --git a/src/test/java/cn/x47/AppTest.java b/src/test/java/cn/x47/AppTest.java
deleted file mode 100644
index ed16303..0000000
--- a/src/test/java/cn/x47/AppTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package cn.x47;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
diff --git a/src/test/java/cn/x47/service/impl/VmServiceImplTest.java b/src/test/java/cn/x47/service/impl/VmServiceImplTest.java
new file mode 100644
index 0000000..9cda38e
--- /dev/null
+++ b/src/test/java/cn/x47/service/impl/VmServiceImplTest.java
@@ -0,0 +1,31 @@
+package cn.x47.service.impl;
+
+import cn.x47.service.VmService;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class VmServiceImplTest {
+
+ static VmServiceImpl vmService;
+
+ @BeforeAll
+ static void setUp() {
+ vmService = new VmServiceImpl();
+
+ }
+
+ @AfterEach
+ void tearDown() {
+ System.out.println("执行结束");
+ }
+
+ @Test
+ void test1() {
+ vmService.test();
+
+ }
+}
\ No newline at end of file