added prune
This commit is contained in:
parent
de6b8d5643
commit
d5c10979f1
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PowerShell Launch Current File",
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"script": "${file}",
|
||||
"args": [],
|
||||
"cwd": "${file}"
|
||||
},
|
||||
{
|
||||
"name": "PowerShell Launch Current File in Temporary Console",
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"script": "${file}",
|
||||
"args": [],
|
||||
"cwd": "${file}",
|
||||
"createTemporaryIntegratedConsole": true
|
||||
},
|
||||
{
|
||||
"name": "PowerShell Launch Current File w/Args Prompt",
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"script": "${file}",
|
||||
"args": [
|
||||
"${command:SpecifyScriptArgs}"
|
||||
],
|
||||
"cwd": "${file}"
|
||||
},
|
||||
{
|
||||
"name": "PowerShell Attach to Host Process",
|
||||
"type": "PowerShell",
|
||||
"request": "attach"
|
||||
},
|
||||
{
|
||||
"name": "PowerShell Interactive Session",
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"cwd": ""
|
||||
},
|
||||
{
|
||||
"name": "PowerShell Attach Interactive Session Runspace",
|
||||
"type": "PowerShell",
|
||||
"request": "attach",
|
||||
"processId": "current"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -3,13 +3,20 @@ $WorkDir="$env:LOCALAPPDATA\ps-aclreport"
|
|||
|
||||
function createBaselineReport($Computer, $Share){
|
||||
$ShareName="${Computer}-${Share}"
|
||||
$Date=(Get-Date).ToString("yyyyMMddHHmm")
|
||||
$Date=(Get-Date).ToString("yyyyMMddHHmmss")
|
||||
$BaselineName="Baseline_${ShareName}_${Date}"
|
||||
New-ACLShareReport -ComputerName $Computer -Include $Share -IncludeInherited | Export-ACLReport -Path "${Workdir}\${BaselineName}.acl" -Force
|
||||
}
|
||||
|
||||
function pruneBaselineReports(){
|
||||
|
||||
$reg="([a-zA-Z]+_.*)_\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}\.acl"
|
||||
$ReportGroups=(Get-Childitem -Path $WorkDir) | Sort-Object -Property Name | Where-Object {$_.name -match "([a-zA-Z]+_.*)_\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}\.acl"} | Group-Object -Property {$Matches[1]}
|
||||
For ($i=0; $i -lt $ReportGroups.Length; $i++){
|
||||
For ($j=0; $j -lt $ReportGroups[$i].Count; $j++){
|
||||
if ($j -ne 0 -And $j -ne ($ReportGroups[$i].Count-1)){
|
||||
remove-item $ReportGroups[$i].Group[$j].FullName -Force
|
||||
}
|
||||
|
||||
createBaselineReport "nas.proferis.local" "techniczny"
|
||||
}
|
||||
}
|
||||
}
|
||||
pruneBaselineReports
|
||||
Loading…
Reference in New Issue