-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathown.ps1
42 lines (38 loc) · 881 Bytes
/
own.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<#
import-module <filepath>\own.ps1 first
#>
Function get-own
{
Param
(
#search $username in object owners
[Parameter(Mandatory=$true)]
[String]$username,
#look objects recursively in this $startPath
[Parameter(Mandatory=$true)]
[String]$startPath
)
Process
{
#search recursively in $startPath, object owned by $username
Get-ChildItem $startPath -Force -Recurse -ErrorAction 'SilentlyContinue' | `
Get-Acl | Where { $_.Owner -eq $username } | `
Format-List -Property PsPath
}
}
Function list-own
{
Param
(
#look objects recursively in this $startPath
[Parameter(Mandatory=$true)]
[String]$startPath
)
Process
{
#list all object owners, recursively in $startPath
Get-ChildItem $startPath -Force -Recurse -ErrorAction 'SilentlyContinue' | `
Get-Acl | `
Format-List -Property PsPath, Owner
}
}