├── .gitignore ├── ACLReportTools.Package.ps1 ├── ACLReportTools.format.ps1xml ├── ACLReportTools.psd1 ├── ACLReportTools.psm1 ├── ACLReportTools.pssproj ├── ACLReportTools.sln ├── ACLReportTools.v12.suo ├── LICENSE ├── README.md ├── Tests └── Integration │ └── ACLReportTools.Tests.ps1 └── appveyor.yml /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | package 4 | artifacts 5 | -------------------------------------------------------------------------------- /ACLReportTools.Package.ps1: -------------------------------------------------------------------------------- 1 | $Files = @( 2 | @{ Filename = 'ACLReportTools.psm1'; }; 3 | @{ Filename = 'ACLReportTools.psd1' }; 4 | @{ Filename = 'ACLReportTools.format.ps1xml' }; 5 | @{ Filename = 'README.md' }; 6 | ) 7 | 8 | ########################################################################################################################################## 9 | # Support Functions 10 | ########################################################################################################################################## 11 | Function InitZip 12 | { 13 | # If PS is version 4 or less then we require the PSCX Module to unzip/zip files 14 | If ($PSVersionTable.PSVersion.Major -lt 5) { 15 | # Is the PSCX Module Available? 16 | If ( (Get-Module -ListAvailable PSCX | Measure-Object).Count -eq 0) { 17 | Throw "PSCX Module is not available. Please download it from http://pscx.codeplex.com/" 18 | } # If 19 | Import-Module PSCX 20 | } # If 21 | } # Function InitZip 22 | ########################################################################################################################################## 23 | 24 | ########################################################################################################################################## 25 | Function UnzipFile ([String]$ZipFileName,[String]$DestinationPath) 26 | { 27 | If ($PSVersionTable.PSVersion.Major -lt 5) { 28 | Expand-Archive -Path $ZipFileName -OutputPath $DestinationPath 29 | } Else { 30 | Expand-Archive -Path $ZipFileName -DestinationPath $DestinationPath -Force 31 | } # If 32 | } # Function UnzipFile 33 | ########################################################################################################################################## 34 | 35 | ########################################################################################################################################## 36 | Function ZipFolder ([String]$ZipFileName,[String]$SourcePath) 37 | { 38 | If ($PSVersionTable.PSVersion.Major -lt 5) { 39 | Get-ChildItem -Path $SourcePath -Recurse | Write-Zip -IncludeEmptyDirectories -OutputPath $ZipFileName -EntryPathRoot $SourcePath -Level 9 40 | } Else { 41 | Compress-Archive -DestinationPath $ZipFileName -Path "$SourcePath\*" -CompressionLevel Optimal 42 | } # If 43 | } # Function ZipFolder 44 | ########################################################################################################################################## 45 | 46 | ########################################################################################################################################## 47 | Function Package-Module 48 | { 49 | <# 50 | .SYNOPSIS 51 | Packages the files required for distributing a module. 52 | 53 | .DESCRIPTION 54 | All this function does is zip up the files required to be distributed with the a module. 55 | 56 | If PS 4 is used then this function requires the PSCX module to be available and installed on this computer. 57 | 58 | .LINK 59 | http://pscx.codeplex.com/ 60 | #> 61 | Param ( 62 | [String]$Name 63 | ) # Params 64 | 65 | Begin { 66 | # Initialize the zip functions 67 | InitZip 68 | 69 | [String]$TempPath = "$Env:TEMP\Package\" 70 | New-Item -Path $TempPath -ItemType 'Directory' -Force | Out-Null 71 | New-Item -Path "$TempPath\$Name" -ItemType 'Directory' -Force | Out-Null 72 | } # Begin 73 | 74 | Process { 75 | Foreach ($File In $Files) { 76 | If ($File.Filename.Substring($File.Filename.Length-1,1) -eq '\') { 77 | New-Item -Path "$TempPath\$Name\$($File.Filename)" -ItemType Directory -Force | Out-Null 78 | } Else { 79 | Copy-Item -Path "$PSScriptRoot\$($File.Filename)" -Destination "$TempPath\$Name\$($File.Filename)" -Force 80 | } # If 81 | } # Foreach 82 | New-Item -Path "$PSScriptRoot\Package" -ItemType Directory -Force 83 | If (Test-Path -Path "$PSScriptRoot\Package\$Name.zip" ) { Remove-Item -Path "$PSScriptRoot\Package\$Name.zip" -Force | Out-Null } 84 | ZipFolder -ZipFileName "$PSScriptRoot\Package\$Name.zip" -SourcePath $TempPath 85 | } # Process 86 | 87 | End { 88 | Remove-Item -Path $TempPath -Recurse -Force 89 | } # End 90 | } # Function Package-Module 91 | ########################################################################################################################################## 92 | 93 | Package-Module -Name 'ACLReportTools' -------------------------------------------------------------------------------- /ACLReportTools.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Permission 6 | 7 | ACLReportTools.Permission 8 | 9 | 10 | 11 | 12 | 13 | 14 | 32 15 | 16 | 17 | 18 | 10 19 | 20 | 21 | 22 | 32 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | ComputerName 34 | 35 | 36 | Type 37 | 38 | 39 | Share 40 | 41 | 42 | Path 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Permission Difference 53 | 54 | ACLReportTools.PermissionDiff 55 | 56 | 57 | 58 | 59 | 60 | 61 | 32 62 | 63 | 64 | 65 | 15 66 | 67 | 68 | 69 | 32 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | ComputerName 87 | 88 | 89 | Type 90 | 91 | 92 | Share 93 | 94 | 95 | Path 96 | 97 | 98 | DiffType 99 | 100 | 101 | Difference 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /ACLReportTools.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlagueHO/ACLReportTools/285c0af85cefccc059b4294c77bedc53ea60a201/ACLReportTools.psd1 -------------------------------------------------------------------------------- /ACLReportTools.psm1: -------------------------------------------------------------------------------- 1 | #Requires -Version 2.0 2 | 3 | ############################################################################################ 4 | # Data Sections 5 | ############################################################################################ 6 | $Script:Html_Header = Data { 7 | @' 8 | {0} 9 | 24 | 25 | 26 |

{0}

27 | '@ 28 | } 29 | 30 | $Script:Html_Footer = Data { 31 | @' 32 | 33 | '@ 34 | } 35 | 36 | $Script:Html_ComputerName = Data { 37 | @' 38 |

Differences on Computer {0}

39 | '@ 40 | } 41 | 42 | $Script:Html_ShareName = Data { 43 | @' 44 |

Differences in Share {0}

