Powershell Script to get the NTFS permissions of a folder


' Provide the folder path as highlighted below
' Output will be an permissions.csv file


# Include only folders from the root path
Get-ChildItem "D:\Test" -Recurse | ?{ $_.PsIsContainer } | %{
  $Path = $_.FullName

  (Get-Acl $Path).Access | Select-Object `
    @{n='Path1';e={ $Path }}, IdentityReference, `
    FileSystemRights, IsInherited
} | Export-CSV "Permissions.csv"



***Share your comments about this post***

Powershell Script to create multiple groups in Active directory Domain

' Provide group names, group type and OU path in .csv file in below format.
' Save the file as bulk_input.csv under C:\temp folder




Import-Module ActiveDirectory
#Import CSV
$csv = @()
$csv = Import-Csv -Path "C:\temp\bulk_input.csv"

#Get Domain Base
$searchbase = Get-ADDomain | ForEach {  $_.DistinguishedName }

#Loop through all items in the CSV
ForEach ($item In $csv)
{
  #Check if the OU exists
  $check = [ADSI]::Exists("LDAP://$($item.GroupLocation),$($searchbase)")
  If ($check -eq $True)
  {
    Try
    {
      #Check if the Group already exists
      $exists = Get-ADGroup $item.GroupName
      Write-Host "Group $($item.GroupName) alread exists! Group creation skipped!"
    }
    Catch
    {
      #Create the group if it doesn't exist
      $create = New-ADGroup -Name $item.GroupName -GroupScope $item.GroupType -Path ($($item.GroupLocation)+","+$($searchbase))
      Write-Host "Group $($item.GroupName) created!"
    }
  }
  Else
  {
      Write-Host "Target OU can't be found! Group creation skipped!"
  }
}




***Share your comments about this post***