Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to get an ACE entry into Spreadsheet using get-ace

$
0
0

Hi folks. I'm working on a script to pull a server inventory including shares, share permissions, and other entries.

I'm able to retrieve the share and ace entries, but when I try to write them to an excel sheet, they aren't coming over with a readable value.  I can output the info to the screen.  I've tried to use a Switch command like this but it doesn't work -

 
#       Switch($UniqueShare.AccessRights)
#                {
# 1179817 {$Sheet1.Cells.Item($intRowShare, 7) = "ReadAndExecute"}
#   }

Below is a code snip showing what I'm doing.  Any help would be appreciated.

$strComputer = read-host "Enter computer name "
$strComputerDelim = "\\" + $strComputer
$sharelist = get-wmiobject win32_share -ComputerName  $strComputer

foreach ($share in $sharelist)
 {
$ShareAceName = $strComputerDelim + "\" + $share.Name
$ShareAceDetails = get-ace -path $ShareAceName

    foreach ($ShareAce in $ShareAceDetails)
        {
        foreach ($UniqueShare in $ShareAce)
            {
#Populate Shares Sheet (This is only a code snippet)
        write-host $UniqueShare.AccessRights
        $Sheet1.Cells.Item($intRowShare, 7) = $UniqueShare.AccessRights
 $Sheet1.Cells.Item($intRowShare, 8) = $ShareAceDetails.AccessControlType


        $intRowShare = $intRowShare + 1
            }
       }

$intRowShare = $intRowShare + 1

}

Results on screen are like this for the Permissions:
ReadAndExecute, Synchronize
FullControl
ReadAndExecute, Synchronize
ReadAndExecute, Synchronize
GenericExecute, GenericRead
ReadAndExecute, Synchronize

Results in the sheet are like this:
Permission
1179817

Thanks,

Don K


Don K


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>