45 | '@ 46 | } 47 | 48 | $Script:Html_DifferenceLine = Data { 49 | @' 50 | {0}: {2}
51 | '@ 52 | } 53 | 54 | ############################################################################################ 55 | # Main CmdLets 56 | ############################################################################################ 57 | 58 | 59 | <# 60 | .SYNOPSIS 61 | Creates a list of Share, File and Folder ACLs for the specified shares/computers. 62 | 63 | .DESCRIPTION 64 | Produces an array of [ACLReportTools.Permission] objects for the computers provided. 65 | Specific shares can be specified or excluded using the Include/Exclude parameters. 66 | 67 | The report can be stored for use as a comparison in either a variable or as a file 68 | using the Export-ACLReport cmdlet (found in this module). For example: 69 | 70 | New-ACLShareReport -ComputerName CLIENT01 -Include MyShare,OtherShare | 71 | Export-ACLReport -path c:\ACLReports\CLIENT01_2014_11_14.acl 72 | 73 | .PARAMETER ComputerName 74 | This is the computer(s) to create the ACL Share report for. The Computer names can 75 | also be passed in via the pipeline. 76 | 77 | .PARAMETER Include 78 | This is a list of shares to include from the report. If this parameter is not set it 79 | will default to including all shares. This parameter can't be set if the Exclude 80 | parameter is set. 81 | 82 | .PARAMETER Exclude 83 | This is a list of shares to exclude from the report. If this parameter is not set it 84 | will default to excluding no shares. This parameter can't be set if the Include 85 | parameter is set. 86 | 87 | .PARAMETER IncludeInherited 88 | Setting this switch will cause the non inherited file/folder ACLs to be pulled 89 | recursively. 90 | 91 | .EXAMPLE 92 | New-ACLShareReport -ComputerName CLIENT01 93 | Creates a report of all the Share and file/folder ACLs on the CLIENT01 machine. 94 | 95 | .EXAMPLE 96 | New-ACLShareReport -ComputerName CLIENT01 -Include MyShare,OtherShare 97 | Creates a report of all the Share and file/folder ACLs on the CLIENT01 machine that are 98 | in shares named either MyShare or OtherShare. 99 | 100 | .EXAMPLE 101 | New-ACLShareReport -ComputerName CLIENT01 -Exclude SysVol 102 | Creates a report of all the Share and file/folder ACLs on the CLIENT01 machine that are 103 | in shares not named SysVol. 104 | #> 105 | Function New-ACLShareReport 106 | { 107 | [CmdLetBinding()] 108 | param ( 109 | [Parameter( 110 | ValueFromPipeline=$true, 111 | ValueFromPipelineByPropertyName=$true)] 112 | [String[]]$ComputerName=$env:computername, 113 | 114 | [String[]]$Include, 115 | 116 | [String[]]$Exclude, 117 | 118 | [Switch]$IncludeInherited 119 | ) # param 120 | begin 121 | { 122 | [ACLReportTools.Permission[]]$acls = $null 123 | $null = $PSBoundParameters.Remove('includeinherited') 124 | } # Begin 125 | process 126 | { 127 | $Shares = Get-ACLShare @PSBoundParameters 128 | $acls += $Shares | Get-ACLShareACL 129 | if ($IncludeInherited) 130 | { 131 | $acls += $Shares | Get-ACLShareFileACL -Recurse 132 | } 133 | else 134 | { 135 | $acls += $Shares | Get-ACLShareFileACL -Recurse -IncludeInherited 136 | } 137 | } # Process 138 | end 139 | { 140 | return $acls 141 | } # End 142 | } # Function New-ACLShareReport 143 | 144 | 145 | <# 146 | .SYNOPSIS 147 | Creates a list of File and Folder ACLs for the provided path(s). 148 | 149 | .DESCRIPTION 150 | Produces an array of [ACLReportTools.Permission] objects for the list of paths provided. 151 | 152 | The report can be stored for use as a comparison in either a variable or as a file 153 | using the Export-ACLReport cmdlet (found in this module). For example: 154 | 155 | New-ACLPathFileReport -Path e:\public | 156 | Export-ACLReport -path c:\ACLReports\Public_2015-04-04.acl 157 | 158 | .PARAMETER Path 159 | This is the path(s) to create the ACL PathFile report for. 160 | 161 | .PARAMETER IncludeInherited 162 | Setting this switch will cause the non inherited file/folder ACLs to be pulled 163 | recursively. 164 | 165 | .EXAMPLE 166 | New-ACLPathFileReport -Path e:\public 167 | Creates a report of all the file/folder ACLs in the e:\public folder on this machine. 168 | #> 169 | Function New-ACLPathFileReport 170 | { 171 | [CmdLetBinding()] 172 | param 173 | ( 174 | [Parameter( 175 | ValueFromPipeline=$true, 176 | ValueFromPipelineByPropertyName=$true)] 177 | [String[]]$Path=(Convert-path -Path .), 178 | 179 | [Switch]$IncludeInherited 180 | ) # param 181 | begin 182 | { 183 | [ACLReportTools.Permission[]]$acls = $null 184 | $null = $PSBoundParameters.Remove('path') 185 | } # Begin 186 | process 187 | { 188 | Foreach ($p in $Path) { 189 | $acls += Get-ACLPathFileACL -Path $p -Recurse @PSBoundParameters 190 | } 191 | } # Process 192 | end 193 | { 194 | return $acls 195 | } # End 196 | } # Function New-ACLPathFileReport 197 | 198 | 199 | <# 200 | .SYNOPSIS 201 | Export an ACL Report as a file. 202 | 203 | .DESCRIPTION 204 | This Cmdlet will save whatever ACL Report that is in the pipeline to a file. 205 | 206 | This cmdlet just calls Export-ACLPermission although at some point will add additional 207 | functionality. 208 | 209 | .PARAMETER Path 210 | This is the path to the ACL Permission Report output file. This parameter is required. 211 | 212 | .PARAMETER InputObject 213 | Specifies the Permissions objects to export to the file. Enter a variable that contains 214 | the objects or type a command or expression that gets the objects. You can also pipe 215 | ACLReportTools.Permission objects to this cmdlet. 216 | 217 | .PARAMETER Force 218 | Causes the file to be overwritten if it exists. 219 | 220 | .EXAMPLE 221 | New-ACLShareReport -ComputerName CLIENT01 -Include MyShare,OtherShare | 222 | Export-ACLReport -path c:\ACLReports\CLIENT01_2014_11_14.acl 223 | Creates a new ACL Share Report for Computer Client01 for the MyShare and OtherShares 224 | and exports it to the file C:\ACLReports\CLIENT01_2014_11_14.acl. 225 | 226 | .EXAMPLE 227 | Export-ACLReport -Path C:\ACLReports\server01.acl -InputObject $ShareReport 228 | Saves the ACLs in the $ShareReport variable to the file C:\ACLReports\server01.acl. 229 | 230 | .EXAMPLE 231 | Export-ACLReport ` 232 | -Path C:\ACLReports\server01.acl ` 233 | -InputObject (New-ACLShareReport -ComputerName SERVER01) -Force 234 | Saves the file ACLs for all shares on the compuer SERVER01 to the file 235 | C:\ACLReports\server01.acl. If the file exists it will be overwritten. 236 | 237 | .EXAMPLE 238 | New-ACLShareReport -ComputerName SERVER01 | 239 | Export-ACLReport -Path C:\ACLReports\server01.acl -Force 240 | Saves the file ACLs for all shares on the compuer SERVER01 to the file 241 | C:\ACLReports\server01.acl. If the file exists it will be overwritten. 242 | #> 243 | function Export-ACLReport { 244 | [CmdLetBinding()] 245 | param 246 | ( 247 | [Parameter(Mandatory=$true)] 248 | [ValidateNotNullOrEmpty()] 249 | [String]$Path, 250 | 251 | [Parameter(Mandatory=$true, 252 | ValueFromPipeline=$true, 253 | ValueFromPipelineByPropertyName=$true)] 254 | [ValidateScript({$_.GetType().FullName -ne 'ACLReportTools.Permission[]'})] 255 | [ACLReportTools.Permission[]]$InputObject, 256 | 257 | [Switch]$Force 258 | 259 | ) # param 260 | begin 261 | { 262 | [ACLReportTools.Permission[]]$InputObjectNew = $Null 263 | } 264 | process 265 | { 266 | foreach ($I in $InputObject) 267 | { 268 | $InputObjectNew += $I 269 | } 270 | } 271 | end 272 | { 273 | [Void]$PSBoundParameters.Remove('InputObject') 274 | $InputObjectNew | Export-ACLPermission @PSBoundParameters 275 | } 276 | } # Function Export-ACLReport 277 | 278 | 279 | <# 280 | .SYNOPSIS 281 | Export an ACL Permission Diff Report as a file. 282 | 283 | .DESCRIPTION 284 | This Cmdlet will save whatever ACL Permission Diff Report that is in the pipeline 285 | to a file. 286 | 287 | This cmdlet just calls Export-ACLPermissionDiff although at some point will add 288 | additional functionality. 289 | 290 | .PARAMETER Path 291 | This is the path to the ACL Permission Diff Report output file. This parameter is 292 | required. 293 | 294 | .PARAMETER InputObject 295 | Specifies the Permissions objects to export to the file. Enter a variable that contains the 296 | objects or type a command or expression that gets the objects. You can also pipe 297 | ACLReportTools.PermissionDiff objects to Export-ACLReport. 298 | 299 | .PARAMETER Force 300 | Causes the file to be overwritten if it exists. 301 | 302 | .EXAMPLE 303 | Compare-ACLReports -Baseline (Import-ACLReports ` 304 | -Path c:\ACLReports\CLIENT01_2014_11_14.acl) ` 305 | -With (Get-ACLReport -ComputerName CLIENT01) | 306 | Export-ACLDiffReport -Path "$HOME\Documents\Compare.acr" 307 | This will perform a comparison of the current share ACL report from computer CLIENT01 with 308 | the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl and then export 309 | the report file 310 | to $HOME\Documents\Compare.acr 311 | #> 312 | function Export-ACLDiffReport 313 | { 314 | [CmdLetBinding()] 315 | param 316 | ( 317 | [Parameter(Mandatory=$true)] 318 | [ValidateNotNullOrEmpty()] 319 | [String]$Path, 320 | 321 | [Parameter(Mandatory=$true, 322 | ValueFromPipeline=$true, 323 | ValueFromPipelineByPropertyName=$true)] 324 | [ValidateScript({$_.GetType().FullName -ne 'ACLReportTools.PermissionDiff[]'})] 325 | [ACLReportTools.PermissionDiff[]]$InputObject, 326 | 327 | [Switch]$Force 328 | 329 | ) # param 330 | begin 331 | { 332 | [ACLReportTools.PermissionDiff[]]$InputObjectNew = $Null 333 | } 334 | process 335 | { 336 | foreach ($I in $InputObject) 337 | { 338 | $InputObjectNew += $I 339 | } 340 | } 341 | end 342 | { 343 | [Void]$PSBoundParameters.Remove('InputObject') 344 | $InputObjectNew | Export-ACLPermissionDiff @PSBoundParameters 345 | } 346 | } # Function Export-ACLDiffReport 347 | 348 | 349 | <# 350 | .SYNOPSIS 351 | Import the ACL Report that is in a file. 352 | 353 | .DESCRIPTION 354 | This Cmdlet will import all the ACL Report (ACLReportTools.Permission) objects from a 355 | specified file into the pipeline. 356 | 357 | This cmdlet just calls Import-ACLPermission although at some point will add additional 358 | functionality. 359 | 360 | .PARAMETER Path 361 | This is the path to the ACL Permission Report file to import. This parameter is 362 | required. 363 | 364 | .EXAMPLE 365 | Import-ACLReport -Path C:\ACLReports\server01.acl 366 | Imports the ACL Share Report from the file C:\ACLReports\server01.acl and puts it 367 | into the pipeline 368 | #> 369 | function Import-ACLReport 370 | { 371 | [CmdLetBinding()] 372 | # [OutputType([ACLReportTools.Permission])] 373 | param 374 | ( 375 | [Parameter(Mandatory=$true)] 376 | [ValidateNotNullOrEmpty()] 377 | [String]$Path 378 | ) # param 379 | 380 | Import-ACLPermission @PSBoundParameters 381 | 382 | } # Function Import-ACLReport 383 | 384 | 385 | <# 386 | .SYNOPSIS 387 | Import the ACL Difference Report that is in a file. 388 | 389 | .DESCRIPTION 390 | This Cmdlet will import all the ACL Difference Report (ACLReportTools.PermissionDiff) 391 | objects from a specified file into the pipeline. 392 | 393 | This cmdlet just calls Import-ACLPermissionDiff although at some point will add 394 | additional functionality. 395 | 396 | .PARAMETER Path 397 | This is the path to the ACL Permission Report file to import. This parameter is 398 | required. 399 | 400 | .EXAMPLE 401 | Import-ACLDiffReport -Path C:\ACLReports\server01.acr 402 | Imports the ACL Share Report from the file C:\ACLReports\server01Permission and puts 403 | it into the pipeline 404 | #> 405 | function Import-ACLDiffReport 406 | { 407 | [CmdLetBinding()] 408 | # [OutputType([ACLReportTools.PermissionDiff])] 409 | param 410 | ( 411 | [Parameter(Mandatory=$true)] 412 | [ValidateNotNullOrEmpty()] 413 | [String]$Path 414 | ) # param 415 | 416 | Import-ACLPermissionDiff @PSBoundParameters 417 | 418 | } # Function Import-ACLDiffReport 419 | 420 | 421 | <# 422 | .SYNOPSIS 423 | Compares two ACL reports and produces an ACL Difference report. 424 | 425 | .DESCRIPTION 426 | This cmdlets compares two ACL Share reports and produces a difference list in the 427 | pipeline that can then be reported on. 428 | 429 | A baseline report (usually from importing a previous ACL Share Report) must be provided. 430 | The second ACL Share report (called the current ACL Share report) will be compared 431 | against the baseline report. 432 | The current ACL report will be either generated by the New-ACLShareReport or 433 | New-ACLPathFileReport cmdlets (depending on parameters) or it can be passed in via the 434 | With variable. 435 | 436 | .PARAMETER Baseline 437 | This is the baseline report data the comparison will focus on. It will usually be 438 | pulled in from a previously saved Share ACL report via the Import-ACLReports 439 | 440 | .PARAMETER ComputerName 441 | This is the computer(s) to generate the current list of Share ACLs for to perform the 442 | comparison with the baseline. The Computer names can also be passed in via the pipeline. 443 | 444 | This parameter should not be used if the With Parameter is provided. 445 | 446 | .PARAMETER Include 447 | This is a list of shares to include from the comparison. If this parameter is not set it will 448 | default to including all shares. This parameter can't be set if the Exclude parameter is set. 449 | 450 | This parameter should not be used if the With Parameter is provided. 451 | 452 | .PARAMETER Exclude 453 | This is a list of shares to exclude from the comparison. If this parameter is not set it will 454 | default to excluding no shares. This parameter can't be set if the Include parameter is set. 455 | 456 | This parameter should not be used if the With Parameter is provided. 457 | 458 | .PARAMETER With 459 | This parameter provides an ACL Share report to compare with the Baseline ACL Share 460 | report. 461 | 462 | This parameter should not be used if the ComputerName Parameter is provided. 463 | 464 | .PARAMETER ReportNoChange 465 | Setting this switch will cause a 'No Change' report item to be shown when a share is 466 | identical in both the baseline and current reports. 467 | 468 | .PARAMETER IncludeInherited 469 | Setting this switch will cause the non inherited file/folder ACLs to be pulled 470 | recursively. 471 | 472 | .EXAMPLE 473 | Compare-ACLReports ` 474 | -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) ` 475 | -With (Get-ACLReport -ComputerName CLIENT01) 476 | This will perform a comparison of the current share ACL report from computer CLIENT01 with 477 | the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl 478 | 479 | .EXAMPLE 480 | Compare-ACLReports ` 481 | -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) ` 482 | -ComputerName CLIENT01 483 | This will perform a comparison of the current share ACL report from computer CLIENT01 with 484 | the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl 485 | 486 | .EXAMPLE 487 | Compare-ACLReports ` 488 | -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14_SHARE01_ONLY.acl) ` 489 | -ComputerName CLIENT01 ` 490 | -Include SHARE01 491 | This will perform a comparison of the current share ACL report from computer CLIENT01 492 | for only SHARE01 with the stored share ACL report in file 493 | c:\ACLReports\CLIENT01_2014_11_14_SHARE01_ONLY.acl 494 | 495 | .EXAMPLE 496 | "CLIENT01" | Compare-ACLReports ` 497 | -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) 498 | This will perform a comparison of the current share ACL report from computer CLIENT01 499 | with the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl 500 | 501 | .EXAMPLE 502 | Compare-ACLReports ` 503 | -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) ` 504 | -With (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_06_01.acl) 505 | This will perform a comparison of the share ACL report in file 506 | c:\ACLReports\CLIENT01_2014_06_01.acl with the stored share ACL report in file 507 | c:\ACLReports\CLIENT01_2014_11_14.acl 508 | #> 509 | Function Compare-ACLReports 510 | { 511 | [CmdLetBinding()] 512 | param 513 | ( 514 | [Parameter( 515 | Mandatory=$true)] 516 | [ValidateScript( { ($_.GetType() -ne 'ACLReportTools.Permission') ` 517 | -and ($_.GetType() -ne 'Deserialized.ACLReportTools.Permission') } )] 518 | [Object[]]$Baseline, 519 | 520 | [Parameter( 521 | ParameterSetName='CompareToCurrentShares', 522 | ValueFromPipeline=$true, 523 | ValueFromPipelineByPropertyName=$true)] 524 | [String[]]$ComputerName=$env:computername, 525 | 526 | [Parameter( 527 | ParameterSetName='CompareToCurrentShares')] 528 | [String[]]$Include, 529 | 530 | [Parameter( 531 | ParameterSetName='CompareToCurrentShares')] 532 | [String[]]$Exclude, 533 | 534 | [Parameter( 535 | ParameterSetName='CompareToCurrentFiles')] 536 | [String[]]$Path, 537 | 538 | [Parameter( 539 | ParameterSetName='CompareToOther')] 540 | [ACLReportTools.Permission[]]$With, 541 | 542 | [Switch]$ReportNoChange, 543 | 544 | [Switch]$IncludeInherited 545 | ) # param 546 | begin 547 | { 548 | [ACLReportTools.PermissionDiff[]]$Comparison = $Null 549 | } # Begin 550 | process 551 | { 552 | switch ($PSCmdLet.ParameterSetName) 553 | { 554 | 'CompareToCurrentShares' { 555 | # A report to compare to wasn't specified so we need to generate 556 | # the current report using the other parameters passed. 557 | $null = $PSBoundParameters.Remove('Baseline') 558 | $null = $PSBoundParameters.Remove('With') 559 | $null = $PSBoundParameters.Remove('ReportNoChange') 560 | $null = $PSBoundParameters.Remove('Path') 561 | Write-Verbose -Message 'Assembling current ACL Share report for comparison.' 562 | [ACLReportTools.Permission[]]$With += New-ACLShareReport @PSBoundParameters 563 | Break 564 | } 565 | 'CompareToCurrentFiles' { 566 | # A report to compare to wasn't specified so we need to generate 567 | # the current report using the other parameters passed. 568 | $null = $PSBoundParameters.Remove('Baseline') 569 | $null = $PSBoundParameters.Remove('With') 570 | $null = $PSBoundParameters.Remove('ReportNoChange') 571 | $null = $PSBoundParameters.Remove('ComputerName') 572 | $null = $PSBoundParameters.Remove('Include') 573 | $null = $PSBoundParameters.Remove('Exclude') 574 | Write-Verbose -Message 'Assembling current ACL Path File report for comparison.' 575 | [ACLReportTools.Permission[]]$With += New-ACLPathFileReport @PSBoundParameters 576 | Break 577 | } 578 | } 579 | } # Process 580 | end 581 | { 582 | # The actual comparions is performed now 583 | # Get list of shares and computers we are going to compare the ACLs from 584 | $Current_Computers = $With | Select-Object -ExpandProperty ComputerName -Unique 585 | if ($Current_Computers.Length -eq 0) 586 | { 587 | Write-Error 'No accessible shares were found on the computers specified.' 588 | Return 589 | } 590 | else 591 | { 592 | $Baseline_Computers = $Baseline | Select-Object -ExpandProperty ComputerName -Unique 593 | foreach ($Current_Computer in $current_Computers) 594 | { 595 | # Perform a share comparison on each of the current computers 596 | If ($baseline_Computers -contains $Current_Computer) 597 | { 598 | Write-Verbose -Message "Performing share comparison of computer $Current_Computer." 599 | # Assemble the list of shares for the computer 600 | $Current_Shares = $With | 601 | Where-Object -Property ComputerName -eq $Current_Computer | 602 | Select-Object -ExpandProperty Share -Unique 603 | $Baseline_Shares = $Baseline | 604 | Where-Object -Property ComputerName -eq $Current_Computer | 605 | Select-Object -ExpandProperty Share -Unique 606 | foreach ($current_share in $current_shares) 607 | { 608 | if ($baseline_shares -contains $current_share) 609 | { 610 | Write-Verbose -Message "Performing share comparison of share $Current_Share on computer $Current_Computer." 611 | 612 | # Assemble list of ACLS for share/computer 613 | $Filter = [ScriptBlock]::Create({ ($_.ComputerName -eq $Current_Computer) ` 614 | -and ($_.Share -eq $Current_Share) -and ($_.Type -eq [ACLReportTools.PermissionTypeEnum]::Share) }) 615 | $Current_Share_Acls = $With | Where-Object -FilterScript $Filter 616 | $Baseline_Share_Acls = $Baseline | Where-Object -FilterScript $Filter 617 | [boolean]$changes = $false 618 | 619 | # Now compare the current share ACLs wth the baseline share ACLs 620 | foreach ($current_share_acl in $current_share_acls) 621 | { 622 | [string]$c_accesscontroltype = $current_share_acl.Access.AccessControlType 623 | [string]$c_filesystemrights = $current_share_acl.Access.AccessRights 624 | [string]$c_identityreference = $current_share_acl.Access.Account 625 | [boolean]$acl_found = $false 626 | foreach ($baseline_share_acl in $baseline_share_acls) 627 | { 628 | [string]$b_accesscontroltype = $baseline_share_acl.Access.AccessControlType 629 | [string]$b_filesystemrights = $baseline_share_acl.Access.AccessRights 630 | [string]$b_identityreference = $baseline_share_acl.Access.Account 631 | if ($c_identityreference -eq $b_identityreference) 632 | { 633 | $acl_found = $true 634 | break 635 | } # If 636 | 637 | } # Foreach 638 | 639 | if ($acl_found) 640 | { 641 | # The IdentityReference (user) exists in both the Baseline and the Current ACLs 642 | # Check it's the same though 643 | if ($c_filesystemrights -ne $b_filesystemrights) 644 | { 645 | # The Permission rights are different 646 | $DiffMessage = "Share permission rights changed from '$b_filesystemrights' to '$c_filesystemrights' for '$c_identityreference'." 647 | Write-Verbose -Message $DiffMessage 648 | $Comparison += New-PermissionDiffObject ` 649 | -Type ([ACLReportTools.PermissionTypeEnum]::Share) ` 650 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Rights Changed') ` 651 | -ComputerName $Current_Computer -Share $Current_Share ` 652 | -Difference $DiffMessage 653 | $changes = $true 654 | 655 | } 656 | elseif ($c_accesscontroltype -ne $b_accesscontroltype) 657 | { 658 | # The Permission access control type is different 659 | $DiffMessage = "Share permission '$c_filesystemrights $c_accesscontroltype' for '$c_identityreference' added." 660 | Write-Verbose -Message $DiffMessage 661 | $Comparison += New-PermissionDiffObject ` 662 | -Type ([ACLReportTools.PermissionTypeEnum]::Share) ` 663 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Access Control Changed') ` 664 | -ComputerName $Current_Computer -Share $Current_Share ` 665 | -Difference $DiffMessage 666 | $changes = $true 667 | } # If 668 | } 669 | else 670 | { 671 | # The ACL wasn't found in the baseline so it must be newly added 672 | $DiffMessage = "Share permission '$c_filesystemrights $c_accesscontroltype' for '$c_identityreference' added." 673 | Write-Verbose -Message $DiffMessage 674 | $Comparison += New-PermissionDiffObject ` 675 | -Type ([ACLReportTools.PermissionTypeEnum]::Share) ` 676 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Added') ` 677 | -ComputerName $Current_Computer -Share $Current_Share ` 678 | -Difference $DiffMessage 679 | $changes = $true 680 | } # If 681 | } # Foreach 682 | 683 | # Now compare the baseline share ACLs wth the current share ACLs 684 | # We only need to check if a ACL has been removed from the baseline 685 | foreach ($baseline_share_acl in $baseline_share_acls) 686 | { 687 | [string]$b_accesscontroltype = $baseline_share_acl.Access.AccessControlType 688 | [string]$b_filesystemrights = $baseline_share_acl.Access.AccessRights 689 | [string]$b_identityreference = $baseline_share_acl.Access.Account 690 | [boolean]$acl_found = $false 691 | foreach ($current_share_acl in $current_share_acls) 692 | { 693 | [string]$c_accesscontroltype = $current_share_acl.Access.AccessControlType 694 | [string]$c_filesystemrights = $current_share_acl.Access.AccessRights 695 | [string]$c_identityreference = $current_share_acl.Access.Account 696 | if ($c_identityreference -eq $b_identityreference) 697 | { 698 | $acl_found = $true 699 | break 700 | } # If 701 | } # Foreach 702 | 703 | if (-not $acl_found) 704 | { 705 | # The IdentityReference (user) exists in the Baseline but not in the Current 706 | $DiffMessage = "Share permission '$b_filesystemrights $b_accesscontroltype' for '$b_identityreference' removed." 707 | Write-Verbose -Message $DiffMessage 708 | $Comparison += New-PermissionDiffObject ` 709 | -Type ([ACLReportTools.PermissionTypeEnum]::Share) ` 710 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Removed') ` 711 | -ComputerName $Current_Computer -Share $Current_Share ` 712 | -Difference $DiffMessage 713 | $changes = $true 714 | } # If 715 | } # Foreach 716 | 717 | # Perform the baseline to current file/folder ACL comparison 718 | $Filter = [ScriptBlock]::Create({ ($_.ComputerName -eq $Current_Computer) ` 719 | -and ($_.Share -eq $Current_Share) ` 720 | -and (($_.Type -eq [ACLReportTools.PermissionTypeEnum]::File) ` 721 | -or ($_.Type -eq [ACLReportTools.PermissionTypeEnum]::Folder)) }) 722 | $Current_file_Acls = $With | Where-Object -FilterScript $Filter 723 | $Baseline_file_Acls = $Baseline | Where-Object -FilterScript $Filter 724 | [string]$last_path = '.' 725 | 726 | foreach ($current_file_acl in $current_file_acls) 727 | { 728 | # Put all the Current File ACL props into variables for easy access. 729 | [string]$c_path = $current_file_acl.Path 730 | [string]$c_owner = $current_file_acl.Owner 731 | [string]$c_inherited = $current_file_acl.Inherited 732 | $c_access = $current_file_acl.Access 733 | [string]$c_accesscontroltype = $c_access.AccessControlType 734 | [string]$c_filesystemrights = $c_access.AccessRights 735 | [string]$c_identityreference = $c_access.Account 736 | [string]$c_appliesto=Convert-FileSystemAppliesToString -InheritanceFlags $c_access.InheritanceFlags -PropagationFlags $c_access.PropagationFlags 737 | [boolean]$acl_found = $false 738 | foreach ($baseline_file_acl in $baseline_file_acls) 739 | { 740 | [string]$b_path = $baseline_file_acl.Path 741 | [string]$b_owner = $baseline_file_acl.Owner 742 | [string]$b_inherited = $baseline_file_acl.Inherited 743 | $b_access = $baseline_file_acl.Access 744 | [string]$b_accesscontroltype = $b_access.AccessControlType 745 | [string]$b_filesystemrights = $b_access.AccessRights 746 | [string]$b_identityreference = $b_access.Account 747 | [string]$b_appliesto=Convert-FileSystemAppliesToString -InheritanceFlags $b_access.InheritanceFlags -PropagationFlags $b_access.PropagationFlags 748 | if ($c_path -eq $b_path) 749 | { 750 | # Perform an owner check on each file/folder only once 751 | # If we've already checked this path, don't bother 752 | # checking the owner again. 753 | if ($last_path -ne $c_path) 754 | { 755 | if ($c_owner -ne $b_owner) 756 | { 757 | # The Permission Owner are different 758 | $DiffMessage = "$([ACLReportTools.PermissionTypeEnum]$current_file_acl.Type) $c_path owner changed from '$b_owner' to '$c_owner'." 759 | Write-Verbose -Message $DiffMessage 760 | $Comparison += New-PermissionDiffObject ` 761 | -Type ($current_file_acl.Type) ` 762 | -Path $c_path ` 763 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Owner Changed') ` 764 | -ComputerName $Current_Computer -Share $Current_Share ` 765 | -Difference $DiffMessage 766 | $changes = $true 767 | } # If 768 | 769 | if ($c_inherited -ne $b_inherited) 770 | { 771 | # The inheritance is different 772 | $DiffMessage = "$([ACLReportTools.PermissionTypeEnum]$current_file_acl.Type) $c_path inheritance changed from '$b_inheritance' to '$c_inheritance'." 773 | Write-Verbose -Message $DiffMessage 774 | $Comparison += New-PermissionDiffObject ` 775 | -Type ($current_file_acl.Type) ` 776 | -Path $c_path ` 777 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Inheritance Changed') ` 778 | -ComputerName $Current_Computer -Share $Current_Share ` 779 | -Difference $DiffMessage 780 | $changes = $true 781 | } 782 | 783 | $last_path = $c_path 784 | } # If 785 | # Check that the Identity Reference (user) is the same 786 | # one and that the Applies To is the same 787 | if (($c_identityreference -eq $b_identityreference) ` 788 | -and ($c_appliesto -eq $b_appliesto)) 789 | { 790 | $acl_found = $true 791 | break 792 | } 793 | } # If 794 | } # Foreach 795 | 796 | if ($acl_found) 797 | { 798 | # The IdentityReference (user) and path exists in both 799 | # the Baseline and the Current ACLs 800 | # Check it's the same though 801 | if ($c_filesystemrights -ne $b_filesystemrights) 802 | { 803 | # The Permission rights are different 804 | $DiffMessage = "$([ACLReportTools.PermissionTypeEnum]$current_file_acl.Type) $c_path permission rights changed from '$b_filesystemrights' to '$c_filesystemrights' for '$c_identityreference'." 805 | Write-Verbose -Message $DiffMessage 806 | $Comparison += New-PermissionDiffObject ` 807 | -Type ($current_file_acl.Type) ` 808 | -Path $c_path ` 809 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Rights Changed') ` 810 | -ComputerName $Current_Computer -Share $Current_Share ` 811 | -Difference $DiffMessage 812 | $changes = $true 813 | } # If 814 | if ($c_accesscontroltype -ne $b_accesscontroltype) 815 | { 816 | # The Permission access control type is different 817 | $DiffMessage = "$([ACLReportTools.PermissionTypeEnum]$current_file_acl.Type) $c_path permission access control type changed from '$b_accesscontroltype' to '$c_accesscontroltype' for '$c_identityreference'." 818 | Write-Verbose -Message $DiffMessage 819 | $Comparison += New-PermissionDiffObject ` 820 | -Type ($current_file_acl.Type) ` 821 | -Path $c_path ` 822 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Access Control Changed') ` 823 | -ComputerName $Current_Computer -Share $Current_Share ` 824 | -Difference $DiffMessage 825 | $changes = $true 826 | } # If 827 | } 828 | else 829 | { 830 | # The Permission was not found in the baseline so it must have 831 | # been added 832 | $DiffMessage = "$([ACLReportTools.PermissionTypeEnum]$current_file_acl.Type) $c_path permission '$c_filesystemrights, $c_accesscontroltype, $c_appliesto' added for '$c_identityreference'." 833 | Write-Verbose -Message $DiffMessage 834 | $Comparison += New-PermissionDiffObject ` 835 | -Type ($current_file_acl.Type) ` 836 | -Path $c_path ` 837 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Added') ` 838 | -ComputerName $Current_Computer -Share $Current_Share ` 839 | -Difference $DiffMessage 840 | $changes = $true 841 | } # If 842 | } # Foreach 843 | 844 | # Now compare the baseline file ACLs wth the current file ACLs 845 | # We only need to check if a ACL has been removed from the baseline 846 | foreach ($baseline_file_acl in $baseline_file_acls) 847 | { 848 | [string]$b_path = $baseline_file_acl.Path 849 | [string]$b_owner = $baseline_file_acl.Owner 850 | $b_access = $baseline_file_acl.Access 851 | [string]$b_accesscontroltype = $b_access.AccessControlType 852 | [string]$b_filesystemrights = $b_access.AccessRights 853 | [string]$b_identityreference = $b_access.Account 854 | [string]$b_appliesto = Convert-FileSystemAppliesToString ` 855 | -InheritanceFlags $b_access.InheritanceFlags ` 856 | -PropagationFlags $b_access.PropagationFlags 857 | [boolean]$acl_found = $false 858 | foreach ($current_file_acl in $current_file_acls) 859 | { 860 | [string]$c_path = $current_file_acl.Path 861 | [string]$c_owner = $current_file_acl.Owner 862 | $c_access = $current_file_acl.Access 863 | [string]$c_accesscontroltype = $c_access.AccessControlType 864 | [string]$c_filesystemrights = $c_access.AccessRights 865 | [string]$c_identityreference = $c_access.Account 866 | [string]$c_appliesto = Convert-FileSystemAppliesToString ` 867 | -InheritanceFlags $c_access.InheritanceFlags ` 868 | -PropagationFlags $c_access.PropagationFlags 869 | if (($c_path -eq $b_path) -and ($c_identityreference -eq $b_identityreference) -and ($c_appliesto -eq $b_appliesto)) 870 | { 871 | $acl_found = $true 872 | break 873 | } # If 874 | } # Foreach 875 | if (-not $acl_found) 876 | { 877 | # The IdentityReference (user) and path exists in the 878 | # Baseline but not in the Current 879 | $DiffMessage = "$([ACLReportTools.PermissionTypeEnum]$baseline_file_acl.Type) $b_path permission '$b_filesystemrights, $b_accesscontroltype, $b_appliesto' removed for '$b_identityreference'." 880 | Write-Verbose -Message $DiffMessage 881 | $Comparison += New-PermissionDiffObject ` 882 | -Type ($baseline_file_acl.Type) ` 883 | -Path $b_path ` 884 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Removed') ` 885 | -ComputerName $Current_Computer -Share $Current_Share ` 886 | -Difference $DiffMessage 887 | $changes = $true 888 | } # If 889 | } # Foreach 890 | 891 | # If no changes have been made to any of the Share or File/Folder 892 | # ACLs then say so 893 | if (-not $changes) 894 | { 895 | $DiffMessage = "The share, file and folder permissions for the share $Current_Share on $Current_Computer have not changed." 896 | Write-Verbose -Message $DiffMessage 897 | if ($ReportNoChange) 898 | { 899 | $Comparison += New-PermissionDiffObject ` 900 | -Type ([ACLReportTools.PermissionTypeEnum]::Share) ` 901 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'No Change') ` 902 | -ComputerName $Current_Computer -Share $Current_Share ` 903 | -Difference $DiffMessage 904 | } # If ($ReportNoChange) 905 | } # If 906 | } 907 | else 908 | { 909 | # The Share exists in the Current but not in the Baseline 910 | $DiffMessage = "The share $Current_Share on computer $Current_Computer has been added." 911 | Write-Verbose -Message $DiffMessage 912 | $Comparison += New-PermissionDiffObject ` 913 | -Type ([ACLReportTools.PermissionTypeEnum]::Share) ` 914 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Share Added') ` 915 | -ComputerName $Current_Computer -Share $Current_Share ` 916 | -Difference $DiffMessage 917 | 918 | # Get the Current File/Folder ACLs to an Array 919 | $Filter = [ScriptBlock]::Create({ ($_.ComputerName -eq $Current_Computer) ` 920 | -and ($_.Share -eq $Current_Share) ` 921 | -and (($_.Type -eq [ACLReportTools.PermissionTypeEnum]::File) ` 922 | -or ($_.Type -eq [ACLReportTools.PermissionTypeEnum]::Folder)) }) 923 | $Current_file_Acls = $With | Where-Object -FilterScript $Filter 924 | 925 | # Output all the current share ACLs into the report as the share is new all permissions must also be new 926 | foreach ($current_file_acl in $current_file_acls) 927 | { 928 | [string]$c_path = $current_file_acl.Path 929 | [string]$c_owner = $current_file_acl.Owner 930 | $c_access = $current_file_acl.Access 931 | [string]$c_accesscontroltype = $c_access.AccessControlType 932 | [string]$c_filesystemrights = $c_access.AccessRights 933 | [string]$c_identityreference = $c_access.Account 934 | 935 | # Because this is a new share, the permission has always been added 936 | $DiffMessage = "$($current_file_acl.Type) $c_path permission '$c_filesystemrights, $c_accesscontroltype, $c_appliesto' added for '$c_identityreference'." 937 | Write-Verbose -Message $DiffMessage 938 | $Comparison += New-PermissionDiffObject ` 939 | -Type ($current_file_acl.Type) ` 940 | -Path $c_path ` 941 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Permission Added') ` 942 | -ComputerName $Current_Computer -Share $Current_Share ` 943 | -Difference $DiffMessage 944 | } # Foreach ($current_file_acl in $current_file_acls) 945 | } # If ($baseline_shares -contains $current_share) 946 | } # Foreach ($current_share in $current_shares) 947 | 948 | # Check for any removed shares 949 | foreach ($baseline_share in $baseline_shares) 950 | { 951 | if ($current_shares -notcontains $baseline_share) 952 | { 953 | # Baseline Share does not exist in Current Shares (Share removed) 954 | $DiffMessage = "The share $baseline_share on computer $Current_Computer has been removed." 955 | Write-Verbose -Message $DiffMessage 956 | $Comparison += New-PermissionDiffObject ` 957 | -Type ([ACLReportTools.PermissionTypeEnum]::Share) ` 958 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Share Removed') ` 959 | -ComputerName $Current_Computer -Share $baseline_share ` 960 | -Difference $DiffMessage 961 | } # If ($current_shares -notcontains $baseline_share) 962 | } # Foreach ($baseline_share in $baseline_shares) 963 | } 964 | else 965 | { 966 | # The Computer exists in the Current but not in the Baseline 967 | $DiffMessage = "Skiping share comparison of computer $Current_Computer because it was not found in the baseline report." 968 | Write-Verbose -Message $DiffMessage 969 | $Comparison += New-PermissionDiffObject ` 970 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Computer Added') ` 971 | -ComputerName $Current_Computer ` 972 | -Difference $DiffMessage 973 | } # If ($baseline_Computers.Contains($Current_Computer)) 974 | } # Foreach ($Current_Computer in $current_Computers) 975 | 976 | # Check for any removed computers 977 | foreach ($baseline_computer in $baseline_computers) 978 | { 979 | if ($current_computers -notcontains $baseline_computer) 980 | { 981 | # Baseline computer does not exist in Current computer (Computer removed) 982 | $DiffMessage = "The computer $Current_Computer has been removed." 983 | Write-Verbose -Message $DiffMessage 984 | $Comparison += New-PermissionDiffObject ` 985 | -DiffType ([ACLReportTools.PermissionDiffEnum]::'Computer Removed') ` 986 | -ComputerName $Current_Computer ` 987 | -Difference $DiffMessage 988 | 989 | } # If 990 | } # Foreach ($baseline_computer in $baseline_computers) 991 | } # If 992 | # Push the comparison result objects into the pipeline 993 | $Comparison 994 | } # End 995 | } # Function Compare-ACLReports 996 | 997 | 998 | #################################################################################################### 999 | # Support CmdLets 1000 | #################################################################################################### 1001 | 1002 | <# 1003 | .SYNOPSIS 1004 | Gets a list of the Shares on a specified computer(s) with specified inclusions or exclusions. 1005 | 1006 | .DESCRIPTION 1007 | This function will pull a list of shares that are set up on the specified computer. Shares 1008 | can also be included or excluded from the share list by setting the Include or Exclude 1009 | properties. 1010 | 1011 | The Cmdlet returns an array of ACLReportTools.Share objects. 1012 | 1013 | .PARAMETER ComputerName 1014 | This is the computer to get the shares from. If this parameter is not set it will default 1015 | to the current machine. 1016 | 1017 | .PARAMETER Include 1018 | This is a list of shares to include from the computer. If this parameter is not set it will 1019 | default to including all shares. This parameter can't be set if the Exclude parameter is set. 1020 | 1021 | .PARAMETER Exclude 1022 | This is a list of shares to exclude from the computer. If this parameter is not set it will 1023 | default to excluding no shares. This parameter can't be set if the Include parameter is set. 1024 | 1025 | .EXAMPLE 1026 | Get-ACLShare -ComputerName CLIENT01 1027 | Returns a list of all shares set up on the CLIENT01 machine. 1028 | 1029 | .EXAMPLE 1030 | Get-ACLShare -ComputerName CLIENT01 -Include MyShare,OtherShare 1031 | Returns a list of shares that are set up on the CLIENT01 machine that are named either 1032 | MyShare or OtherShare. 1033 | 1034 | .EXAMPLE 1035 | Get-ACLShare -ComputerName CLIENT01 -Exclude SysVol 1036 | Returns a list of shares that are set up on the CLIENT01 machine that are not called SysVol. 1037 | 1038 | .EXAMPLE 1039 | Get-ACLShare -ComputerName CLIENT01,CLIENT02 1040 | Returns a list of shares that are set up on the CLIENT01 and CLIENT02 machines. 1041 | 1042 | .EXAMPLE 1043 | Get-ACLShare -ComputerName CLIENT01,CLIENT02 -Exclude SysVol 1044 | Returns a list of shares that are set up on the CLIENT01 and CLIENT02 machines that are not 1045 | called SysVol. 1046 | #> 1047 | Function Get-ACLShare { 1048 | [CmdLetBinding()] 1049 | param 1050 | ( 1051 | [Parameter( 1052 | ValueFromPipeline=$true, 1053 | ValueFromPipelineByPropertyName=$true)] 1054 | [String[]]$ComputerName=$env:computername, 1055 | 1056 | [String[]]$Include, 1057 | 1058 | [String[]]$Exclude 1059 | ) # param 1060 | begin 1061 | { 1062 | [ACLReportTools.Share[]]$SelectedShares = $null 1063 | } # Begin 1064 | process 1065 | { 1066 | foreach ($Computer in $ComputerName) 1067 | { 1068 | Write-Verbose -Message "Getting shares list on computer $Computer" 1069 | [Array]$AllShares = Get-WMIObject -Class win32_share -ComputerName $Computer | 1070 | Where-Object { $_.Name -notlike "*$" } | 1071 | select -ExpandProperty Name 1072 | foreach ($Share in $AllShares) 1073 | { 1074 | if ($Include.Count -gt 0) 1075 | { 1076 | if ($Share -in $Include) 1077 | { 1078 | Write-Verbose -Message "$Share on computer $Computer Included" 1079 | $SelectedShares += New-ShareObject -ComputerName $Computer -ShareName $Share 1080 | } 1081 | else 1082 | { 1083 | Write-Verbose -Message "$Share on computer $Computer Not Included" 1084 | } 1085 | } 1086 | elseif ($Exclude.Count -gt 0) 1087 | { 1088 | if ($Share -in $Exclude) 1089 | { 1090 | Write-Verbose -Message "$Share on computer $Computer Excluded" 1091 | } 1092 | else 1093 | { 1094 | Write-Verbose -Message "$Share on computer $Computer Not Excluded" 1095 | $SelectedShares += New-ShareObject -ComputerName $Computer -ShareName $Share 1096 | } 1097 | } 1098 | else 1099 | { 1100 | Write-Verbose -Message "$Share on computer $Computer Included" 1101 | $SelectedShares += New-ShareObject -ComputerName $Computer -ShareName $Share 1102 | } # If 1103 | } # Foreach ($Share in $AllShares) 1104 | } # Foreach ($Computer In $ComputerName) 1105 | } # Process 1106 | end 1107 | { 1108 | Return $SelectedShares 1109 | } # End 1110 | } # Function Get-ACLShare 1111 | 1112 | 1113 | <# 1114 | .SYNOPSIS 1115 | Gets the ACLs for a specified Share. 1116 | 1117 | .DESCRIPTION 1118 | This function will return the share ACLs for the specified share. 1119 | 1120 | .PARAMETER ComputerName 1121 | This is the computer to get the share ACLs from. If this parameter is not set it will 1122 | default to the current machine. 1123 | 1124 | .PARAMETER ShareName 1125 | This is the share name to pull the share ACLs for. 1126 | 1127 | .PARAMETER Shares 1128 | This is a pipeline parameter that should be used for passing in a list of shares and 1129 | computers to pull ACLs for. This parameter expects an array of [ACLReportTools.Share] objects. 1130 | 1131 | This parameter is usually used with the Get-ACLShare CmdLet. 1132 | 1133 | For example: 1134 | 1135 | Get-ACLShare -ComputerName CLIENT01,CLIENT02 -Exclude SYSVOL | Get-ACLShareACL 1136 | 1137 | .EXAMPLE 1138 | Get-ACLShareACL -ComputerName CLIENT01 -ShareName MyShre 1139 | Returns the share ACLs for the MyShare Share on the CLIENT01 machine. 1140 | #> 1141 | function Get-ACLShareACL 1142 | { 1143 | [CmdLetBinding()] 1144 | param 1145 | ( 1146 | [Parameter( 1147 | ParameterSetName='ByParameters')] 1148 | [String]$ComputerName=$env:computername, 1149 | 1150 | [Parameter( 1151 | ParameterSetName='ByParameters')] 1152 | [String]$ShareName, 1153 | 1154 | [Parameter( 1155 | ParameterSetName='ByPipeline', 1156 | ValueFromPipeline=$true, 1157 | ValueFromPipelineByPropertyName=$true)] 1158 | [ACLReportTools.Share[]]$Shares 1159 | ) # param 1160 | 1161 | begin 1162 | { 1163 | # Create an empty array to store all the Share ACLs. 1164 | [ACLReportTools.Permission[]]$share_acls = $null 1165 | } # Begin 1166 | process 1167 | { 1168 | if ($PsCmdlet.ParameterSetName -eq 'ByPipeline') 1169 | { 1170 | $ComputerName = $_.ComputerName 1171 | $ShareName = $_.Name 1172 | } 1173 | $objShareSec = Get-WMIObject ` 1174 | -Class Win32_LogicalShareSecuritySetting ` 1175 | -Filter "name='$ShareName'" ` 1176 | -ComputerName $ComputerName 1177 | try 1178 | { 1179 | $SD = $objShareSec.GetSecurityDescriptor().Descriptor 1180 | foreach ($ace in $SD.DACL) 1181 | { 1182 | $UserName = $ace.Trustee.Name 1183 | if ($ace.Trustee.Domain -ne $Null) { $UserName = "$($ace.Trustee.Domain)\$UserName" } 1184 | if ($ace.Trustee.Name -eq $Null) { $UserName = $ace.Trustee.SIDString } 1185 | $fs_rule = New-Object Security.AccessControl.FileSystemAccessRule($UserName, $ace.AccessMask, $ace.AceType) 1186 | $type = [ACLReportTools.PermissionTypeEnum]::Share 1187 | $acl_object = New-PermissionObject ` 1188 | -Type $type ` 1189 | -ComputerName $ComputerName ` 1190 | -Share $ShareName ` 1191 | -Access $fs_rule 1192 | $share_acls += $acl_object 1193 | } # Foreach 1194 | } 1195 | catch 1196 | { 1197 | Write-Error "Unable to obtain share ACLs for $ShareName" 1198 | } # Try 1199 | } # Process 1200 | end 1201 | { 1202 | Return $share_acls 1203 | } # End 1204 | } # function Get-ACLShareACL 1205 | 1206 | 1207 | <# 1208 | .SYNOPSIS 1209 | Gets all the file/folder ACLs definited within a specified Share. 1210 | 1211 | .DESCRIPTION 1212 | This function will return a list of file/folder ACLs for the specified share. If the Recurse switch is used then files/folder ACLs will be scanned recursively. If the IncludeInherited switch is set then inherited file/folder permissions will also be returned, otherwise only non-inherited permissions will be returned. 1213 | 1214 | .PARAMETER ComputerName 1215 | This is the computer to get the share ACLs from. If this parameter is not set it will default to the current machine. 1216 | 1217 | .PARAMETER ShareName 1218 | This is the share name to pull the file/folder ACLs for. 1219 | 1220 | .PARAMETER Recurse 1221 | Setting this switch will cause the file/folder ACLs to be pulled recursively. 1222 | 1223 | .PARAMETER IncludeInherited 1224 | Setting this switch will cause the non inherited file/folder ACLs to be pulled recursively. 1225 | 1226 | .EXAMPLE 1227 | Get-ACLShareFileACL -ComputerName CLIENT01 -ShareName MyShare 1228 | Returns the file/folder ACLs for the root of MyShare Share on the CLIENT01 machine. 1229 | 1230 | .EXAMPLE 1231 | Get-ACLShareFileACL -ComputerName CLIENT01 -ShareName MyShare -Recurse 1232 | Returns the file/folder ACLs for all files/folders recursively inside the MyShare Share on the CLIENT01 machine. 1233 | #> 1234 | function Get-ACLShareFileACL 1235 | { 1236 | [CmdLetBinding()] 1237 | param 1238 | ( 1239 | [Parameter( 1240 | ParameterSetName='ByParameters')] 1241 | [String]$ComputerName=$env:computername, 1242 | 1243 | [Parameter( 1244 | ParameterSetName='ByParameters')] 1245 | [String]$ShareName, 1246 | 1247 | [Parameter( 1248 | ParameterSetName='ByPipeline', 1249 | ValueFromPipeline=$true, 1250 | ValueFromPipelineByPropertyName=$true)] 1251 | [ACLReportTools.Share[]]$Shares, 1252 | 1253 | [Switch]$Recurse, 1254 | 1255 | [Switch]$IncludeInherited 1256 | ) # param 1257 | 1258 | begin 1259 | { 1260 | # Create an empty array to store all the non inherited file/folder ACLs. 1261 | [ACLReportTools.Permission[]]$file_acls = $null 1262 | } # Begin 1263 | process 1264 | { 1265 | if ($PsCmdlet.ParameterSetName -eq 'ByPipeline') 1266 | { 1267 | $ComputerName = $_.ComputerName 1268 | $ShareName = $_.Name 1269 | } 1270 | # Now generate the root file/folder ACLs 1271 | $Path = "\\$ComputerName\$ShareName" 1272 | [Security2.FileSystemAccessRule2[]]$root_file_acl = Get-NTFSAccess -Path $path 1273 | [String]$owner = (Get-NTFSOwner -Path $path).Owner.AccountName 1274 | foreach ($access in $root_file_acl) 1275 | { 1276 | # Write each non-inherited ACL from the root into the array of ACL's 1277 | if ($access.IsInherited) 1278 | { 1279 | [String] $Inherited = "Inherited from $($access.InheritedFrom)" 1280 | } 1281 | else 1282 | { 1283 | [String] $Inherited = 'Not-inherited' 1284 | } 1285 | $file_acls += New-PermissionObject ` 1286 | -ComputerName $ComputerName ` 1287 | -Type ([ACLReportTools.PermissionTypeEnum]::Folder) ` 1288 | -Path $Path ` 1289 | -Owner $owner ` 1290 | -Access $access ` 1291 | -Share $ShareName ` 1292 | -Inherited $Inherited 1293 | Write-Verbose -Message "Get-ACLShareFileACL: Root ACL for $ShareName path $Path owner $Owner`n$(Convert-AccessToString($Access))" 1294 | } # Foreach 1295 | if ($Recurse) 1296 | { 1297 | # Generate all file/folder ACLs for subfolders and/or files containined within the share recursively 1298 | $node_file_acls = Get-childitem -Path $Path -recurse | 1299 | Get-NTFSAccess 1300 | if (! $IncludeInherited) 1301 | { 1302 | # Generate any non-inferited file/folder ACLs for subfolders and/or files containined within the share recursively 1303 | $node_file_acls = $node_file_acls | Where-Object -Property IsInherited -eq $False 1304 | } 1305 | $lastPath = '' 1306 | foreach ($access in $node_file_acls) 1307 | { 1308 | # Write each non-inherited ACL from the file/folder into the array of ACL's 1309 | $Path = $access.FullName 1310 | if ($lastPath -ne $Path) 1311 | { 1312 | try 1313 | { 1314 | [Boolean]$IsFolder = ((Get-Item -Path $Path -ErrorAction 'Stop') -is [System.IO.DirectoryInfo]) 1315 | } 1316 | catch 1317 | { 1318 | Write-Warning "Get-ACLPathFileACL: Access Denied to $Path" 1319 | $IsFolder = $True 1320 | } 1321 | if ($IsFolder) 1322 | { 1323 | $type = [ACLReportTools.PermissionTypeEnum]::Folder 1324 | } 1325 | else 1326 | { 1327 | $type = [ACLReportTools.PermissionTypeEnum]::File 1328 | } 1329 | [String]$Owner = (Get-NTFSOwner -Path $Path).Owner.AccountName 1330 | $lastPath = $access.FullName 1331 | } 1332 | if ($IncludeInherited -and $access.IsInherited) 1333 | { 1334 | [String] $Inherited = "Inherited from $($access.InheritedFrom)" 1335 | } 1336 | else 1337 | { 1338 | [String] $Inherited = 'Not-inherited' 1339 | } 1340 | $file_acls += New-PermissionObject ` 1341 | -ComputerName $ComputerName ` 1342 | -Type $type ` 1343 | -Path $Path ` 1344 | -Owner $owner ` 1345 | -Access $access ` 1346 | -Share $ShareName ` 1347 | -Inherited $Inherited 1348 | Write-Verbose -Message "Get-ACLShareFileACL: $Inherited ACL for $ShareName path $Path owner $Owner`n$(Convert-AccessToString($Access))" 1349 | } # Foreach 1350 | } # If 1351 | } # Process 1352 | end 1353 | { 1354 | Return $file_acls 1355 | } # End 1356 | } # Function Get-ACLShareFileACL 1357 | 1358 | 1359 | <# 1360 | .SYNOPSIS 1361 | Gets all the file/folder ACLs defined within a specified Path. 1362 | 1363 | .DESCRIPTION 1364 | This function will return a list of file/folder ACLs for the specified share. If the Recurse switch is used then files/folder ACLs will be scanned recursively. If the IncludeInherited switch is set then inherited file/folder permissions will also be returned, otherwise only non-inherited permissions will be returned. 1365 | 1366 | .PARAMETER Path 1367 | This is the path to pull the file/folder ACLs for. 1368 | 1369 | .PARAMETER Recurse 1370 | Setting this switch will cause the file/folder ACLs to be pulled recursively. 1371 | 1372 | .PARAMETER IncludeInherited 1373 | Setting this switch will cause the non inherited file/folder ACLs to be pulled recursively. 1374 | 1375 | .EXAMPLE 1376 | Get-ACLPathFileACL -Path C:\Users 1377 | Returns the file/folder ACLs for the root of C:\Users folder. 1378 | 1379 | .EXAMPLE 1380 | Get-ACLPathFileACL -Path C:\Users -Recurse 1381 | Returns the file/folder ACLs for all files/folders recursively inside the C:\Users folder. 1382 | #> 1383 | function Get-ACLPathFileACL 1384 | { 1385 | [CmdLetBinding()] 1386 | param 1387 | ( 1388 | [Parameter(Mandatory=$true)] 1389 | [ValidateNotNullOrEmpty()] 1390 | [String]$Path, 1391 | 1392 | [Switch]$Recurse, 1393 | 1394 | [Switch]$IncludeInherited 1395 | ) # param 1396 | 1397 | # Create an empty array to store all the non inherited file/folder ACLs. 1398 | [ACLReportTools.Permission[]]$file_acls = $null 1399 | [String]$ComputerName = $ENV:ComputerName 1400 | 1401 | # Now generate the root file/folder ACLs 1402 | [Security2.FileSystemAccessRule2[]]$root_file_acl = Get-NTFSAccess -Path $path 1403 | [String]$owner = (Get-NTFSOwner -Path $path).Owner.AccountName 1404 | foreach ($access in $root_file_acl) 1405 | { 1406 | # Write each non-inherited ACL from the root into the array of ACL's 1407 | if ($access.IsInherited) 1408 | { 1409 | $Inherited = "Inherited from $($access.InheritedFrom)" 1410 | } 1411 | else 1412 | { 1413 | $Inherited = 'Not-inherited' 1414 | } 1415 | $file_acls += New-PermissionObject ` 1416 | -ComputerName $ComputerName ` 1417 | -Type ([ACLReportTools.PermissionTypeEnum]::Folder) ` 1418 | -Path $Path ` 1419 | -Owner $owner ` 1420 | -Access $access ` 1421 | -Inherited $Inherited 1422 | Write-Verbose -Message "Get-ACLPathFileACL: Root ACL for $Path owner $Owner`n$(Convert-AccessToString($Access))" 1423 | } # Foreach 1424 | if ($Recurse) 1425 | { 1426 | # Generate all file/folder ACLs for subfolders and/or files containined within the share recursively 1427 | $node_file_acls = Get-childitem -Path $Path -recurse | 1428 | Get-NTFSAccess 1429 | if (! $IncludeInherited) 1430 | { 1431 | # Generate any non-inferited file/folder ACLs for subfolders and/or files containined within the share recursively 1432 | $node_file_acls = $node_file_acls | Where-Object -Property IsInherited -eq $False 1433 | } 1434 | $LastPath = '' 1435 | foreach ($access in $node_file_acls) 1436 | { 1437 | # Write each non-inherited ACL from the file/folder into the array of ACL's 1438 | $Path = $access.FullName 1439 | if ($LastPath -ne $Path) 1440 | { 1441 | try 1442 | { 1443 | [Boolean]$IsFolder = ((Get-Item -Path $Path -ErrorAction 'Stop') -is [System.IO.DirectoryInfo]) 1444 | } 1445 | catch 1446 | { 1447 | Write-Warning "Get-ACLPathFileACL: Access Denied to $Path" 1448 | $IsFolder = $True 1449 | } 1450 | if ($IsFolder) 1451 | { 1452 | $type = [ACLReportTools.PermissionTypeEnum]::Folder 1453 | } 1454 | else 1455 | { 1456 | $type = [ACLReportTools.PermissionTypeEnum]::File 1457 | } 1458 | [String] $Owner = (Get-NTFSOwner -Path $Path).Owner.AccountName 1459 | $LastPath = $Path 1460 | } 1461 | if ($IncludeInherited -and $access.IsInherited) 1462 | { 1463 | $Inherited = "Inherited from $($access.InheritedFrom)" 1464 | } 1465 | else 1466 | { 1467 | $Inherited = 'Not-inherited' 1468 | } 1469 | $file_acls += New-PermissionObject ` 1470 | -ComputerName $ComputerName ` 1471 | -Type $type ` 1472 | -Path $Path ` 1473 | -Owner $Owner ` 1474 | -Access $Access ` 1475 | -Inherited $Inherited 1476 | Write-Verbose -Message "Get-ACLPathFileACL: $Inherited ACL for $Path owner $Owner`n$(Convert-AccessToString($Access))" 1477 | } # Foreach 1478 | } # If 1479 | return $file_acls 1480 | } # Function Get-ACLPathFileACL 1481 | 1482 | 1483 | <# 1484 | .SYNOPSIS 1485 | Export the ACL Permissions objects that are provided as a file. 1486 | 1487 | .DESCRIPTION 1488 | This Cmdlet will save what ever ACLs (ACLReportTools.Permission) to a file. 1489 | 1490 | .PARAMETER Path 1491 | This is the path to the ACL Permissions file output file. This parameter is required. 1492 | 1493 | .PARAMETER InputObject 1494 | Specifies the ACL Permissions objects to export to the file. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.Permission objects to cmdlet. 1495 | 1496 | .PARAMETER Force 1497 | Causes the file to be overwritten if it exists. 1498 | 1499 | .EXAMPLE 1500 | New-ACLPathFileReport -Path e:\Shares | Export-ACLPermission -Path C:\ACLReports\server01.acl 1501 | Creates a new ACL Permission report for e:\Shares and saves it to the file C:\ACLReports\server01.acl. 1502 | 1503 | .EXAMPLE 1504 | Export-ACLPermission -Path C:\ACLReports\server01.acl -InputObject $Acls 1505 | Saves the ACL Permissions in the $Acls variable to the file C:\ACLReports\server01.acl. 1506 | 1507 | .EXAMPLE 1508 | Export-ACLPermission -Path C:\ACLReports\server01.acl -InputObject (Get-ACLShare -ComputerName SERVER01 | Get-ACLShareFileACL -Recurse) 1509 | Saves the file ACLs for all shares on the compuer SERVER01 to the file C:\ACLReports\server01.acl. 1510 | #> 1511 | function Export-ACLPermission 1512 | { 1513 | [CmdLetBinding()] 1514 | param 1515 | ( 1516 | [Parameter(Mandatory=$true)] 1517 | [ValidateNotNullOrEmpty()] 1518 | [String]$Path, 1519 | 1520 | [Parameter(Mandatory=$true, 1521 | ValueFromPipeline=$true, 1522 | ValueFromPipelineByPropertyName=$true)] 1523 | [ValidateScript({ $_.GetType().FullName -ne 'ACLReportTools.Permission[]' })] 1524 | [ACLReportTools.Permission[]] $InputObject, 1525 | 1526 | [Switch]$Force 1527 | ) # param 1528 | 1529 | begin 1530 | { 1531 | if ((Test-Path -Path $Path -PathType Leaf) -and ($force -eq $false)) 1532 | { 1533 | Write-Error "The file $Path already exists. Use Force to overwrite it." 1534 | return 1535 | } 1536 | [array]$Output = $null 1537 | } # Begin 1538 | process 1539 | { 1540 | foreach ($Permission in $InputObject) 1541 | { 1542 | $Output += $Permission 1543 | } # Foreach 1544 | } # Process 1545 | end 1546 | { 1547 | try 1548 | { 1549 | $Output | Export-Clixml -Path $Path -Force 1550 | } 1551 | catch 1552 | { 1553 | Write-Error "Unable to export the ACL Permissions file $Path." 1554 | } 1555 | } # End 1556 | } # Function Export-ACLPermission 1557 | 1558 | 1559 | <# 1560 | .SYNOPSIS 1561 | Export the ACL Difference Objects that are provided as a file. 1562 | 1563 | .DESCRIPTION 1564 | This Cmdlet will export an array of provided Permission Difference [ACLReportTools.PermissionDiff] records to a file. 1565 | 1566 | .PARAMETER Path 1567 | This is the path to the ACL Permission Diff file. This parameter is required. 1568 | 1569 | .PARAMETER InputObject 1570 | Specifies the Permissions objects to export to th file. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.PermissionDiff objects to this cmdlet. 1571 | 1572 | .PARAMETER Force 1573 | Causes the file to be overwritten if it exists. 1574 | 1575 | .EXAMPLE 1576 | Export-ACLPermissionDiff -Path C:\ACLReports\server01.acr -InputObject $DiffReport 1577 | Saves the ACL Difference objects in the $DiffReport variable to the file C:\ACLReports\server01.acr. If the file exists it will be overwritten if the Force switch is set. 1578 | #> 1579 | function Export-ACLPermissionDiff 1580 | { 1581 | [CmdLetBinding()] 1582 | param 1583 | ( 1584 | [Parameter(Mandatory=$true)] 1585 | [ValidateNotNullOrEmpty()] 1586 | [String]$Path, 1587 | 1588 | [Parameter(Mandatory=$true, 1589 | ValueFromPipeline=$true, 1590 | ValueFromPipelineByPropertyName=$true)] 1591 | [ValidateScript({$_.GetType().FullName -ne 'ACLReportTools.PermissionDiff[]'})] 1592 | [ACLReportTools.PermissionDiff[]]$InputObject, 1593 | 1594 | [Switch]$Force 1595 | ) # param 1596 | 1597 | begin 1598 | { 1599 | if ((Test-Path -Path $Path -PathType Leaf) -and ($force -eq $false)) 1600 | { 1601 | Write-Error "The file $Path already exists. Use Force to overwrite it." 1602 | return 1603 | } 1604 | [array]$Output = $null 1605 | } # Begin 1606 | process 1607 | { 1608 | foreach ($PermissionDiff in $InputObject) 1609 | { 1610 | $Output += $PermissionDiff 1611 | } # Foreach 1612 | } # Process 1613 | end 1614 | { 1615 | try 1616 | { 1617 | $Output | Export-Clixml -Path $Path -Force 1618 | } 1619 | catch 1620 | { 1621 | Write-Error "Unable to export the ACL Permission Diff $Path." 1622 | } 1623 | } # End 1624 | } # Function Export-ACLPermissionDiff 1625 | 1626 | 1627 | <# 1628 | .SYNOPSIS 1629 | Import the a File containing serialized ACL Permission objects that are in a file back into the pipeline. 1630 | 1631 | .DESCRIPTION 1632 | This Cmdlet will load all the ACLs (ACLReportTools.Permission) records from a specified file. 1633 | 1634 | .PARAMETER Path 1635 | This is the path to the file containing ACL Permission objects. This parameter is required. 1636 | 1637 | .EXAMPLE 1638 | Import-ACLPermission -Path C:\ACLReports\server01.acl 1639 | Loads the ACLs in the file C:\ACLReports\server01.acl. 1640 | #> 1641 | function Import-ACLPermission 1642 | { 1643 | [CmdLetBinding()] 1644 | # [OutputType([ACLReportTools.Permission])] 1645 | param 1646 | ( 1647 | [Parameter(Mandatory=$true)] 1648 | [ValidateNotNullOrEmpty()] 1649 | [String]$Path 1650 | ) # param 1651 | 1652 | if ((Test-Path -Path $Path -PathType Leaf) -eq $false) 1653 | { 1654 | Write-Error "The file $Path does not exist." 1655 | return 1656 | } 1657 | 1658 | try 1659 | { 1660 | Import-Clixml -Path $Path 1661 | } 1662 | catch 1663 | { 1664 | Write-Error "Unable to import the ACL file $Path." 1665 | } # Try 1666 | } # Function Import-ACLPermission 1667 | 1668 | 1669 | <# 1670 | .SYNOPSIS 1671 | Import the a File containing serialized ACL Permission Diff objects that are in a file back into the pipeline. 1672 | 1673 | .DESCRIPTION 1674 | This Cmdlet will load all the ACLs (ACLReportTools.PermissionDiff) records from a specified file. 1675 | 1676 | .PARAMETER Path 1677 | This is the path to the file containing ACL Permission Diff objects. This parameter is required. 1678 | 1679 | .EXAMPLE 1680 | Import-ACLPermissionDiff -Path C:\ACLReports\server01.acr 1681 | Loads the ACL Permission Diff objects in the file C:\ACLReports\server01.acr. 1682 | #> 1683 | function Import-ACLPermissionDiff 1684 | { 1685 | [CmdLetBinding()] 1686 | # [OutputType([ACLReportTools.PermissionDiff])] 1687 | param 1688 | ( 1689 | [Parameter(Mandatory=$true)] 1690 | [ValidateNotNullOrEmpty()] 1691 | [String]$Path 1692 | ) # param 1693 | 1694 | if ((Test-Path -Path $Path -PathType Leaf) -eq $false) 1695 | { 1696 | Write-Error "The file $Path does not exist." 1697 | return 1698 | } 1699 | 1700 | try 1701 | { 1702 | Import-Clixml -Path $Path 1703 | } 1704 | catch 1705 | { 1706 | Write-Error "Unable to import the ACL file $Path." 1707 | } # Try 1708 | } # Function Import-ACLPermissionDiff 1709 | 1710 | 1711 | <# 1712 | .SYNOPSIS 1713 | Export the ACL Difference Objects that are provided as an HTML file. 1714 | 1715 | .DESCRIPTION 1716 | This Cmdlet will export an array of provided Permission Difference [ACLReportTools.PermissionDiff] records to an HTML file for easy viewing and reporting. 1717 | 1718 | .PARAMETER Path 1719 | This is the path to the HTML output file. This parameter is required. 1720 | 1721 | .PARAMETER InputObject 1722 | Specifies the Permissions DIff objects to export to the as HTML. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.PermissionDiff objects to this cmdlet. 1723 | 1724 | .PARAMETER Force 1725 | Causes the file to be overwritten if it exists. 1726 | 1727 | .PARAMETER Title 1728 | Optional Title text to write into the report. 1729 | 1730 | .EXAMPLE 1731 | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\server01.acl) -With (Get-ACLReport -ComputerName Server01) | Export-ACLPermissionDiffHTML -Path C:\ACLReports\server01.htm 1732 | 1733 | Performs a comparison using the Baseline file c:\ACLReports\Server01.acl and the shares on Server01 and outputs ACL Difference Report as an HTML file. 1734 | #> 1735 | function Export-ACLPermissionDiffHTML 1736 | { 1737 | [CmdLetBinding()] 1738 | param 1739 | ( 1740 | [Parameter(Mandatory=$true)] 1741 | [ValidateNotNullOrEmpty()] 1742 | [String]$Path, 1743 | 1744 | [Parameter(Mandatory=$true, 1745 | ValueFromPipeline=$true, 1746 | ValueFromPipelineByPropertyName=$true)] 1747 | [ValidateScript({$_.GetType().FullName -ne 'ACLReportTools.PermissionDiff[]'})] 1748 | [ACLReportTools.PermissionDiff[]]$InputObject, 1749 | 1750 | [Switch]$Force, 1751 | 1752 | [String]$Title = 'ACL Difference Report' 1753 | ) # param 1754 | 1755 | begin 1756 | { 1757 | if ((Test-Path -Path $Path -PathType Leaf) -and ($force -eq $false)) 1758 | { 1759 | Write-Error "The file $Path already exists. Use Force to overwrite it." 1760 | return 1761 | } 1762 | Set-Content -Path $Path -Value ( CreateHTMLReportHeader -Title $Title ) -Force 1763 | [String]$LastComputer = '' 1764 | [String]$LastShare = '' 1765 | } # Begin 1766 | process 1767 | { 1768 | foreach ($PermissionDiff in $InputObject) 1769 | { 1770 | if (($ComputerName -ne '') -and ($PermissionDiff.ComputerName -ne $LastComputer)) 1771 | { 1772 | $LastComputer = $PermissionDiff.ComputerName 1773 | Add-Content -Path $Path -Value ( CreateHTMLComputerNameLine -ComputerName $PermissionDiff.ComputerName ) -Force 1774 | } 1775 | if (($PermissionDiff.Share -ne '') -and ($PermissionDiff.Share -ne $LastShare )) 1776 | { 1777 | $LastShare = $PermissionDiff.Share 1778 | Add-Content -Path $Path -Value ( CreateHTMLShareNameLine -ShareName $PermissionDiff.Share ) -Force 1779 | } 1780 | Add-Content -Path $Path -Value ( CreateHTMLPermissionDiffLine -PermissionDiff $PermissionDiff ) -Force 1781 | } # Foreach 1782 | } # Process 1783 | end 1784 | { 1785 | Add-Content -Path $Path -Value ( CreateHTMLReportFooter ) -Force 1786 | } # End 1787 | } # Function Export-ACLPermissionDiffHTML 1788 | 1789 | 1790 | #################################################################################################### 1791 | # Hidden Support CmdLets 1792 | #################################################################################################### 1793 | 1794 | 1795 | <# 1796 | .SYNOPSIS 1797 | This function creates the a support module containing classes and enums via reflection. It also checks for and loads the 1798 | File System Security PowerShell Module Module (https://gallery.technet.microsoft.com/scriptcenter/1abd77a5-9c0b-4a2b-acef-90dbb2b84e85) 1799 | 1800 | .DESCRIPTION 1801 | This function creates a .net dynamic module via reflection and adds classes and enums to it that are then used by other functions in this module. 1802 | #> 1803 | function Initialize-Module 1804 | { 1805 | [CmdLetBinding()] 1806 | param ( 1807 | [String]$ModuleName = 'ACLReportTools' 1808 | ) # Param 1809 | 1810 | # Do we need to install the NTFSSecurity Module? 1811 | $SupportInstall = (@(Get-Command -Name Install-Module -ErrorAction SilentlyContinue).Count -gt 0) 1812 | $NTFSSecurityModules = @(Get-Module -Name NTFSSecurity -ListAvailable) 1813 | 1814 | if ( @($NTFSSecurityModules | Where-Object -Property Version -gt 4.0.0).Count -eq 0) 1815 | { 1816 | try 1817 | { 1818 | Write-Verbose -Message 'NTFSSecrity Module needs to be installed.' 1819 | Get-PackageProvider -Name NuGet -ForceBootstrap -Force 1820 | Install-Module -Name NTFSSecurity -MinimumVersion 4.0.0 -Force 1821 | Write-Verbose -Message 'NTFSSecrity Module was installed.' 1822 | } 1823 | catch 1824 | { 1825 | Throw 'NTFSSecurity Module v4.0.0 or greater is not available and could not be installed automatically. Please download it from https://gallery.technet.microsoft.com/scriptcenter/1abd77a5-9c0b-4a2b-acef-90dbb2b84e85' 1826 | } 1827 | } # If 1828 | Import-Module -Name NTFSSecurity -MinimumVersion 4.0.0 1829 | 1830 | $Domain = [AppDomain]::CurrentDomain 1831 | 1832 | if (($Domain.GetAssemblies() | Where-Object -FilterScript { $_.FullName -eq "$ModuleName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" } | Measure-Object).Count-eq 0) 1833 | { 1834 | # Define the module 1835 | $DynAssembly = New-Object Reflection.AssemblyName($ModuleName) 1836 | $AssemblyBuilder = $Domain.DefineDynamicAssembly($DynAssembly, 'Run') 1837 | $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule($ModuleName, $False) 1838 | 1839 | # Define Permission Difference Enumeration 1840 | $EnumBuilder = $ModuleBuilder.DefineEnum('ACLReportTools.PermissionTypeEnum', 'Public', [Int]) 1841 | # Define values of the enum 1842 | $EnumBuilder.DefineLiteral('Not Applicable', [Int]0) 1843 | $EnumBuilder.DefineLiteral('Share', [Int]1) 1844 | $EnumBuilder.DefineLiteral('Folder', [Int]2) 1845 | $EnumBuilder.DefineLiteral('File', [Int]3) 1846 | $PermissionTypeEnumType = $EnumBuilder.CreateType() 1847 | 1848 | # Define the ACLReportTools.Permission Class 1849 | $Attributes = 'AutoLayout, AnsiClass, Class, Public' 1850 | $TypeBuilder = $ModuleBuilder.DefineType('ACLReportTools.Permission',$Attributes,[System.Object]) 1851 | $TypeBuilder.DefineField('ComputerName', [string], 'Public') | Out-Null 1852 | $TypeBuilder.DefineField('Type', $PermissionTypeEnumType, 'Public') | Out-Null 1853 | $TypeBuilder.DefineField('Share', [string], 'Public') | Out-Null 1854 | $TypeBuilder.DefineField('Path', [string], 'Public') | Out-Null 1855 | $TypeBuilder.DefineField('Owner', [string], 'Public') | Out-Null 1856 | $TypeBuilder.DefineField('Access', [Security2.FileSystemAccessRule2], 'Public') | Out-Null 1857 | $TypeBuilder.DefineField('Inherited', [string], 'Public') | Out-Null 1858 | $TypeBuilder.CreateType() | Out-Null 1859 | 1860 | # Define the ACLReportTools.Share Class 1861 | $Attributes = 'AutoLayout, AnsiClass, Class, Public' 1862 | $TypeBuilder = $ModuleBuilder.DefineType('ACLReportTools.Share',$Attributes,[System.Object]) 1863 | $TypeBuilder.DefineField('ComputerName', [string], 'Public') | Out-Null 1864 | $TypeBuilder.DefineField('Name', [string], 'Public') | Out-Null 1865 | $TypeBuilder.CreateType() | Out-Null 1866 | 1867 | # Define Permission Difference Enumeration 1868 | $EnumBuilder = $ModuleBuilder.DefineEnum('ACLReportTools.PermissionDiffEnum', 'Public', [Int]) 1869 | # Define values of the enum 1870 | $EnumBuilder.DefineLiteral('No Change', [Int]0) 1871 | $EnumBuilder.DefineLiteral('Computer Added', [Int]1) 1872 | $EnumBuilder.DefineLiteral('Computer Removed', [Int]2) 1873 | $EnumBuilder.DefineLiteral('Share Removed', [Int]3) 1874 | $EnumBuilder.DefineLiteral('Share Added', [Int]4) 1875 | $EnumBuilder.DefineLiteral('Permission Removed', [Int]5) 1876 | $EnumBuilder.DefineLiteral('Permission Added', [Int]6) 1877 | $EnumBuilder.DefineLiteral('Permission Rights Changed', [Int]7) 1878 | $EnumBuilder.DefineLiteral('Permission Access Control Changed', [Int]8) 1879 | $EnumBuilder.DefineLiteral('Owner Changed', [Int]9) 1880 | $EnumBuilder.DefineLiteral('Inheritance Changed', [Int]10) 1881 | $PermissionDiffEnumType = $EnumBuilder.CreateType() 1882 | 1883 | # Define the ACLReportTools.PermissionDiff Class 1884 | $Attributes = 'AutoLayout, AnsiClass, Class, Public' 1885 | $TypeBuilder = $ModuleBuilder.DefineType('ACLReportTools.PermissionDiff',$Attributes,[System.Object]) 1886 | $TypeBuilder.DefineField('ComputerName', [string], 'Public') | Out-Null 1887 | $TypeBuilder.DefineField('Type', $PermissionTypeEnumType, 'Public') | Out-Null 1888 | $TypeBuilder.DefineField('Share', [string], 'Public') | Out-Null 1889 | $TypeBuilder.DefineField('Path', [string], 'Public') | Out-Null 1890 | $TypeBuilder.DefineField('DiffType', $PermissionDiffEnumType, 'Public') | Out-Null 1891 | $TypeBuilder.DefineField('Difference', [String], 'Public') | Out-Null 1892 | $TypeBuilder.CreateType() | Out-Null 1893 | } # If 1894 | } # Function Initialize-Module 1895 | 1896 | 1897 | <# 1898 | .SYNOPSIS 1899 | This function creates an ACLReportTools.Share object and populates it. 1900 | 1901 | .DESCRIPTION 1902 | This function creates an ACLReportTools.Share object from the class definition in the dynamic module ACLREportsModule and assigns the function parameters to the field values of the object. 1903 | #> 1904 | function New-ShareObject 1905 | { 1906 | [CmdLetBinding()] 1907 | param 1908 | ( 1909 | [Parameter(Mandatory=$true)] 1910 | [ValidateNotNullOrEmpty()] 1911 | [String]$ComputerName, 1912 | 1913 | [Parameter(Mandatory=$true)] 1914 | [ValidateNotNullOrEmpty()] 1915 | [String]$ShareName 1916 | ) # Param 1917 | 1918 | $share_object = New-Object -TypeName 'ACLReportTools.Share' 1919 | $share_object.ComputerName = $ComputerName 1920 | $share_object.Name = $ShareName 1921 | return $share_object 1922 | } # function New-ShareObject 1923 | 1924 | 1925 | <# 1926 | .SYNOPSIS 1927 | This function creates an ACLReportTools.Permission object and populates it. 1928 | 1929 | .DESCRIPTION 1930 | This function creates an ACLReportTools.Permission object from the class definition in the dynamic module ACLREportsModule and assigns the function parameters to the field values of the object. 1931 | #> 1932 | function New-PermissionObject 1933 | { 1934 | [CmdLetBinding()] 1935 | param 1936 | ( 1937 | [Parameter(Mandatory=$true)] 1938 | [ACLReportTools.PermissionTypeEnum]$Type, 1939 | 1940 | [Parameter(Mandatory=$true)] 1941 | [ValidateNotNullOrEmpty()] 1942 | [String]$ComputerName, 1943 | 1944 | [String]$Path='', 1945 | 1946 | [String]$Share='', 1947 | 1948 | [String]$Owner='', 1949 | 1950 | [Parameter(Mandatory=$true)] 1951 | [ValidateNotNull()] 1952 | [Security2.FileSystemAccessRule2]$Access, 1953 | 1954 | [String]$Inherited='' 1955 | ) # Param 1956 | 1957 | # Need to correct the $Access objects to ensure the FileSystemRights values correctly converted to string 1958 | # When the "Generic Rights" bits are set: http://msdn.microsoft.com/en-us/library/aa374896%28v=vs.85%29.aspx 1959 | $permission_object = New-Object -TypeName 'ACLReportTools.Permission' 1960 | $permission_object.Type = $Type 1961 | $permission_object.ComputerName = $ComputerName 1962 | $permission_object.Path = $Path 1963 | $permission_object.Share = $Share 1964 | $permission_object.Owner = $Owner 1965 | $permission_object.Access = $Access 1966 | $permission_object.Inherited = $Inherited 1967 | return $permission_object 1968 | } # function New-PermissionObject 1969 | 1970 | 1971 | <# 1972 | .SYNOPSIS 1973 | This function creates an ACLReportTools.PermissionDiff object and populates it. 1974 | 1975 | .DESCRIPTION 1976 | This function creates an ACLReportTools.PermissionDiff object from the class definition in the dynamic module ACLREportsModule and assigns the function parameters to the field values of the object. 1977 | #> 1978 | function New-PermissionDiffObject 1979 | { 1980 | [CmdLetBinding()] 1981 | param 1982 | ( 1983 | [ACLReportTools.PermissionTypeEnum]$Type=([ACLReportTools.PermissionTypeEnum]::'Not Applicable'), 1984 | 1985 | [Parameter(Mandatory=$true)] 1986 | [ValidateNotNullOrEmpty()] 1987 | [String]$ComputerName, 1988 | 1989 | [String]$Path='', 1990 | 1991 | [String]$Share='', 1992 | 1993 | [ACLReportTools.PermissionDiffEnum]$DiffType=([ACLReportTools.PermissionDiffEnum]::'No Change'), 1994 | 1995 | [String]$Difference='' 1996 | ) # Param 1997 | 1998 | # Need to correct the $Access objects to ensure the FileSystemRights values correctly converted to string 1999 | # When the "Generic Rights" bits are set: http://msdn.microsoft.com/en-us/library/aa374896%28v=vs.85%29.aspx 2000 | $permissiondiff_object = New-Object -TypeName 'ACLReportTools.PermissionDiff' 2001 | $permissiondiff_object.Type = $Type 2002 | $permissiondiff_object.ComputerName = $ComputerName 2003 | $permissiondiff_object.Path = $Path 2004 | $permissiondiff_object.Share = $Share 2005 | $permissiondiff_object.DiffType = $DiffType 2006 | $permissiondiff_object.Difference = $Difference 2007 | return $permissiondiff_object 2008 | } # function New-PermissionDiffObject 2009 | 2010 | 2011 | <# 2012 | .SYNOPSIS 2013 | 2014 | .DESCRIPTION 2015 | #> 2016 | function Convert-FileSystemAppliesToString 2017 | { 2018 | [CmdLetBinding()] 2019 | param 2020 | ( 2021 | [Parameter(Mandatory=$true)] 2022 | [String]$InheritanceFlags, 2023 | [Parameter(Mandatory=$true)] 2024 | [String]$PropagationFlags 2025 | ) # Param 2026 | if ($PropagationFlags -eq 'None') 2027 | { 2028 | switch ($InheritanceFlags) 2029 | { 2030 | 'None' { return 'This folder only'; break } 2031 | 'ContainerInherit, ObjectInherit' { return 'This folder, subfolders and files'; break } 2032 | 'ContainerInherit' { return 'This folder and subfolders'; break } 2033 | 'ObjectInherit' { return 'This folder and files'; break } 2034 | } # Switch 2035 | } 2036 | else 2037 | { 2038 | switch ($InheritanceFlags) 2039 | { 2040 | 'ContainerInherit, ObjectInherit' { return 'Subfolders and files only'; break } 2041 | 'ContainerInherit' { return 'Subfolders only'; break } 2042 | 'ObjectInherit' { return 'Files only'; break } 2043 | } # Switch 2044 | } # If 2045 | return 'Unknown' 2046 | } # function Convert-FileSystemAppliesToString 2047 | 2048 | 2049 | <# 2050 | .SYNOPSIS 2051 | 2052 | .DESCRIPTION 2053 | #> 2054 | function Convert-AccessToString 2055 | { 2056 | [CmdLetBinding()] 2057 | param 2058 | ( 2059 | [Parameter(Mandatory=$true)] 2060 | [Object]$Access 2061 | ) # Param 2062 | [string]$rights=$Access.AccessRights 2063 | [string]$controltype=$Access.AccessControlType 2064 | [string]$IdentityReference=$Access.IdentityReference 2065 | [string]$IsInherited=$Access.IsInherited 2066 | [string]$AppliesTo=Convert-FileSystemAppliesToString -InheritanceFlags $Access.InheritanceFlags -PropagationFlags $Access.PropagationFlags 2067 | Return "AccessRights : $rights`nAccessControlType : $controltype`nIdentityReference : $IdentityReference`nIsInherited : $IsInherited`nAppliesTo : $AppliesTo`n" 2068 | } # function Convert-AccessToString 2069 | 2070 | 2071 | <# 2072 | .SYNOPSIS 2073 | 2074 | .DESCRIPTION 2075 | #> 2076 | function Convert-ACEToString 2077 | { 2078 | [CmdLetBinding()] 2079 | param 2080 | ( 2081 | [Parameter(Mandatory=$true)] 2082 | [Object]$ACE 2083 | ) # Param 2084 | [string]$path=$ACE.path 2085 | [string]$owner=$ACE.owner 2086 | [string]$acccessstring=Convert-ACEToString($ACE.access) 2087 | Return "Path : $path`nOwner : $owner`n$acccessstring" 2088 | } # function Convert-ACEToString 2089 | 2090 | 2091 | Function CreateHTMLReportHeader 2092 | { 2093 | param 2094 | ( 2095 | [Parameter(Mandatory=$true)] 2096 | [String]$Title 2097 | ) # Param 2098 | return $Script:Html_Header -f $Title 2099 | } # Function CreateHTMLReportHeader 2100 | 2101 | 2102 | Function CreateHTMLReportFooter 2103 | { 2104 | return $Script:Html_Footer 2105 | } # Function CreateHTMLReportFooter 2106 | 2107 | 2108 | Function CreateHTMLComputerNameLine 2109 | { 2110 | param 2111 | ( 2112 | [Parameter(Mandatory=$true)] 2113 | [String]$ComputerName 2114 | ) # Param 2115 | return $Script:Html_ComputerName -f $ComputerName 2116 | } # Function CreateHTMLComputerNameLine 2117 | 2118 | 2119 | Function CreateHTMLShareNameLine 2120 | { 2121 | param 2122 | ( 2123 | [Parameter(Mandatory=$true)] 2124 | [String]$ShareName 2125 | ) # Param 2126 | return $Script:Html_ShareName -f $ShareName 2127 | } # Function CreateHTMLShareNameLine 2128 | 2129 | 2130 | Function CreateHTMLPermissionDiffLine 2131 | { 2132 | param 2133 | ( 2134 | [Parameter(Mandatory=$true)] 2135 | [ACLReportTools.PermissionDiff]$PermissionDiff 2136 | ) # Param 2137 | 2138 | # This function takes a Permission Diff object and formats it as HTML for a report. 2139 | [string]$label = $PermissionDiff.Type.ToString() 2140 | [string]$class = $PermissionDiff.DiffType.ToString().ToLower() -replace ' ','' 2141 | [string]$html = $PermissionDiff.Difference 2142 | return $Script:Html_DifferenceLine -f $Label,$Class,$Html 2143 | } # Function CreateHTMLPermissionDiffLine 2144 | 2145 | 2146 | # Ensure all the custom classes are loaded in available 2147 | Initialize-Module 2148 | 2149 | 2150 | # Export the Module Cmdlets 2151 | Export-ModuleMember -Function ` 2152 | New-ACLShareReport,` 2153 | New-ACLPathFileReport, ` 2154 | Import-ACLReport,` 2155 | Export-ACLReport,` 2156 | Import-ACLDiffReport,` 2157 | Export-ACLDiffReport,` 2158 | Compare-ACLReports,` 2159 | Get-ACLShare,` 2160 | Get-ACLShareACL,` 2161 | Get-ACLPathFileACL,` 2162 | Get-ACLShareFileACL,` 2163 | Import-ACLPermission,` 2164 | Export-ACLPermission,` 2165 | Import-ACLPermissionDiff,` 2166 | Export-ACLPermissionDiff,` 2167 | Export-ACLPermissionDiffHTML 2168 | -------------------------------------------------------------------------------- /ACLReportTools.pssproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | 2.0 6 | 6CAFC0C6-A428-4d30-A9F9-700E829FEA51 7 | Exe 8 | MyApplication 9 | MyApplication 10 | ACLReportTools 11 | 12 | 13 | true 14 | full 15 | false 16 | bin\Debug\ 17 | DEBUG;TRACE 18 | prompt 19 | 4 20 | 21 | 22 | pdbonly 23 | true 24 | bin\Release\ 25 | TRACE 26 | prompt 27 | 4 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ACLReportTools.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F5034706-568F-408A-B7B3-4D38C6DB8A32}") = "ACLReportTools", "ACLReportTools.pssproj", "{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /ACLReportTools.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlagueHO/ACLReportTools/285c0af85cefccc059b4294c77bedc53ea60a201/ACLReportTools.v12.suo -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ACLReportTools 2 | ============== 3 | This module contains functions for creating reports on file, folder and share ACL's, storing the reports and comparing them with earlier reports. 4 | 5 | Requirements 6 | ------------ 7 | > PowerShell 2.0 8 | 9 | Overview 10 | -------- 11 | The intended purpose of this module is to allow an Admininstrator to report on how ACL's for a set of path or shares have changed since a baseline was last created. 12 | 13 | Basically it allows administrators to easily see what ACL changes are being made so they keep an eye on any security issues arising. 14 | The process of creating/updating the baseline and producing the ACL Difference report could be easily automated. 15 | If performing SMB share comparisons, the report generation can be performed remotely (from a desktop PC for example). 16 | 17 | The process that is normally followed using this module is: 18 | 19 | 1. Produce a baseline ACL Report from a set of Folders or Shares (even on multiple computers). 20 | 2. Export the baseline ACL Report as a file. 21 | 3. ... Sometime later ... 22 | 4. Import the baseline ACL Report from a stored file. 23 | 5. Produce a ACL Difference report comparing the imported baseline ACL Report with the current ACL state of the Folders or Shares. 24 | 6. Optionally export the ACL Difference report as HTML. 25 | 7. Repeat from step 1. 26 | 27 | The above process could be easily automated in many ways (Task Scheduler is suggested). 28 | 29 | The comparison is always performed recursively scanning a specified set of folders or SMB shares. 30 | All files and folders within these locations will be scanned, but only non-inherited ACLs will be added to the ACL Reports. 31 | 32 | Definitions 33 | ----------- 34 | ### ACL Report 35 | An **ACL report** is a list of the current ACLs for a set of Shares or Folders. 36 | It is stored as a serialized array of [ACLReportTools.Permission] objects that are returned by the New-ACLShareReport, New-ACLPathFileReport and Import-ACLReport cmdlets. 37 | 38 | ACL Reports produced for Shares rather than folders differ in that the Share name is provided in each [ACLReportTools.Permission] object and that the SMB Share ACL is also provided in the [ACLReportTools.Permission] array. 39 | 40 | ### ACL Difference Report 41 | An **ACL Difference report** is a list of all ACL differences between two ACL reports. 42 | It is stored as serialized array of [ACLReportTools.PermissionDiff] objects that are produced by the Compare-ACLReports cmdlet. 43 | 44 | 45 | Important Notes 46 | --------------- 47 | When performing a comparison, make sure the baseline report used covers the same set of folders/shares you want to compare now. 48 | E.g. Don't try and compare ACLs for c:\windows and c:\wwwroot - that would make no sense. 49 | 50 | If shares or folders that are being compared have large numbers of non-inherited ACLs (perhaps because some junior admin doesn't understand inheritance) then a comparison can take a LONG time (hours) and really hog your CPU. If this is the case, run on another machine using Share mode or run after hours - or better yet, teach junior admins about inheritance! :) 51 | 52 | This Module uses the awesome NTFS Security Module available here: 53 | 54 | https://gallery.technet.microsoft.com/scriptcenter/1abd77a5-9c0b-4a2b-acef-90dbb2b84e85 55 | 56 | Ensure that you unblock all files in the NTFSSecurity module before attempting to Import Module ACLReportTools. 57 | Module ACLReportTools automatically looks for and Imports NTFSSecuriy if present. 58 | If it is missing an error will be reported stating that it is missing. 59 | If you recieve any other errors loading ACL Report tools, it is usually because some of the NTFSSecurity module files are blocked and need to be unblocked manually or with Unblock-File. 60 | You can confirm this by calling Import-Module NTFSSecurity - if any errors appear then it is most likely the cause. After unblocking the module files you may need to restart PowerShell. 61 | 62 | You should also ensure that the account that is being used to generate the reports has read access to all paths (recursively) you are reporting on and can access also read the ACLs. 63 | If it can't access them then you may get access denied errors. 64 | 65 | Installation 66 | ------------ 67 | * Installation if WMF5.0 is Installed: 68 | 1. In PowerShell execute: 69 | ```powershell 70 | Install-Module ACLReportTools 71 | ``` 72 | 73 | * Installation if WMF5.0 is Not Installed: 74 | 1. Unzip the archive containing the ACLReportTools module into the one of the PowerShell Modules folders. 75 | E.g. c:\program files\windowspowershell\modules 76 | 2. This will create a folder called ACLReportTools containing all the files required for this module. 77 | 3. In PowerShell execute: 78 | ```powershell 79 | Import-Module ACLReportTools 80 | ``` 81 | 82 | Example Usage 83 | ------------- 84 | ### Example Usage: Creating a Baseline ACL Report file from non-inherited permissions only from files and folders 85 | This example creates a baseline ACL Report on the folders e:\work and d:\profiles and stores it in the Baseline.acl file in the current users Documents folder. It will include only non-inherited permissions. 86 | ```powershell 87 | Import-Module ACLReportTools 88 | New-ACLPathFileReport -Path "e:\Work","d:\Profiles" | Export-ACLReport -Path "$HOME\Documents\Baseline.acl" -Force 89 | ``` 90 | 91 | 92 | ### Example Usage: Comparing a Baseline ACL Report file with the current non-inherited permissions only from current file and folder ACLs 93 | This example compares the previously created baseline ACL Report stored in the users Documents folder and compares it with the current ACLs for the folders e:\Work and d:\Profiles. It will include only non-inherited permissions. 94 | ```powershell 95 | Import-Module ACLReportTools 96 | Compare-ACLReports -Baseline (Import-ACLReport -Path "$HOME\Documents\Baseline.acl") -Path "e:\Work","d:\Profiles" 97 | ``` 98 | 99 | 100 | ### Example Usage: Creating a Baseline ACL Report file from inherited and non-inherited permissions only from files and folders 101 | This example creates a baseline ACL Report on the folders e:\work and d:\profiles and stores it in the Baseline.acl file in the current users Documents folder. It will include inherited and non-inherited permissions. 102 | ```powershell 103 | Import-Module ACLReportTools 104 | New-ACLPathFileReport -Path "e:\Work","d:\Profiles" -IncudeInherited | Export-ACLReport -Path "$HOME\Documents\Baseline.acl" -Force 105 | ``` 106 | 107 | 108 | ### Example Usage: Comparing a Baseline ACL Report file with the current inherited and non-inherited permissions only from current file and folder ACLs 109 | This example compares the previously created baseline ACL Report stored in the users Documents folder and compares it with the current ACLs for the folders e:\Work and d:\Profiles. It will include inherited and non-inherited permissions. 110 | ```powershell 111 | Import-Module ACLReportTools 112 | Compare-ACLReports -Baseline (Import-ACLReport -Path "$HOME\Documents\Baseline.acl") -Path "e:\Work","d:\Profiles" -IncudeInherited 113 | ``` 114 | 115 | 116 | ### Example Usage: Creating a Baseline ACL Report file from non-inherited permissions only from shares 117 | This example creates a baseline ACL Report on the shares \\client\Share1\ and \\client\Share2\ and stores it in the Baseline.acl file in the current users Documents folder. It will include only non-inherited permissions. 118 | ```powershell 119 | Import-Module ACLReportTools 120 | New-ACLShareReport -ComputerName Client -Include Share1,Share2 | Export-ACLReport -Path "$HOME\Documents\Baseline.acl" -Force 121 | ``` 122 | 123 | 124 | ### Example Usage: Comparing a Baseline ACL Report file with the current non-inherited permissions only from current shares ACLs 125 | This example compares the previously created baseline ACL Report stored in the users Documents folder and compares it with the current ACLs for the shares \\client\Share1\ and \\client\Share2\. It will include only non-inherited permissions. 126 | ```powershell 127 | Import-Module ACLReportTools 128 | Compare-ACLReports -Baseline (Import-ACLReport -Path "$HOME\Documents\Baseline.acl") -ComputerName Client -Include Share1,Share2 129 | ``` 130 | 131 | 132 | ### Example Usage: Creating a Baseline ACL Report file from inherited and non-inherited permissions only from shares 133 | This example creates a baseline ACL Report on the shares \\client\Share1\ and \\client\Share2\ and stores it in the Baseline.acl file in the current users Documents folder. It will include inherited and non-inherited permissions. 134 | ```powershell 135 | Import-Module ACLReportTools 136 | New-ACLShareReport -ComputerName Client -Include Share1,Share2 | Export-ACLReport -Path "$HOME\Documents\Baseline.acl" -Force -IncudeInherited 137 | ``` 138 | 139 | 140 | ### Example Usage: Comparing a Baseline ACL Report file with the current inherited and non-inherited permissions only from current shares ACLs 141 | This example compares the previously created baseline ACL Report stored in the users Documents folder and compares it with the current ACLs for the shares \\client\Share1\ and \\client\Share2\. It will include inherited and non-inherited permissions. 142 | ```powershell 143 | Import-Module ACLReportTools 144 | Compare-ACLReports -Baseline (Import-ACLReport -Path "$HOME\Documents\Baseline.acl") -ComputerName Client -Include Share1,Share2 -IncudeInherited 145 | ``` 146 | 147 | 148 | ### Example Usage: Exporting a Difference Report as an HTML File 149 | This example takes the output of the Compare-ACLReports cmdlet and formats it as HTML and saves it for easier review and storage. 150 | ```powershell 151 | Import-Module ACLReportTools 152 | Compare-ACLReports -Baseline (Import-ACLReport -Path "$HOME\Documents\Baseline.acl") -ComputerName Client -Include Share1,Share2 | Export-ACLPermissionDiffHTML -Path "$HOME\Documents\Difference.htm" 153 | ``` 154 | 155 | 156 | CmdLets 157 | ------- 158 | ### New-ACLShareReport 159 | #### SYNOPSIS 160 | Creates a list of Share, File and Folder ACLs for the specified shares/computers. 161 | 162 | #### DESCRIPTION 163 | Produces an array of [ACLReportTools.Permission] objects for the computers provided. Specific shares can be specified or excluded using the Include/Exclude parameters. 164 | 165 | The report can be stored for use as a comparison in either a variable or as a file using the Export-ACLReport cmdlet (found in this module). For example: 166 | 167 | ```powershell 168 | New-ACLShareReport -ComputerName CLIENT01 -Include MyShare,OtherShare | Export-ACLReport -path c:\ACLReports\CLIENT01_2014_11_14.acl 169 | ``` 170 | 171 | #### PARAMETER ComputerName 172 | This is the computer(s) to create the ACL Share report for. The Computer names can also be passed in via the pipeline. 173 | 174 | #### PARAMETER Include 175 | This is a list of shares to include from the report. If this parameter is not set it will default to including all shares. This parameter can't be set if the Exclude parameter is set. 176 | 177 | #### PARAMETER Exclude 178 | This is a list of shares to exclude from the report. If this parameter is not set it will default to excluding no shares. This parameter can't be set if the Include parameter is set. 179 | 180 | #### PARAMETER IncludeInherited 181 | Setting this switch will cause the non inherited file/folder ACLs to be pulled recursively. 182 | 183 | #### EXAMPLE 184 | ```powershell 185 | New-ACLShareReport -ComputerName CLIENT01 186 | ``` 187 | Creates a report of all the Share and file/folder ACLs on the CLIENT01 machine. 188 | 189 | #### EXAMPLE 190 | ```powershell 191 | New-ACLShareReport -ComputerName CLIENT01 -Include MyShare,OtherShare 192 | ``` 193 | Creates a report of all the Share and file/folder ACLs on the CLIENT01 machine that are in shares named either MyShare or OtherShare. 194 | 195 | #### EXAMPLE 196 | ```powershell 197 | New-ACLShareReport -ComputerName CLIENT01 -Exclude SysVol 198 | ``` 199 | Creates a report of all the Share and file/folder ACLs on the CLIENT01 machine that are in shares not named SysVol. 200 | 201 | 202 | ### New-ACLPathFileReport 203 | #### SYNOPSIS 204 | Creates a list of File and Folder ACLs for the provided path(s). 205 | 206 | #### DESCRIPTION 207 | Produces an array of [ACLReportTools.Permission] objects for the list of paths provided. 208 | 209 | The report can be stored for use as a comparison in either a variable or as a file using the Export-ACLReport cmdlet (found in this module). For example: 210 | 211 | ```powershell 212 | New-ACLPathFileReport -Path e:\public | Export-ACLReport -path c:\ACLReports\Public_2015-04-04.acl 213 | ``` 214 | 215 | #### PARAMETER Path 216 | This is the path(s) to create the ACL PathFile report for. 217 | 218 | #### PARAMETER IncludeInherited 219 | Setting this switch will cause the non inherited file/folder ACLs to be pulled recursively. 220 | 221 | #### EXAMPLE 222 | ```powershell 223 | New-ACLPathFileReport -Path e:\public 224 | ``` 225 | Creates a report of all the file/folder ACLs in the e:\public folder on this machine. 226 | 227 | 228 | ### Export-ACLReport 229 | #### SYNOPSIS 230 | Export an ACL Report as a file. 231 | 232 | #### DESCRIPTION 233 | This Cmdlet will save whatever ACL Report that is in the pipeline to a file. 234 | 235 | This cmdlet just calls Export-ACLPermission although at some point will add additional functionality. 236 | 237 | #### PARAMETER Path 238 | This is the path to the ACL Permission Report output file. This parameter is required. 239 | 240 | #### PARAMETER InputObject 241 | Specifies the Permissions objects to export to the file. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.Permission objects to this cmdlet. 242 | 243 | #### PARAMETER Force 244 | Causes the file to be overwritten if it exists. 245 | 246 | #### EXAMPLE 247 | ```powershell 248 | New-ACLShareReport -ComputerName CLIENT01 -Include MyShare,OtherShare | Export-ACLReport -path c:\ACLReports\CLIENT01_2014_11_14.acl 249 | ``` 250 | Creates a new ACL Share Report for Computer Client01 for the MyShare and OtherShares and exports it to the file C:\ACLReports\CLIENT01_2014_11_14.acl. 251 | 252 | #### EXAMPLE 253 | ```powershell 254 | Export-ACLReport -Path C:\ACLReports\server01.acl -InputObject $ShareReport 255 | ``` 256 | Saves the ACLs in the $ShareReport variable to the file C:\ACLReports\server01.acl. 257 | 258 | #### EXAMPLE 259 | ```powershell 260 | Export-ACLReport -Path C:\ACLReports\server01.acl -InputObject (New-ACLShareReport -ComputerName SERVER01) -Force 261 | ``` 262 | Saves the file ACLs for all shares on the compuer SERVER01 to the file C:\ACLReports\server01.acl. If the file exists it will be overwritten. 263 | 264 | #### EXAMPLE 265 | ```powershell 266 | New-ACLShareReport -ComputerName SERVER01 | Export-ACLReport -Path C:\ACLReports\server01.acl -Force 267 | ``` 268 | Saves the file ACLs for all shares on the compuer SERVER01 to the file C:\ACLReports\server01.acl. If the file exists it will be overwritten. 269 | 270 | 271 | ### Import-ACLReport 272 | #### SYNOPSIS 273 | Import the ACL Report that is in a file. 274 | 275 | #### DESCRIPTION 276 | This Cmdlet will import all the ACL Report (ACLReportTools.Permission) objects from a specified file into the pipeline. 277 | 278 | This cmdlet just calls Import-ACLPermission although at some point will add additional functionality. 279 | 280 | #### PARAMETER Path 281 | This is the path to the ACL Permission Report file to import. This parameter is required. 282 | 283 | #### EXAMPLE 284 | ```powershell 285 | Import-ACLReport -Path C:\ACLReports\server01.acl 286 | ``` 287 | Imports the ACL Share Report from the file C:\ACLReports\server01.acl and puts it into the pipeline 288 | 289 | 290 | ### Export-ACLDiffReport 291 | #### SYNOPSIS 292 | Export an ACL Permission Diff Report as a file. 293 | 294 | #### DESCRIPTION 295 | This Cmdlet will save whatever ACL Permission Diff Report that is in the pipeline to a file. 296 | 297 | This cmdlet just calls Export-ACLPermissionDiff although at some point will add additional functionality. 298 | 299 | #### PARAMETER Path 300 | This is the path to the ACL Permission Diff Report output file. This parameter is required. 301 | 302 | #### PARAMETER InputObject 303 | Specifies the Permissions objects to export to the file. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.PermissionDiff objects to Export-ACLReport. 304 | 305 | #### PARAMETER Force 306 | Causes the file to be overwritten if it exists. 307 | 308 | #### EXAMPLE 309 | ```powershell 310 | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) -With (Get-ACLReport -ComputerName CLIENT01) | Export-ACLDiffReport -Path "$HOME\Documents\Compare.acr" 311 | ``` 312 | This will perform a comparison of the current share ACL report from computer CLIENT01 with the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl and then export the report file 313 | to $HOME\Documents\Compare.acr 314 | 315 | 316 | ### Import-ACLDiffReport 317 | #### SYNOPSIS 318 | Import the ACL Difference Report that is in a file. 319 | 320 | #### DESCRIPTION 321 | This Cmdlet will import all the ACL Difference Report (ACLReportTools.PermissionDiff) objects from a specified file into the pipeline. 322 | 323 | This cmdlet just calls Import-ACLPermissionDiff although at some point will add additional functionality. 324 | 325 | #### PARAMETER Path 326 | This is the path to the ACL Permission Report file to import. This parameter is required. 327 | 328 | #### EXAMPLE 329 | ```powershell 330 | Import-ACLDiffReport -Path C:\ACLReports\server01.acr 331 | ``` 332 | Imports the ACL Share Report from the file C:\ACLReports\server01Permission and puts it into the pipeline 333 | 334 | 335 | ### Compare-ACLReports 336 | #### SYNOPSIS 337 | Compares two ACL reports and produces an ACL Difference report. 338 | 339 | #### DESCRIPTION 340 | This cmdlets compares two ACL Share reports and produces a difference list in the pipeline that can then be reported on. 341 | 342 | A baseline report (usually from importing a previous ACL Share Report) must be provided. The second ACL Share report (called the current ACL Share report) will be compared against the baseline report. 343 | The current ACL report will be either generated by the New-ACLShareReport or New-ACLPathFileReport cmdlets (depending on parameters) or it can be passed in via the With variable. 344 | 345 | #### PARAMETER Baseline 346 | This is the baseline report data the comparison will focus on. It will usually be pulled in from a previously saved Share ACL report via the Import-ACLReports 347 | 348 | #### PARAMETER ComputerName 349 | This is the computer(s) to generate the current list of Share ACLs for to perform the comparison with the baseline. The Computer names can also be passed in via the pipeline. 350 | 351 | This parameter should not be used if the With Parameter is provided. 352 | 353 | #### PARAMETER Include 354 | This is a list of shares to include from the comparison. If this parameter is not set it will default to including all shares. This parameter can't be set if the Exclude parameter is set. 355 | 356 | This parameter should not be used if the With Parameter is provided. 357 | 358 | #### PARAMETER Exclude 359 | This is a list of shares to exclude from the comparison. If this parameter is not set it will default to excluding no shares. This parameter can't be set if the Include parameter is set. 360 | 361 | This parameter should not be used if the With Parameter is provided. 362 | 363 | #### PARAMETER With 364 | This parameter provides an ACL Share report to compare with the Baseline ACL Share report. 365 | 366 | This parameter should not be used if the ComputerName Parameter is provided. 367 | 368 | #### PARAMETER ReportNoChange 369 | Setting this switch will cause a 'No Change' report item to be shown when a share is identical in both the baseline and current reports. 370 | 371 | #### PARAMETER IncludeInherited 372 | Setting this switch will cause the non inherited file/folder ACLs to be pulled recursively. 373 | 374 | #### EXAMPLE 375 | ```powershell 376 | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) -With (Get-ACLReport -ComputerName CLIENT01) 377 | ``` 378 | This will perform a comparison of the current share ACL report from computer CLIENT01 with the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl 379 | 380 | #### EXAMPLE 381 | ```powershell 382 | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) -ComputerName CLIENT01 383 | ``` 384 | This will perform a comparison of the current share ACL report from computer CLIENT01 with the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl 385 | 386 | #### EXAMPLE 387 | ```powershell 388 | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14_SHARE01_ONLY.acl) -ComputerName CLIENT01 -Include SHARE01 389 | ``` 390 | This will perform a comparison of the current share ACL report from computer CLIENT01 for only SHARE01 with the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14_SHARE01_ONLY.acl 391 | 392 | #### EXAMPLE 393 | ```powershell 394 | "CLIENT01" | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) 395 | ``` 396 | This will perform a comparison of the current share ACL report from computer CLIENT01 with the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl 397 | 398 | #### EXAMPLE 399 | ```powershell 400 | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_11_14.acl) -With (Import-ACLReports -Path c:\ACLReports\CLIENT01_2014_06_01.acl) 401 | ``` 402 | This will perform a comparison of the share ACL report in file c:\ACLReports\CLIENT01_2014_06_01.acl with the stored share ACL report in file c:\ACLReports\CLIENT01_2014_11_14.acl 403 | 404 | 405 | ### Export-ACLPermission 406 | #### SYNOPSIS 407 | Export the ACL Permissions objects that are provided as a file. 408 | 409 | #### DESCRIPTION 410 | This Cmdlet will save what ever ACLs (ACLReportTools.Permission) to a file. 411 | 412 | #### PARAMETER Path 413 | This is the path to the ACL Permissions file output file. This parameter is required. 414 | 415 | #### PARAMETER InputObject 416 | Specifies the ACL Permissions objects to export to the file. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.Permission objects to cmdlet. 417 | 418 | #### PARAMETER Force 419 | Causes the file to be overwritten if it exists. 420 | 421 | #### EXAMPLE 422 | ```powershell 423 | New-ACLPathFileReport -Path e:\Shares | Export-ACLPermission -Path C:\ACLReports\server01.acl 424 | ``` 425 | Creates a new ACL Permission report for e:\Shares and saves it to the file C:\ACLReports\server01.acl. 426 | 427 | #### EXAMPLE 428 | ```powershell 429 | Export-ACLPermission -Path C:\ACLReports\server01.acl -InputObject $Acls 430 | ``` 431 | Saves the ACL Permissions in the $Acls variable to the file C:\ACLReports\server01.acl. 432 | 433 | #### EXAMPLE 434 | ```powershell 435 | Export-ACLPermission -Path C:\ACLReports\server01.acl -InputObject (Get-ACLShare -ComputerName SERVER01 | Get-ACLShareFileACL -Recurse) 436 | ``` 437 | Saves the file ACLs for all shares on the compuer SERVER01 to the file C:\ACLReports\server01.acl. 438 | 439 | 440 | ### Import-ACLPermission 441 | #### SYNOPSIS 442 | Import the a File containing serialized ACL Permission objects that are in a file back into the pipeline. 443 | 444 | #### DESCRIPTION 445 | This Cmdlet will load all the ACLs (ACLReportTools.Permission) records from a specified file. 446 | 447 | #### PARAMETER Path 448 | This is the path to the file containing ACL Permission objects. This parameter is required. 449 | 450 | #### EXAMPLE 451 | ```powershell 452 | Import-ACLPermission -Path C:\ACLReports\server01.acl 453 | ``` 454 | Loads the ACLs in the file C:\ACLReports\server01.acl. 455 | 456 | 457 | ### Export-ACLPermissionDiff 458 | #### SYNOPSIS 459 | Export the ACL Difference Objects that are provided as a file. 460 | 461 | #### DESCRIPTION 462 | This Cmdlet will export an array of provided Permission Difference [ACLReportTools.PermissionDiff] records to a file. 463 | 464 | #### PARAMETER Path 465 | This is the path to the ACL Permission Diff file. This parameter is required. 466 | 467 | #### PARAMETER InputObject 468 | Specifies the Permissions objects to export to th file. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.PermissionDiff objects to this cmdlet. 469 | 470 | #### PARAMETER Force 471 | Causes the file to be overwritten if it exists. 472 | 473 | #### EXAMPLE 474 | ```powershell 475 | Export-ACLPermissionDiff -Path C:\ACLReports\server01.acr -InputObject $DiffReport 476 | ``` 477 | Saves the ACL Difference objects in the $DiffReport variable to the file C:\ACLReports\server01.acr. If the file exists it will be overwritten if the Force switch is set. 478 | 479 | 480 | ### Import-ACLPermissionDiff 481 | #### SYNOPSIS 482 | Import the a File containing serialized ACL Permission Diff objects that are in a file back into the pipeline. 483 | 484 | #### DESCRIPTION 485 | This Cmdlet will load all the ACLs (ACLReportTools.PermissionDiff) records from a specified file. 486 | 487 | #### PARAMETER Path 488 | This is the path to the file containing ACL Permission Diff objects. This parameter is required. 489 | 490 | #### EXAMPLE 491 | ```powershell 492 | Import-ACLPermissionDiff -Path C:\ACLReports\server01.acr 493 | ``` 494 | Loads the ACL Permission Diff objects in the file C:\ACLReports\server01.acr. 495 | 496 | 497 | ### Export-ACLPermissionDiffHTML 498 | #### SYNOPSIS 499 | Export the ACL Difference Objects that are provided as an HTML file. 500 | 501 | #### DESCRIPTION 502 | This Cmdlet will export an array of provided Permission Difference [ACLReportTools.PermissionDiff] records to an HTML file for easy viewing and reporting. 503 | 504 | #### PARAMETER Path 505 | This is the path to the HTML output file. This parameter is required. 506 | 507 | #### PARAMETER InputObject 508 | Specifies the Permissions DIff objects to export to the as HTML. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe ACLReportTools.PermissionDiff objects to this cmdlet. 509 | 510 | #### PARAMETER Force 511 | Causes the file to be overwritten if it exists. 512 | 513 | #### PARAMETER Title 514 | Optional Title text to write into the report. 515 | 516 | #### EXAMPLE 517 | ```powershell 518 | Compare-ACLReports -Baseline (Import-ACLReports -Path c:\ACLReports\server01.acl) -With (Get-ACLReport -ComputerName Server01) | Export-ACLPermissionDiffHTML -Path C:\ACLReports\server01.htm 519 | ``` 520 | Performs a comparison using the Baseline file c:\ACLReports\Server01.acl and the shares on Server01 and outputs ACL Difference Report as an HTML file. 521 | 522 | 523 | ### Get-ACLShare 524 | #### SYNOPSIS 525 | Gets a list of the Shares on a specified computer(s) with specified inclusions or exclusions. 526 | 527 | #### DESCRIPTION 528 | This function will pull a list of shares that are set up on the specified computer. Shares can also be included or excluded from the share list by setting the Include or Exclude properties. 529 | 530 | The Cmdlet returns an array of ACLReportTools.Share objects. 531 | 532 | #### PARAMETER ComputerName 533 | This is the computer to get the shares from. If this parameter is not set it will default to the current machine. 534 | 535 | #### PARAMETER Include 536 | This is a list of shares to include from the computer. If this parameter is not set it will default to including all shares. This parameter can't be set if the Exclude parameter is set. 537 | 538 | #### PARAMETER Exclude 539 | This is a list of shares to exclude from the computer. If this parameter is not set it will default to excluding no shares. This parameter can't be set if the Include parameter is set. 540 | 541 | #### EXAMPLE 542 | ```powershell 543 | Get-ACLShare -ComputerName CLIENT01 544 | ``` 545 | Returns a list of all shares set up on the CLIENT01 machine. 546 | 547 | #### EXAMPLE 548 | ```powershell 549 | Get-ACLShare -ComputerName CLIENT01 -Include MyShare,OtherShare 550 | ``` 551 | Returns a list of shares that are set up on the CLIENT01 machine that are named either MyShare or OtherShare. 552 | 553 | #### EXAMPLE 554 | ```powershell 555 | Get-ACLShare -ComputerName CLIENT01 -Exclude SysVol 556 | ``` 557 | Returns a list of shares that are set up on the CLIENT01 machine that are not called SysVol. 558 | 559 | #### EXAMPLE 560 | ```powershell 561 | Get-ACLShare -ComputerName CLIENT01,CLIENT02 562 | ``` 563 | Returns a list of shares that are set up on the CLIENT01 and CLIENT02 machines. 564 | 565 | #### EXAMPLE 566 | ```powershell 567 | Get-ACLShare -ComputerName CLIENT01,CLIENT02 -Exclude SysVol 568 | ``` 569 | Returns a list of shares that are set up on the CLIENT01 and CLIENT02 machines that are not called SysVol. 570 | 571 | 572 | ### Get-ACLShareACL 573 | #### SYNOPSIS 574 | Gets the ACLs for a specified Share. 575 | 576 | #### DESCRIPTION 577 | This function will return the share ACLs for the specified share. 578 | 579 | #### PARAMETER ComputerName 580 | This is the computer to get the share ACLs from. If this parameter is not set it will default to the current machine. 581 | 582 | #### PARAMETER ShareName 583 | This is the share name to pull the share ACLs for. 584 | 585 | #### PARAMETER Shares 586 | This is a pipeline parameter that should be used for passing in a list of shares and computers to pull ACLs for. This parameter expects an array of [ACLReportTools.Share] objects. 587 | 588 | This parameter is usually used with the Get-ACLShare CmdLet. 589 | 590 | For example: 591 | 592 | ```powershell 593 | Get-ACLShare -ComputerName CLIENT01,CLIENT02 -Exclude SYSVOL | Get-ACLShareACL 594 | ``` 595 | 596 | #### EXAMPLE 597 | ```powershell 598 | Get-ACLShareACL -ComputerName CLIENT01 -ShareName MyShre 599 | ``` 600 | Returns the share ACLs for the MyShare Share on the CLIENT01 machine. 601 | 602 | 603 | ### Get-ACLShareFileACL 604 | #### SYNOPSIS 605 | Gets all the file/folder ACLs definited within a specified Share. 606 | 607 | #### DESCRIPTION 608 | This function will return a list of file/folder ACLs for the specified share. If the Recurse switch is used then files/folder ACLs will be scanned recursively. If the IncludeInherited switch is set then inherited file/folder permissions will also be returned, otherwise only non-inherited permissions will be returned. 609 | 610 | #### PARAMETER ComputerName 611 | This is the computer to get the share ACLs from. If this parameter is not set it will default to the current machine. 612 | 613 | #### PARAMETER ShareName 614 | This is the share name to pull the file/folder ACLs for. 615 | 616 | #### PARAMETER Recurse 617 | Setting this switch will cause the file/folder ACLs to be pulled recursively. 618 | 619 | #### PARAMETER IncludeInherited 620 | Setting this switch will cause the non inherited file/folder ACLs to be pulled recursively. 621 | 622 | #### EXAMPLE 623 | ```powershell 624 | Get-ACLShareFileACL -ComputerName CLIENT01 -ShareName MyShare 625 | ``` 626 | Returns the file/folder ACLs for the root of MyShare Share on the CLIENT01 machine. 627 | 628 | #### EXAMPLE 629 | ```powershell 630 | Get-ACLShareFileACL -ComputerName CLIENT01 -ShareName MyShare -Recurse 631 | ``` 632 | Returns the file/folder ACLs for all files/folders recursively inside the MyShare Share on the CLIENT01 machine. 633 | 634 | 635 | ### Get-ACLPathFileACL 636 | #### SYNOPSIS 637 | Gets all the file/folder ACLs defined within a specified Path. 638 | 639 | #### DESCRIPTION 640 | This function will return a list of file/folder ACLs for the specified share. If the Recurse switch is used then files/folder ACLs will be scanned recursively. If the IncludeInherited switch is set then inherited file/folder permissions will also be returned, otherwise only non-inherited permissions will be returned. 641 | 642 | #### PARAMETER Path 643 | This is the path to pull the file/folder ACLs for. 644 | 645 | #### PARAMETER Recurse 646 | Setting this switch will cause the file/folder ACLs to be pulled recursively. 647 | 648 | #### PARAMETER IncludeInherited 649 | Setting this switch will cause the non inherited file/folder ACLs to be pulled recursively. 650 | 651 | #### EXAMPLE 652 | ```powershell 653 | Get-ACLPathFileACL -Path C:\Users 654 | ``` 655 | Returns the file/folder ACLs for the root of C:\Users folder. 656 | 657 | #### EXAMPLE 658 | ```powershell 659 | Get-ACLPathFileACL -Path C:\Users -Recurse 660 | ``` 661 | Returns the file/folder ACLs for all files/folders recursively inside the C:\Users folder. 662 | 663 | 664 | Versions 665 | -------- 666 | ### 1.30.1.0 667 | * 2016-05-21: Changed module init to check NTFSSecurity module version is v4.0.0 or above. 668 | 669 | ### 1.30.0.0 670 | * 2016-02-09: Moved to new repo. 671 | * 2016-02-09: Updated to support NTFSSecurity 4.0.0.0 module and above. 672 | * 2016-02-09: Added IncludeInherited switch to some cmdlets. 673 | * 2016-02-09: Documentation updated. 674 | 675 | ### 1.21.0.0 676 | * 2015-05-13: Added Cmdlet for Exporting Diff Report as HTML 677 | 678 | ### 1.2.0.0 679 | * 2015-05-13: Added Cmdlets for Importing/Exporting Permission Difference reports. 680 | 681 | ### 1.1.0.0 682 | * 2015-05-12: Updated to use NTFSSecurity Module Updated CmdLet names to follow standards 683 | 684 | ### 1.0.0.0 685 | * 2015-05-09: Initial Version 686 | 687 | Links 688 | ----- 689 | * **[GitHub Repo](https://github.com/PlagueHO/ACLReportTools)**: Raise any issues, requests or PRs here. 690 | * **[My Blog](https://dscottraynsford.wordpress.com)**: See my PowerShell and Programming Blog. -------------------------------------------------------------------------------- /Tests/Integration/ACLReportTools.Tests.ps1: -------------------------------------------------------------------------------- 1 | #region HEADER 2 | [String] $Global:ModuleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)) 3 | 4 | # Import Module 5 | Import-Module -Name (Join-Path -Path $Global:ModuleRoot -ChildPath 'ACLReportTools.psm1') -Force 6 | 7 | # Create the artifact path 8 | [String] $Global:ArtifactPath = Join-Path -Path $moduleRoot -ChildPath 'Artifacts' 9 | $null = New-Item ` 10 | -Path $Global:ArtifactPath ` 11 | -ItemType Directory ` 12 | -Force ` 13 | -ErrorAction SilentlyContinue 14 | 15 | Write-Verbose -Message "Preparing for integration test run" 16 | 17 | [String] $Global:TestPath = Join-Path -Path $env:Temp -ChildPath ([System.IO.Path]::GetRandomFileName()) 18 | [Int] $Global:MaxShares = 4 # Must be 4 or greater 19 | [String] $Global:FileSourceFolder = Join-Path -Path $env:SystemRoot -ChildPath 'System32\Sysprep' 20 | If (-not (Test-Path -Path $Global:TestPath -PathType Container)) { 21 | Write-Verbose -Message "Creating test path '$($Global:TestPath)'" 22 | $null = New-Item ` 23 | -Path $Global:TestPath ` 24 | -ItemType Directory 25 | } 26 | 27 | [String[]] $Global:SharePaths = @() 28 | [String[]] $Global:ShareNames = @() 29 | # Create shares used for testing and add files to them 30 | 1..$Global:MaxShares | Foreach-Object { 31 | $ShareName = "Share$($_)" 32 | $SharePath = Join-Path -Path $Global:TestPath -ChildPath $ShareName 33 | Write-Verbose -Message "Creating share path '$SharePath'" 34 | $Global:ShareNames += $ShareName 35 | $Global:SharePaths += $SharePath 36 | If (-not (Test-Path $SharePath -PathType Container)) { 37 | $null = New-Item ` 38 | -Path $SharePath ` 39 | -ItemType Directory 40 | } 41 | 42 | # Create the share 43 | Write-Verbose -Message "Creating share $ShareName" 44 | $null = New-SMBShare ` 45 | -Path $SharePath ` 46 | -Name $ShareName 47 | 48 | # Copy some random files to the share 49 | Write-Verbose -Message "Copying content to $ShareName" 50 | $null = Copy-Item ` 51 | -Path $Global:FileSourceFolder ` 52 | -Destination $SharePath ` 53 | -Recurse ` 54 | -Force 55 | 56 | # Set the permissions on the file/folders in the share 57 | Write-Verbose -Message "Setting file/folder permissions on $ShareName" 58 | If ( $_ -eq 2 ) { 59 | Add-NTFSAccess ` 60 | -Path $SharePath ` 61 | -AccessRights FullControl ` 62 | -AppliesTo ThisFolderSubfoldersAndFiles ` 63 | -AccessType Allow ` 64 | -Account "$ENV:ComputerName\$env:USERNAME" 65 | Add-NTFSAccess ` 66 | -Path $SharePath ` 67 | -AccessRights Write ` 68 | -AppliesTo ThisFolderSubfoldersAndFiles ` 69 | -AccessType Allow ` 70 | -Account "$ENV:ComputerName\Administrator" 71 | Add-NTFSAccess ` 72 | -Path $SharePath ` 73 | -AccessRights Read ` 74 | -AppliesTo ThisFolderSubfoldersAndFiles ` 75 | -AccessType Allow ` 76 | -Account "BUILTIN\Users" 77 | Disable-NTFSAccessInheritance ` 78 | -Path $SharePath ` 79 | -RemoveInheritedAccessRules 80 | $null = Grant-SMBShareAccess ` 81 | -Name $ShareName ` 82 | -AccountName "BUILTIN\Guests" ` 83 | -AccessRight Full -Force 84 | } 85 | If ( $_ -eq 3 ) { 86 | Add-NTFSAccess ` 87 | -Path $SharePath ` 88 | -AccessRights FullControl ` 89 | -AppliesTo ThisFolderSubfoldersAndFiles ` 90 | -AccessType Allow ` 91 | -Account "BUILTIN\Guests" 92 | } 93 | } 94 | #endregion 95 | 96 | # Using try/finally to always cleanup even if something awful happens. 97 | try 98 | { 99 | InModuleScope ACLReportTools { 100 | #region Integration Tests 101 | Describe "New-ACLPathFileReport" { 102 | Context "Create using Non-inherited permissions only" { 103 | It 'Should not throw exception' { 104 | { 105 | $Global:NonInheritedPathFileReport = New-ACLPathFileReport -Path $Global:SharePaths 106 | } | Should Not Throw 107 | } 108 | } 109 | Context "Create using All permissions" { 110 | It 'Should not throw exception' { 111 | { 112 | $Global:AllPathFileReport = New-ACLPathFileReport -Path $Global:SharePaths -IncludeInherited 113 | } | Should Not Throw 114 | } 115 | } 116 | } 117 | 118 | Describe "New-ACLShareReport" { 119 | Context "Create using Non-inherited permissions only" { 120 | It 'Should not throw exception' { 121 | { 122 | $Global:NonInheritedShareReport = New-ACLShareReport -ComputerName $ENV:ComputerName -Include $ShareNames 123 | } | Should Not Throw 124 | } 125 | } 126 | Context "Create using All permissions" { 127 | It 'Should not throw exception' { 128 | { 129 | $Global:AllShareReport = New-ACLShareReport -ComputerName $ENV:ComputerName -Include $ShareNames -IncludeInherited 130 | } | Should Not Throw 131 | } 132 | } 133 | } 134 | 135 | Describe "Export-ACLReport" { 136 | Context "Export Path/File report with Non-inherited permissions only" { 137 | It 'Should not throw exception' { 138 | { 139 | $Global:NonInheritedPathFileReport | Export-ACLReport ` 140 | -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileNonInheritedPermissions.Report.acl') -Force 141 | } | Should Not Throw 142 | } 143 | } 144 | Context "Export Path/File report with All permissions" { 145 | It 'Should not throw exception' { 146 | { 147 | $Global:AllPathFileReport | Export-ACLReport ` 148 | -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileAllPermissions.Report.acl') -Force 149 | } | Should Not Throw 150 | } 151 | } 152 | Context "Export Share report with Non-inherited permissions only" { 153 | It 'Should not throw exception' { 154 | { 155 | $Global:NonInheritedShareReport | Export-ACLReport ` 156 | -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareNonInheritedPermissions.Report.acl') -Force 157 | } | Should Not Throw 158 | } 159 | } 160 | Context "Export Share report with All permissions" { 161 | It 'Should not throw exception' { 162 | { 163 | $Global:AllShareReport | Export-ACLReport ` 164 | -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareAllPermissions.Report.acl') -Force 165 | } | Should Not Throw 166 | } 167 | } 168 | } 169 | 170 | Describe "Import-ACLReport" { 171 | Context "Import Path/File report with Non-inherited permissions only" { 172 | It 'Should not throw exception' { 173 | { 174 | $Global:NonInheritedPathFileReportImported = Import-ACLReport -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileNonInheritedPermissions.Report.acl') 175 | } | Should Not Throw 176 | } 177 | } 178 | Context "Import Path/File report with All permissions" { 179 | It 'Should not throw exception' { 180 | { 181 | $Global:AllPathFileReportImported = Import-ACLReport -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileAllPermissions.Report.acl') 182 | } | Should Not Throw 183 | } 184 | } 185 | Context "Import Share report with Non-inherited permissions only" { 186 | It 'Should not throw exception' { 187 | { 188 | $Global:NonInheritedShareReportImported = Import-ACLReport -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareNonInheritedPermissions.Report.acl') 189 | } | Should Not Throw 190 | } 191 | } 192 | Context "Import Share report with All permissions" { 193 | It 'Should not throw exception' { 194 | { 195 | $Global:AllShareReportImported = Import-ACLReport -Path (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareAllPermissions.Report.acl') 196 | } | Should Not Throw 197 | } 198 | } 199 | } 200 | 201 | Describe "Compare-ACLReports" { 202 | Context "Compare Imported Path/File report with Non-inherited permissions only" { 203 | It 'Should not throw exception' { 204 | { 205 | $Global:NonInheritedPathFileDiffReport = Compare-ACLReports ` 206 | -Baseline $Global:NonInheritedPathFileReportImported ` 207 | -Path $Global:SharePaths 208 | } | Should Not Throw 209 | } 210 | It 'Should return no differences' { 211 | $Global:NonInheritedPathFileDiffReport | Should be $null 212 | } 213 | } 214 | Context "Compare Imported Path/File report with All permissions" { 215 | It 'Should not throw exception' { 216 | { 217 | $Global:AllPathFileDiffReport = Compare-ACLReports ` 218 | -Baseline $Global:AllPathFileReportImported ` 219 | -Path $Global:SharePaths ` 220 | -IncludeInherited 221 | } | Should Not Throw 222 | } 223 | It 'Should return no differences' { 224 | $Global:AllPathFileDiffReport | Should be $null 225 | } 226 | } 227 | Context "Compare Imported Path/File report with Non-inherited permissions only with All permissions" { 228 | It 'Should not throw exception' { 229 | { 230 | $Global:NonInheritedvsAllPathFileDiffReport = Compare-ACLReports ` 231 | -Baseline $Global:NonInheritedPathFileReportImported ` 232 | -Path $Global:SharePaths ` 233 | -IncludeInherited 234 | } | Should Not Throw 235 | } 236 | It 'Should return some differences' { 237 | $Global:NonInheritedvsAllPathFileDiffReport | Should not be $null 238 | } 239 | } 240 | Context "Compare Imported Share report with Non-inherited permissions only" { 241 | It 'Should not throw exception' { 242 | { 243 | $Global:NonInheritedShareDiffReport = Compare-ACLReports ` 244 | -Baseline $Global:NonInheritedShareReportImported ` 245 | -Include $Global:ShareNames 246 | } | Should Not Throw 247 | } 248 | It 'Should return no differences' { 249 | $Global:NonInheritedShareDiffReport | Should be $null 250 | } 251 | } 252 | Context "Compare Imported Share report with All permissions" { 253 | It 'Should not throw exception' { 254 | { 255 | $Global:AllShareDiffReport = Compare-ACLReports ` 256 | -Baseline $Global:AllShareReportImported ` 257 | -Include $Global:ShareNames ` 258 | -IncludeInherited 259 | } | Should Not Throw 260 | } 261 | It 'Should return no differences' { 262 | $Global:AllShareDiffReport | Should be $null 263 | } 264 | } 265 | Context "Compare Imported Share report with Non-inherited permissions only with All permissions" { 266 | It 'Should not throw exception' { 267 | { 268 | $Global:AllvsNonInheritedPathFileDiffReport = Compare-ACLReports ` 269 | -Baseline $Global:NonInheritedShareReportImported ` 270 | -Include $Global:ShareNames ` 271 | -IncludeInherited 272 | } | Should Not Throw 273 | } 274 | It 'Should return some differences' { 275 | $Global:AllvsNonInheritedPathFileDiffReport | Should not be $null 276 | } 277 | } 278 | 279 | # Modify the Permission information 280 | 1..$Global:MaxShares | Foreach-Object { 281 | $ShareName = "Share$($_)" 282 | $SharePath = Join-Path -Path $Global:TestPath -ChildPath $ShareName 283 | Write-Verbose -Message "Adding NTFS Permission to '$SharePath' AccessRights=FullControl, AppliesTo Filesonly -AccessType Allow -Account $ENV:COMPUTERNAME\$ENV:USERNAME" 284 | Add-NTFSAccess -Path $Global:TestPath -AccessRights FullControl -AppliesTo FilesOnly -AccessType Allow -Account "$ENV:COMPUTERNAME\$ENV:USERNAME" 285 | If ( $_ -eq 1 ) { 286 | Write-Verbose -Message "Setting NTFS Owner to $ENV:COMPUTERNAME\$ENV:USERNAME for $SharePath" 287 | Set-NTFSOwner -Account "$ENV:COMPUTERNAME\$ENV:USERNAME" -Path $SharePath 288 | } 289 | If ( $_ -eq 2 ) { 290 | Write-Verbose -Message "Editing NTFS Permission to '$SharePath' AccessRights=FullControl, AppliesTo ThisFolderSubfoldersAndFiles -AccessType Allow -Account BUILTIN\Users" 291 | Get-NTFSAccess -Path $SharePath -Account "BUILTIN\Users" | Remove-NTFSAccess 292 | Add-NTFSAccess -Path $SharePath -AccessRights FullControl -AppliesTo ThisFolderSubfoldersAndFiles -AccessType Allow -Account "BUILTIN\Users" 293 | Write-Verbose -Message "Removing ACL for $ENV:ComputerName\Administrator on $SharePath" 294 | Get-NTFSAccess -Path $SharePath -Account "$ENV:ComputerName\Administrator" | Remove-NTFSAccess 295 | Write-Verbose -Message "Revoking Access to $ShareName for Account BUILTIN\Guests" 296 | $null = Revoke-SMBShareAccess -Name $ShareName -AccountName "BUILTIN\Guests" -Force 297 | } 298 | If ( $_ -eq 3 ) { 299 | Write-Verbose -Message "Editing NTFS Permission to '$SharePath' AccessRights=FullControl, AppliesTo ThisFolderSubfoldersAndFiles -AccessType Deny -Account BUILTIN\Guests" 300 | Get-NTFSAccess -Path $SharePath -Account "BUILTIN\Guests" | Remove-NTFSAccess 301 | Add-NTFSAccess -Path $SharePath -AccessRights Read -AppliesTo ThisFolderSubfoldersAndFiles -AccessType Deny -Account "BUILTIN\Guests" 302 | Write-Verbose -Message "Granting Full Access to $ShareName for Account BUILTIN\Guests" 303 | $null = Grant-SMBShareAccess -Name $ShareName -AccountName "BUILTIN\Guests" -AccessRight Full -Force 304 | } 305 | If ( $_ -eq 4 ) { 306 | Write-Verbose -Message "Removing $ShareName" 307 | Get-SMBShare -Name $ShareName | Remove-SMBShare -Force 308 | } 309 | } 310 | 311 | Context "Compare Imported Path/File report with Non-inherited permissions only after permissions modified" { 312 | It 'Should not throw exception' { 313 | { 314 | $Global:NonInheritedPathFileModifiedDiffReport = Compare-ACLReports ` 315 | -Baseline $Global:NonInheritedPathFileReportImported ` 316 | -Path $Global:SharePaths 317 | } | Should Not Throw 318 | } 319 | It 'Should return some differences' { 320 | $Global:NonInheritedPathFileModifiedDiffReport | Should not be $null 321 | } 322 | } 323 | Context "Compare Imported Path/File report with All permissions after permissions modified" { 324 | It 'Should not throw exception' { 325 | { 326 | $Global:AllPathFileModifiedDiffReport = Compare-ACLReports ` 327 | -Baseline $Global:AllPathFileReportImported ` 328 | -Path $Global:SharePaths 329 | } | Should Not Throw 330 | } 331 | It 'Should return some differences' { 332 | $Global:AllPathFileModifiedDiffReport | Should not be $null 333 | } 334 | } 335 | Context "Compare Imported Share report with Non-inherited permissions only after permissions modified" { 336 | It 'Should not throw exception' { 337 | { 338 | $Global:NonInheritedShareModifiedDiffReport = Compare-ACLReports ` 339 | -Baseline $Global:NonInheritedShareReportImported ` 340 | -Include $Global:ShareNames 341 | } | Should Not Throw 342 | } 343 | It 'Should return some differences' { 344 | $Global:NonInheritedShareModifiedDiffReport | Should not be $null 345 | } 346 | } 347 | Context "Compare Imported Share report with All permissions after permissions modified" { 348 | It 'Should not throw exception' { 349 | { 350 | $Global:AllShareModifiedDiffReport = Compare-ACLReports ` 351 | -Baseline $Global:AllShareReportImported ` 352 | -Include $Global:ShareNames 353 | } | Should Not Throw 354 | } 355 | It 'Should return some differences' { 356 | $Global:AllShareModifiedDiffReport | Should not be $null 357 | } 358 | } 359 | } 360 | 361 | Describe "Export-ACLPermissionDiff" { 362 | Context "Export Path/File Different report with Non-inherited permissions only after permissions modified" { 363 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileNonInheritedModifiedPermissionsDiff.Report.acr') 364 | It 'Should not throw exception' { 365 | { 366 | $Global:NonInheritedPathFileModifiedDiffReport | Export-ACLPermissionDiff ` 367 | -Path $ReportFileName -Force 368 | } | Should Not Throw 369 | } 370 | It 'Should create file' { 371 | Test-Path -Path $ReportFileName | Should be $true 372 | } 373 | } 374 | Context "Export Path/File Different report with All permissions after permissions modified" { 375 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileAllModifiedPermissionsDiff.Report.acr') 376 | It 'Should not throw exception' { 377 | { 378 | $Global:AllPathFileModifiedDiffReport | Export-ACLPermissionDiff ` 379 | -Path $ReportFileName -Force 380 | } | Should Not Throw 381 | } 382 | It 'Should create file' { 383 | Test-Path -Path $ReportFileName | Should be $true 384 | } 385 | } 386 | Context "Export Path/File Different report with Non-inherited permissions only after permissions modified" { 387 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareNonInheritedModifiedPermissionsDiff.Report.acr') 388 | It 'Should not throw exception' { 389 | { 390 | $Global:NonInheritedShareModifiedDiffReport | Export-ACLPermissionDiff ` 391 | -Path $ReportFileName -Force 392 | } | Should Not Throw 393 | } 394 | It 'Should create file' { 395 | Test-Path -Path $ReportFileName | Should be $true 396 | } 397 | } 398 | Context "Export Path/File Different report with All permissions after permissions modified" { 399 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareAllModifiedPermissionsDiff.Report.acr') 400 | It 'Should not throw exception' { 401 | { 402 | $Global:AllShareModifiedDiffReport | Export-ACLPermissionDiff ` 403 | -Path $ReportFileName -Force 404 | } | Should Not Throw 405 | } 406 | It 'Should create file' { 407 | Test-Path -Path $ReportFileName | Should be $true 408 | } 409 | } 410 | } 411 | 412 | Describe "Export-ACLPermissionDiffHtml" { 413 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileNonInheritedModifiedPermissionsDiff.Report.htm') 414 | Context "Export Path/File Different report with Non-inherited permissions only after permissions modified" { 415 | It 'Should not throw exception' { 416 | { 417 | $Global:NonInheritedPathFileModifiedDiffReport | Export-ACLPermissionDiffHtml ` 418 | -Path $ReportFileName -Force 419 | } | Should Not Throw 420 | } 421 | It 'Should create file' { 422 | Test-Path -Path $ReportFileName | Should be $true 423 | } 424 | } 425 | Context "Export Path/File Different report with All permissions after permissions modified" { 426 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.PathFileAllModifiedPermissionsDiff.Report.htm') 427 | It 'Should not throw exception' { 428 | { 429 | $Global:AllPathFileModifiedDiffReport | Export-ACLPermissionDiffHtml ` 430 | -Path $ReportFileName -Force 431 | } | Should Not Throw 432 | } 433 | It 'Should create file' { 434 | Test-Path -Path $ReportFileName | Should be $true 435 | } 436 | } 437 | Context "Export Path/File Different report with Non-inherited permissions only after permissions modified" { 438 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareNonInheritedModifiedPermissionsDiff.Report.htm') 439 | It 'Should not throw exception' { 440 | { 441 | $Global:NonInheritedShareModifiedDiffReport | Export-ACLPermissionDiffHtml ` 442 | -Path $ReportFileName -Force 443 | } | Should Not Throw 444 | } 445 | It 'Should create file' { 446 | Test-Path -Path $ReportFileName | Should be $true 447 | } 448 | } 449 | Context "Export Path/File Different report with All permissions after permissions modified" { 450 | $ReportFileName = (Join-Path -Path $Global:ArtifactPath -ChildPath 'IntegrationTests.ShareAllModifiedPermissionsDiff.Report.htm') 451 | It 'Should not throw exception' { 452 | { 453 | $Global:AllShareModifiedDiffReport | Export-ACLPermissionDiffHtml ` 454 | -Path $ReportFileName -Force 455 | } | Should Not Throw 456 | } 457 | It 'Should create file' { 458 | Test-Path -Path $ReportFileName | Should be $true 459 | } 460 | } 461 | } 462 | 463 | #endregion 464 | } 465 | } 466 | finally 467 | { 468 | # Clean up 469 | Write-Verbose -Message "Removing test shares" 470 | Get-SMBShare -Name "Share*" | Remove-SMBShare -Force 471 | Remove-Item $Global:TestPath -Recurse -Force 472 | } 473 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | #---------------------------------# 2 | # environment configuration # 3 | #---------------------------------# 4 | os: WMF 5 5 | version: 1.30.1.{build} 6 | environment: 7 | PowerShellGalleryApiKey: 8 | secure: 3fXfDuds8yhTa7WTOLIEhytrpsej9kcP+4rPrgLaFVmIhimmc+FgUVxkR4u468LH 9 | install: 10 | - cinst -y pester 11 | 12 | #---------------------------------# 13 | # build configuration # 14 | #---------------------------------# 15 | 16 | build: false 17 | 18 | #---------------------------------# 19 | # test configuration # 20 | #---------------------------------# 21 | 22 | test_script: 23 | - ps: | 24 | $testResultsFile = ".\TestsResults.xml" 25 | $res = Invoke-Pester -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru 26 | (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile)) 27 | if ($res.FailedCount -gt 0) { 28 | throw "$($res.FailedCount) tests failed." 29 | } 30 | 31 | #---------------------------------# 32 | # deployment configuration # 33 | #---------------------------------# 34 | 35 | # scripts to run before deployment 36 | deploy_script: 37 | - ps: | 38 | # Creating project artifact 39 | $buildFolder = $ENV:APPVEYOR_BUILD_FOLDER 40 | $StagingFolder = Join-Path -Path $buildFolder -ChildPath 'Staging' 41 | $null = New-Item -Path $StagingFolder -Type directory 42 | $ModuleFolder = Join-Path -Path $StagingFolder -ChildPath 'ACLReportTools' 43 | $null = New-Item -Path $ModuleFolder -Type directory 44 | $VersionFolder = Join-Path -Path $ModuleFolder -ChildPath $ENV:APPVEYOR_BUILD_VERSION 45 | $null = New-Item -Path $VersionFolder -Type directory 46 | 47 | # Populate Version Folder 48 | $null = Copy-Item -Path (Join-Path -Path $buildFolder -ChildPath 'ACLReportTools.psd1') -Destination $VersionFolder 49 | $null = Copy-Item -Path (Join-Path -Path $buildFolder -ChildPath 'ACLReportTools.psm1') -Destination $VersionFolder 50 | $null = Copy-Item -Path (Join-Path -Path $buildFolder -ChildPath 'ACLReportTools.format.ps1xml') -Destination $VersionFolder 51 | $null = Copy-Item -Path (Join-Path -Path $buildFolder -ChildPath 'LICENSE') -Destination $VersionFolder 52 | $null = Copy-Item -Path (Join-Path -Path $buildFolder -ChildPath 'README.MD') -Destination $VersionFolder 53 | 54 | # Set version number 55 | $manifest = Join-Path -Path $VersionFolder -ChildPath "ACLReportTools.psd1" 56 | (Get-Content $manifest -Raw).Replace("1.0.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest 57 | 58 | # Create zip artifact 59 | $zipFilePath = Join-Path -Path $buildFolder -ChildPath "${env:APPVEYOR_PROJECT_NAME}_${env:APPVEYOR_BUILD_VERSION}.zip" 60 | $null = Add-Type -assemblyname System.IO.Compression.FileSystem 61 | [System.IO.Compression.ZipFile]::CreateFromDirectory($StagingFolder, $zipFilePath) 62 | 63 | # Create Publish Script Artifact 64 | $PublishScriptName = $env:APPVEYOR_PROJECT_NAME + "." + $env:APPVEYOR_BUILD_VERSION + "_publish.ps1" 65 | $PublishScriptPath = Join-Path -Path $buildFolder -ChildPath $PublishScriptName 66 | Set-Content -Path $PublishScriptPath -Value "Publish-Module -Name 'ACLReportTools' -RequiredVersion ${env:APPVEYOR_BUILD_VERSION} -NuGetApiKey (Read-Host -Prompt 'NuGetApiKey')" 67 | 68 | @( 69 | # You can add other artifacts here 70 | $zipFilePath, 71 | $PublishScriptPath 72 | ) | % { 73 | Write-Host "Pushing package $_ as Appveyor artifact" 74 | Push-AppveyorArtifact $_ 75 | } 76 | 77 | # Push test artifacts 78 | Get-ChildItem -Path (Join-Path -Path $buildFolder -ChildPath 'Artifacts\*.*') | Foreach-Object { Push-AppveyorArtifact $_ } 79 | 80 | # If this is a build of the Master branch and not a PR push 81 | # then publish the Module to the PowerShell Gallery. 82 | if ((! $ENV:APPVEYOR_PULL_REQUEST_NUMBER) -and ($ENV:APPVEYOR_REPO_BRANCH -eq 'master')) 83 | { 84 | Write-Host "Publishing Module to PowerShell Gallery" 85 | Copy-Item -Path $ModuleFolder -Destination ($ENV:PSModulePath -split ';')[0] -Recurse 86 | Get-PackageProvider -Name NuGet -ForceBootstrap 87 | Publish-Module -Name 'ACLReportTools' -RequiredVersion ${env:APPVEYOR_BUILD_VERSION} -NuGetApiKey $ENV:PowerShellGalleryApiKey -Confirm:$false 88 | } 89 | 90 | # Remove Staging Folder 91 | $null = Remove-Item -Path $StagingFolder -Recurse -Force 92 | --------------------------------------------------------------------------------