Powershell about File System

Source: Internet
Author: User

File System Rights

$sharepath | Select-expand Access | where {!    -eq ' FullControl '}
$sharepath | Select-expand Access | where {("everyone-and ("none")}     
$Result[Email protected]()foreach($ComputerName inch(get-Content E:\fileserverlist.txt)) {$Shareinfo=get-wmiobject-computername$computerName-class Win32_Share | where {$_. type-eq0 }     $Shareinfo| %{     $sharepath="\\"+$_. Pscomputername +"\"+$_. Name$acls= Get-acl$sharepath| Select-expand Access | where {!$_. isinherited-and $_. filesystemrights-eq' FullControl '}foreach($acl inch $acls){$user=$acl. IdentityReference$username=$user -replace' ^.*\ \ '$right=$acl. Filesystemrightsif($user -like' domain*') {$userinfo=get-aduser-identity$username-Properties department,enabled$DEP=$userinfo. Department$name=$userinfo. Name$userstatus=$userinfo. Enabled}Else{$DEP=' No '$name=$username}$info=new-Object PsObject$info| Add-member-membertype Noteproperty-name Name-value$user$info| Add-member-membertype Noteproperty-name Name-value$name$info| Add-member-membertype Noteproperty-name Status-value$userstatus$info| Add-member-membertype Noteproperty-name Dept-value$DEP$info| Add-member-membertype Noteproperty-name Ritht-value$right$info| Add-member-membertype Noteproperty-name Path-value$sharepath$Result+=$info}}  }    $CurrentDate= get-Date$CurrentDate=$CurrentDate. ToString (' yyyy-mm-DD ')$Result| Export-csv D:\ps\filerightinfo_$CurrentDate. csv-encoding UTF8-notypeinformation

Get Share Folder
-eq 0 }
$Result[Email protected]()#Assign the result G assignment E to an @ empty a arrayforeach($ComputerName inch(get-Content E:\IP.txt)) {    $Pingy= Get-wmiobject Win32_PingStatus- F "address= ' $ComputerName '"     #ocomputername in the "Ring ping txt file a "    if($Pingy. StatusCode-eq0)        {        $errorcount=$error. Count$Shareinfo=get-wmiobject-computername$computerName-class Win32_Share | where {$_. type-eq0 }        #if P fruit gping óo q,a get Luservice        if($Shareinfo)            {            $Shareinfo| %{                $Resultinfo=new-Object PsObject$Resultinfo| Add-member-membertype Noteproperty-name Ipaddress-value$ComputerName                $Resultinfo| Add-member-membertype Noteproperty-name Computername-value$_. Pscomputername$Resultinfo| Add-member-membertype noteproperty-name Sharename-value $ ("\\"+$_. Pscomputername +"\"+$_. Name)$Result+=$Resultinfo                }            }        Else{            if($errorcount -eq $error. Count) {$Resultinfo=new-Object PsObject$Resultinfo| Add-member-membertype Noteproperty-name Ipaddress-value$ComputerName                 $Resultinfo| Add-member-membertype Noteproperty-name Computername-value$Shareinfo. Pscomputername$Resultinfo| Add-member-membertype Noteproperty-name Sharename-value"No Share"                                $Result+=$Resultinfo                }                Else                    {                    $Resultinfo=new-Object PsObject$Resultinfo| Add-member-membertype Noteproperty-name Ipaddress-value$ComputerName                     $Resultinfo| Add-member-membertype Noteproperty-name Computername-value$Shareinfo. Pscomputername$Resultinfo| Add-member-membertype Noteproperty-name Sharename-value"RPC Error"                    $Result+=$Resultinfo                    }                }        }    Else        {        $Resultinfo=new-Object PsObject$Resultinfo| Add-member-membertype Noteproperty-name Ipaddress-value$ComputerName         $Resultinfo| Add-member-membertype Noteproperty-name Computername-value$Shareinfo. Pscomputername$Resultinfo| Add-member-membertype Noteproperty-name Sharename-value"The computer is unaviable"        $Result+=$Resultinfo        }    }$CurrentDate= get-Date$CurrentDate=$CurrentDate. ToString (' yyyy-mm-DD ')$Result| Export-csv D:\PS\Shareinfo_$CurrentDate. csv-encoding UTF8-notypeinformation

Powershell about File System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.