如何使用 PowerShell 獲取共享資料夾列表?
Get-SmbShare 提供了本地系統上的所有共享資料夾。
PS C:\Temp> Get-SmbShare Name ScopeName Path Description ---- --------- ---- ----------- ADMIN$ * C:\Windows Remote Admin C$ * C:\ Default share DSC * E:\DSC E$ * E:\ Default share IPC$ * Remote IPC Shared1 * E:\Extract
示例
若要獲取遠端計算機上的共享資料夾,我們可以使用 CIM 會話。例如:
$sess = New-CimSession -ComputerName Labmachine2k16 Get-SmbShare -Session $sess
輸出
PS C:\Users\Administrator> Get-SmbShare -Session $sess Name ScopeName Path Description PSComputerName ---- --------- ---- ----------- -------------- ADMIN$ * C:\Windows Remote Admin Labmachine2k16 C$ * C:\ Default share Labmachine2k16 DSC * E:\DSC Labmachine2k16 E$ * E:\ Default share Labmachine2k16 IPC$ * Remote IPC Labmachine2k16 Shared1 * E:\Extract Labmachine2k16
廣告