Updated list-network-shares.ps1

This commit is contained in:
Markus Fleschutz 2024-10-10 13:29:49 +02:00
parent c8a11f61bc
commit bd3b301072
2 changed files with 12 additions and 7 deletions

View File

@ -18,6 +18,7 @@
Write-Host "`n N E T W O R K" -foregroundColor green
& "$PSScriptRoot/check-firewall"
& "$PSScriptRoot/list-local-ip.ps1"
& "$PSScriptRoot/list-network-shares.ps1"
& "$PSScriptRoot/ping-local-devices.ps1"
& "$PSScriptRoot/check-vpn.ps1"
& "$PSScriptRoot/list-internet-ip.ps1"

View File

@ -1,14 +1,11 @@
<#
.SYNOPSIS
Lists the local network shares
Lists the network shares
.DESCRIPTION
This PowerShell script lists all network shares of the local computer.
This PowerShell script lists all network shares (aka "shared folders") of the local computer.
.EXAMPLE
PS> ./list-network-shares.ps1
Name Path Description
---- ---- -----------
Public C:\Public Public folder for file transfer
Network share \\LAPTOP\Public mapped to: 📂D:\Public ("Public folder for file transfer")
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -16,7 +13,14 @@
#>
try {
Get-WmiObject win32_share | where {$_.name -NotLike "*$"}
if ($IsLinux) {
# TODO
} else {
$shares = Get-WmiObject win32_share | where {$_.name -NotLike "*$"}
foreach ($share in $shares) {
Write-Output "✅ Network share \\$(hostname)\$($share.Name) mapped to: 📂$($share.Path) (`"$($share.Description)`")"
}
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"