PoshCode Archive  Artifact [fd5e981f92]

Artifact fd5e981f92978d0bf25e45fc7437fdc8d2358cbf17d660ae9e073ba5591e4e46:

  • File Get-OwnerReport.ps1 — part of check-in [4b27884ee7] at 2018-06-10 13:06:06 on branch trunk — From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes (user: Lee Holmes size: 1074)

# encoding: ascii
# api: powershell
# title: Get-OwnerReport.ps1
# description: From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes
# version: 0.1
# author: Lee Holmes
# license: CC0
# x-poshcode-id: 2158
# x-archived: 2016-03-18T21:44:03
# x-published: 2011-09-09T21:41:00
#
#
##############################################################################
##
## Get-OwnerReport
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################

<#

.SYNOPSIS

Gets a list of files in the current directory, but with their owner added
to the resulting objects.

.EXAMPLE

Get-OwnerReport | Format-Table Name,LastWriteTime,Owner
Retrieves all files in the current directory, and displays the
Name, LastWriteTime, and Owner

#>

Set-StrictMode -Version Latest

$files = Get-ChildItem
foreach($file in $files)
{
    $owner = (Get-Acl $file).Owner
    $file | Add-Member NoteProperty Owner $owner
    $file
}