forked from dfinke/ImportExcel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-ExcelWorkbookInfo.ps1
65 lines (58 loc) · 2.3 KB
/
Get-ExcelWorkbookInfo.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Function Get-ExcelWorkbookInfo {
<#
.SYNOPSIS
Retrieve information of an Excel workbook.
.DESCRIPTION
The Get-ExcelWorkbookInfo cmdlet retrieves information (LastModifiedBy, LastPrinted, Created, Modified, ...) fron an Excel workbook. These are the same details that are visible in Windows Explorer when right clicking the Excel file, selecting Properties and check the Details tabpage.
.PARAMETER Path
Specifies the path to the Excel file. This parameter is required.
.EXAMPLE
Get-ExcelWorkbookInfo .\Test.xlsx
CorePropertiesXml : #document
Title :
Subject :
Author : Konica Minolta User
Comments :
Keywords :
LastModifiedBy : Bond, James (London) GBR
LastPrinted : 2017-01-21T12:36:11Z
Created : 17/01/2017 13:51:32
Category :
Status :
ExtendedPropertiesXml : #document
Application : Microsoft Excel
HyperlinkBase :
AppVersion : 14.0300
Company : Secret Service
Manager :
Modified : 10/02/2017 12:45:37
CustomPropertiesXml : #document
.NOTES
CHANGELOG
2016/01/07 Added Created by Johan Akerstrom (https://github.com/CosmosKey)
.LINK
https://github.com/dfinke/ImportExcel
#>
[CmdletBinding()]
Param (
[Alias('FullName')]
[Parameter(ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true, Mandatory=$true)]
[String]$Path
)
Process {
Try {
$Path = (Resolve-Path $Path).ProviderPath
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $Path,'Open','Read','ReadWrite'
$xl = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream
$workbook = $xl.Workbook
$workbook.Properties
$stream.Close()
$stream.Dispose()
$xl.Dispose()
$xl = $null
}
Catch {
throw "Failed retrieving Excel workbook information for '$Path': $_"
}
}
}