Chapter5: Common Operation
This section contain the following items:
1.Get disks information
2.Remove item
3.Sleep
4.Timer
5.Launch .exe form .ps1
6.Check if 64bit operation system
7.Get current dictionary
8.Use DISM to add/remove Windows components
9.Write log to text file
10.Check file exist or not
11.Check Network IP
12.Check Network connection type
1ˇ.Check Windows User/Password is valid
1.Get disks information
Unknown (0)
No Root Directory (1)
Removable Disk (2)
Local Disk (3)
Network Drive (4)
Compact Disc (5)
RAM Disk (6)
1.wmic logicaldisk
2.example:
2.Remove item
1.remove a file
2.remove files under a specific folder:
3.Sleep
start to sleep for 60 seconds:
4.Timer
5.Launch .exe form .ps1
Launch .exe with parameters
start-process: 開啟一個thread並執行指定的程式
-filepath : 指定的程式路徑
-ArgumentList : 給程式的參數
Launch multiple executable files at once
有兩種方式:
1.start process:
先用start-process launch後再用Wait-Process
2.System.Diagnostics.Process
有時候使用第一種方式會wait失敗, 這邊可以使用第二種方式, 類似c#
execute exe without windows and wait
6.Check if 64bit operation system
1.Using the Get-WMiObject Cmdlet
2.Using powershell command
7.Get current dictionary
8.Use DISM to add/remove Windows components
9.Write log to text file
10.Check file exist or not
11.Check Network IP
12.Check Network connection type
13.Check Windows User/Password is valid
1.Use Get-Credential
2.Do not use Get-Credential
Last updated
Was this helpful?