Thursday, May 22, 2025

Script Sharepoint

 $shares = Get-WmiObject -Class win32_share -ComputerName (hostname)| ? {$_.name -notlike "*$*"}


$shares | % {

$sharePath = ($_.__PATH).replace("root\cimv2:Win32_Share.Name=","")

$sharePath = $sharePath.replace("""","")

$_ | Add-Member -Name SharePath -Value $sharePath -MemberType NoteProperty -Force

$_ | Add-Member -Name Servidor -Value $_.__Server -MemberType NoteProperty -Force

$_ | Select Name,Path,SharePath,Servidor | Export-Csv C:\temp\SharesNow.csv -Append -Notype

}