# encoding: ascii
# api: powershell
# title: Step 1
# description: Lab 7
# version: 0.1
# type: function
# author: Don Jones
# license: CC0
# function: Get-ShareInfo
# x-poshcode-id: 5067
# x-archived: 2014-04-13T11:56:20
# x-published: 2014-04-09T18:13:00
#
#
 function Get-ShareInfo {
    param(
        [string[]]$ComputerName,

        [string]$ErrorLogFile
    )

    foreach ($computer in $ComputerName) {

        $shares = Get-CimInstance -ClassName Win32_Share -ComputerName $Computer -filter "Path<>''"

        foreach ($share in $shares) {

            $sharename = $share.path -replace "\\","\\"
            $directory = Get-CimInstance -ClassName Win32_Directory -Filter "Name='$($sharename)'"

            $properties = @{'ComputerName'=$Computer;
                            'Name'=$share.name;
                            'Path'=$share.path;
                            'Caption'=$share.caption;
                            'Readable'=$directory.readable;
                            'Writable'=$directory.writable}
            $output = New-Object -TypeName PSObject -Property $properties
            Write-Output $output

        } #foreach share

    } #foreach computer
} #function Get-ShareInfo


Get-ShareInfo -ComputerName dc,win81 -ErrorLogFile c:\errors.txt
